105 lines
5.1 KiB
Diff
105 lines
5.1 KiB
Diff
diff --git a/packages/backend/src/core/NotificationService.ts b/packages/backend/src/core/NotificationService.ts
|
|
index 68ad92f..69b04c1 100644
|
|
--- a/packages/backend/src/core/NotificationService.ts
|
|
+++ b/packages/backend/src/core/NotificationService.ts
|
|
@@ -21,6 +21,8 @@ import type { Config } from '@/config.js';
|
|
import { UserListService } from '@/core/UserListService.js';
|
|
import type { FilterUnionByProperty } from '@/types.js';
|
|
import { trackPromise } from '@/misc/promise-tracker.js';
|
|
+import { WebhookService } from './WebhookService.js';
|
|
+import { QueueService } from './QueueService.js';
|
|
|
|
@Injectable()
|
|
export class NotificationService implements OnApplicationShutdown {
|
|
@@ -42,6 +44,8 @@ export class NotificationService implements OnApplicationShutdown {
|
|
private pushNotificationService: PushNotificationService,
|
|
private cacheService: CacheService,
|
|
private userListService: UserListService,
|
|
+ private webhookService: WebhookService,
|
|
+ private queueService: QueueService,
|
|
) {
|
|
}
|
|
|
|
@@ -175,6 +179,13 @@ export class NotificationService implements OnApplicationShutdown {
|
|
const latestReadNotificationId = await this.redisClient.get(`latestReadNotification:${notifieeId}`);
|
|
if (latestReadNotificationId && (latestReadNotificationId >= (await redisIdPromise)!)) return;
|
|
|
|
+ const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === notifieeId && x.on.includes('notification'));
|
|
+ for (const webhook of webhooks) {
|
|
+ this.queueService.webhookDeliver(webhook, 'notification', {
|
|
+ notification: packed
|
|
+ });
|
|
+ }
|
|
+
|
|
this.globalEventService.publishMainStream(notifieeId, 'unreadNotification', packed);
|
|
this.pushNotificationService.pushNotification(notifieeId, 'notification', packed);
|
|
|
|
diff --git a/packages/backend/src/models/Webhook.ts b/packages/backend/src/models/Webhook.ts
|
|
index 2a727f8..c4d490e 100644
|
|
--- a/packages/backend/src/models/Webhook.ts
|
|
+++ b/packages/backend/src/models/Webhook.ts
|
|
@@ -7,7 +7,7 @@ import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typ
|
|
import { id } from './util/id.js';
|
|
import { MiUser } from './User.js';
|
|
|
|
-export const webhookEventTypes = ['mention', 'unfollow', 'follow', 'followed', 'note', 'reply', 'renote', 'reaction', 'edited'] as const;
|
|
+export const webhookEventTypes = ['mention', 'unfollow', 'follow', 'followed', 'note', 'reply', 'renote', 'reaction', 'edited', 'notification'] as const;
|
|
|
|
@Entity('webhook')
|
|
export class MiWebhook {
|
|
diff --git a/packages/frontend/src/pages/settings/webhook.edit.vue b/packages/frontend/src/pages/settings/webhook.edit.vue
|
|
index 99326c8..fbfabc4 100644
|
|
--- a/packages/frontend/src/pages/settings/webhook.edit.vue
|
|
+++ b/packages/frontend/src/pages/settings/webhook.edit.vue
|
|
@@ -29,6 +29,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|
<MkSwitch v-model="event_renote">{{ i18n.ts._webhookSettings._events.renote }}</MkSwitch>
|
|
<MkSwitch v-model="event_reaction">{{ i18n.ts._webhookSettings._events.reaction }}</MkSwitch>
|
|
<MkSwitch v-model="event_mention">{{ i18n.ts._webhookSettings._events.mention }}</MkSwitch>
|
|
+ <MkSwitch v-model="event_notification">on notification</MkSwitch>
|
|
</div>
|
|
</FormSection>
|
|
|
|
@@ -75,6 +76,7 @@ const event_reply = ref(webhook.on.includes('reply'));
|
|
const event_renote = ref(webhook.on.includes('renote'));
|
|
const event_reaction = ref(webhook.on.includes('reaction'));
|
|
const event_mention = ref(webhook.on.includes('mention'));
|
|
+const event_notification = ref(webhook.on.includes('notification'));
|
|
|
|
async function save(): Promise<void> {
|
|
const events = [];
|
|
@@ -85,6 +87,7 @@ async function save(): Promise<void> {
|
|
if (event_renote.value) events.push('renote');
|
|
if (event_reaction.value) events.push('reaction');
|
|
if (event_mention.value) events.push('mention');
|
|
+ if (event_notification.value) events.push('notification');
|
|
|
|
os.apiWithDialog('i/webhooks/update', {
|
|
name: name.value,
|
|
diff --git a/packages/frontend/src/pages/settings/webhook.new.vue b/packages/frontend/src/pages/settings/webhook.new.vue
|
|
index 2993863..c2db510 100644
|
|
--- a/packages/frontend/src/pages/settings/webhook.new.vue
|
|
+++ b/packages/frontend/src/pages/settings/webhook.new.vue
|
|
@@ -29,6 +29,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|
<MkSwitch v-model="event_renote">{{ i18n.ts._webhookSettings._events.renote }}</MkSwitch>
|
|
<MkSwitch v-model="event_reaction">{{ i18n.ts._webhookSettings._events.reaction }}</MkSwitch>
|
|
<MkSwitch v-model="event_mention">{{ i18n.ts._webhookSettings._events.mention }}</MkSwitch>
|
|
+ <MkSwitch v-model="event_notification">on notification</MkSwitch>
|
|
</div>
|
|
</FormSection>
|
|
|
|
@@ -59,6 +60,7 @@ const event_reply = ref(true);
|
|
const event_renote = ref(true);
|
|
const event_reaction = ref(true);
|
|
const event_mention = ref(true);
|
|
+const event_notification = ref(true);
|
|
|
|
async function create(): Promise<void> {
|
|
const events = [];
|
|
@@ -69,6 +71,7 @@ async function create(): Promise<void> {
|
|
if (event_renote.value) events.push('renote');
|
|
if (event_reaction.value) events.push('reaction');
|
|
if (event_mention.value) events.push('mention');
|
|
+ if (event_notification.value) events.push('notification');
|
|
|
|
os.apiWithDialog('i/webhooks/create', {
|
|
name: name.value,
|