From 9aaed9c6395da19e7bf0a8a140848c73421fea79 Mon Sep 17 00:00:00 2001 From: Aditya Alif Nugraha Date: Mon, 12 May 2025 18:31:30 +0200 Subject: [PATCH 1/3] Add event hooks to app settings --- src/client.ts | 19 ++++++++++++++++++- src/types.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/client.ts b/src/client.ts index d648da3e2..5bce92eda 100644 --- a/src/client.ts +++ b/src/client.ts @@ -754,7 +754,24 @@ export class StreamChat { 'data_template': 'data handlebars template', 'apn_template': 'apn notification handlebars template under v2' }, - 'webhook_url': 'https://acme.com/my/awesome/webhook/' + 'webhook_url': 'https://acme.com/my/awesome/webhook/', + 'event_hooks': [ + { + 'hook_type': 'webhook', + 'enabled': true, + 'event_types': ['message.new'], + 'webhook_url': 'https://acme.com/my/awesome/webhook/' + }, + { + 'hook_type': 'sqs', + 'enabled': true, + 'event_types': ['message.new'], + 'sqs_url': 'https://sqs.us-east-1.amazonaws.com/1234567890/my-queue', + 'sqs_auth_type': 'key', + 'sqs_key': 'my-access-key', + 'sqs_secret': 'my-secret-key' + } + ] } */ async updateAppSettings(options: AppSettings) { diff --git a/src/types.ts b/src/types.ts index 8a370c46f..7bafb981a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -162,6 +162,7 @@ export type AppSettingsAPIResponse = APIResponse & { sqs_key?: string; sqs_secret?: string; sqs_url?: string; + event_hooks?: Array; suspended?: boolean; suspended_explanation?: string; user_search_disallowed_roles?: string[] | null; @@ -2242,6 +2243,7 @@ export type AppSettings = { sqs_key?: string; sqs_secret?: string; sqs_url?: string; + event_hooks?: Array; video_provider?: string; webhook_events?: Array | null; webhook_url?: string; @@ -3977,3 +3979,27 @@ export type ThreadFilters = QueryFilters< | PrimitiveFilter; } >; + +export type HookType = 'webhook' | 'sqs' | 'sns'; + +export type EventHook = { + id?: string; + hook_type?: HookType; + enabled?: boolean; + event_types?: Array; + webhook_url?: string; + sqs_queue_url?: string; + sqs_region?: string; + sqs_auth_type?: string; + sqs_key?: string; + sqs_secret?: string; + sqs_role_arn?: string; + sns_topic_arn?: string; + sns_region?: string; + sns_auth_type?: string; + sns_key?: string; + sns_secret?: string; + sns_role_arn?: string; + created_at?: string; + updated_at?: string; +}; From 12f405496f52db41d1c0ed3f34dfcd3b76fa5a4d Mon Sep 17 00:00:00 2001 From: Aditya Alif Nugraha Date: Tue, 13 May 2025 12:54:00 +0200 Subject: [PATCH 2/3] Reorder event hook --- src/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types.ts b/src/types.ts index 7bafb981a..e6796e649 100644 --- a/src/types.ts +++ b/src/types.ts @@ -129,6 +129,7 @@ export type AppSettingsAPIResponse = APIResponse & { disable_auth_checks?: boolean; disable_permissions_checks?: boolean; enforce_unique_usernames?: 'no' | 'app' | 'team'; + event_hooks?: Array; file_upload_config?: FileUploadConfig; geofences?: Array<{ country_codes: Array; @@ -162,7 +163,6 @@ export type AppSettingsAPIResponse = APIResponse & { sqs_key?: string; sqs_secret?: string; sqs_url?: string; - event_hooks?: Array; suspended?: boolean; suspended_explanation?: string; user_search_disallowed_roles?: string[] | null; @@ -2212,6 +2212,7 @@ export type AppSettings = { disable_auth_checks?: boolean; disable_permissions_checks?: boolean; enforce_unique_usernames?: 'no' | 'app' | 'team'; + event_hooks?: Array; // all possible file mime types are https://www.iana.org/assignments/media-types/media-types.xhtml file_upload_config?: FileUploadConfig; firebase_config?: { @@ -2243,7 +2244,6 @@ export type AppSettings = { sqs_key?: string; sqs_secret?: string; sqs_url?: string; - event_hooks?: Array; video_provider?: string; webhook_events?: Array | null; webhook_url?: string; From 66cced5b316c4bf2c1b53ddc511ea52259a02534 Mon Sep 17 00:00:00 2001 From: Aditya Alif Nugraha Date: Tue, 13 May 2025 13:04:04 +0200 Subject: [PATCH 3/3] Add null default --- src/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types.ts b/src/types.ts index e6796e649..35bb277ba 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2212,7 +2212,7 @@ export type AppSettings = { disable_auth_checks?: boolean; disable_permissions_checks?: boolean; enforce_unique_usernames?: 'no' | 'app' | 'team'; - event_hooks?: Array; + event_hooks?: Array | null; // all possible file mime types are https://www.iana.org/assignments/media-types/media-types.xhtml file_upload_config?: FileUploadConfig; firebase_config?: {