Skip to content

Commit ddb885e

Browse files
committed
Enhance notification system with webhook support
1 parent 335f6b7 commit ddb885e

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hawk.api",
3-
"version": "1.4.6",
3+
"version": "1.4.7",
44
"main": "index.ts",
55
"license": "BUSL-1.1",
66
"scripts": {
@@ -42,7 +42,7 @@
4242
"@graphql-tools/schema": "^8.5.1",
4343
"@graphql-tools/utils": "^8.9.0",
4444
"@hawk.so/nodejs": "^3.3.1",
45-
"@hawk.so/types": "^0.5.8",
45+
"@hawk.so/types": "^0.5.9",
4646
"@n1ru4l/json-patch-plus": "^0.2.0",
4747
"@node-saml/node-saml": "^5.0.1",
4848
"@octokit/oauth-methods": "^4.0.0",

src/rabbitmq.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export enum Queues {
2828
Telegram = 'notify/telegram',
2929
Slack = 'notify/slack',
3030
Loop = 'notify/loop',
31+
Webhook = 'sender/webhook',
3132
Limiter = 'cron-tasks/limiter',
3233
}
3334

@@ -90,6 +91,14 @@ export const WorkerPaths: Record<string, WorkerPath> = {
9091
queue: Queues.Loop,
9192
},
9293

94+
/**
95+
* Path to webhook worker
96+
*/
97+
Webhook: {
98+
exchange: Exchanges.Empty,
99+
queue: Queues.Webhook,
100+
},
101+
93102
/**
94103
* Path to limiter worker
95104
*/

src/typeDefs/notifications.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ export default gql`
4949
"""
5050
loop: NotificationsChannelSettings
5151
52+
"""
53+
Webhook channel
54+
"""
55+
webhook: NotificationsChannelSettings
56+
5257
"""
5358
Webpush
5459
"""

src/typeDefs/notificationsInput.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ export default gql`
4545
"""
4646
loop: NotificationsChannelSettingsInput
4747
48+
"""
49+
Webhook channel
50+
"""
51+
webhook: NotificationsChannelSettingsInput
52+
4853
"""
4954
Web push
5055
"""

src/utils/personalNotifications.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,14 @@ export default async function sendNotification(user: UserDBScheme, task: SenderW
5252
},
5353
});
5454
}
55+
56+
if (user.notifications.channels.webhook?.isEnabled) {
57+
await enqueue(WorkerPaths.Webhook, {
58+
type: task.type,
59+
payload: {
60+
...task.payload,
61+
endpoint: user.notifications.channels.webhook.endpoint,
62+
},
63+
});
64+
}
5565
}

0 commit comments

Comments
 (0)