summaryrefslogtreecommitdiff
path: root/packages/backend/src/queue/index.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2022-04-03 22:36:30 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2022-04-03 22:36:30 +0900
commitf8e6f3cc73b041acd7c8e8186090a297db3100a9 (patch)
treecd72442610caedb742419069065d014edbefadd8 /packages/backend/src/queue/index.ts
parentfix type (diff)
downloadsharkey-f8e6f3cc73b041acd7c8e8186090a297db3100a9.tar.gz
sharkey-f8e6f3cc73b041acd7c8e8186090a297db3100a9.tar.bz2
sharkey-f8e6f3cc73b041acd7c8e8186090a297db3100a9.zip
improve webhook
Diffstat (limited to 'packages/backend/src/queue/index.ts')
-rw-r--r--packages/backend/src/queue/index.ts8
1 files changed, 6 insertions, 2 deletions
diff --git a/packages/backend/src/queue/index.ts b/packages/backend/src/queue/index.ts
index a570400b7b..5bd922468d 100644
--- a/packages/backend/src/queue/index.ts
+++ b/packages/backend/src/queue/index.ts
@@ -1,4 +1,5 @@
import httpSignature from 'http-signature';
+import { v4 as uuid } from 'uuid';
import config from '@/config/index.js';
import { envOption } from '../env.js';
@@ -16,7 +17,7 @@ import { getJobInfo } from './get-job-info.js';
import { systemQueue, dbQueue, deliverQueue, inboxQueue, objectStorageQueue, endedPollNotificationQueue, webhookDeliverQueue } from './queues.js';
import { ThinUser } from './types.js';
import { IActivity } from '@/remote/activitypub/type.js';
-import { Webhook } from '@/models/entities/webhook.js';
+import { Webhook, webhookEventTypes } from '@/models/entities/webhook.js';
function renderError(e: Error): any {
return {
@@ -262,12 +263,15 @@ export function createCleanRemoteFilesJob() {
});
}
-export function webhookDeliver(webhook: Webhook, content: unknown) {
+export function webhookDeliver(webhook: Webhook, type: typeof webhookEventTypes[number], content: unknown) {
const data = {
+ type,
content,
webhookId: webhook.id,
to: webhook.url,
secret: webhook.secret,
+ createdAt: Date.now(),
+ eventId: uuid(),
};
return webhookDeliverQueue.add(data, {