Skip to content

feat: [CHA-858] Add event hooks to app settings #1537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
26 changes: 26 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<EventHook>;
file_upload_config?: FileUploadConfig;
geofences?: Array<{
country_codes: Array<string>;
Expand Down Expand Up @@ -2212,6 +2213,7 @@ export type AppSettings = {
disable_auth_checks?: boolean;
disable_permissions_checks?: boolean;
enforce_unique_usernames?: 'no' | 'app' | 'team';
event_hooks?: Array<EventHook> | null;
// all possible file mime types are https://www.iana.org/assignments/media-types/media-types.xhtml
file_upload_config?: FileUploadConfig;
firebase_config?: {
Expand Down Expand Up @@ -4005,3 +4007,27 @@ export type ThreadFilters = QueryFilters<
| PrimitiveFilter<ThreadResponse['last_message_at']>;
}
>;

export type HookType = 'webhook' | 'sqs' | 'sns';

export type EventHook = {
id?: string;
hook_type?: HookType;
enabled?: boolean;
event_types?: Array<string>;
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;
};
Loading