From 6b3631eae186b9cacf64d0ddcfbb66378e041281 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Tue, 29 Oct 2024 03:41:45 +0800 Subject: [PATCH] feat: add webhookSignature in feed channel --- pnpm-lock.yaml | 6 ++++ .../components/feed/FeedChannelEditForm.tsx | 36 +++++++++++++++++++ src/client/package.json | 2 ++ .../migration.sql | 2 ++ src/server/prisma/schema.prisma | 13 +++---- src/server/prisma/zod/feedchannel.ts | 1 + src/server/trpc/routers/feed/index.ts | 12 +++++-- 7 files changed, 64 insertions(+), 8 deletions(-) create mode 100644 src/server/prisma/migrations/20241028184601_add_feedchannel_webhook_signature/migration.sql diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f3cf54c..8f23d90 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -275,6 +275,9 @@ importers: lucide-react: specifier: ^0.358.0 version: 0.358.0(react@18.2.0) + md5: + specifier: ^2.3.0 + version: 2.3.0 millify: specifier: ^6.1.0 version: 6.1.0 @@ -378,6 +381,9 @@ importers: '@types/lodash-es': specifier: ^4.17.12 version: 4.17.12 + '@types/md5': + specifier: ^2.3.5 + version: 2.3.5 '@types/react': specifier: ^18.2.22 version: 18.2.78 diff --git a/src/client/components/feed/FeedChannelEditForm.tsx b/src/client/components/feed/FeedChannelEditForm.tsx index e7312b0..f13d7e8 100644 --- a/src/client/components/feed/FeedChannelEditForm.tsx +++ b/src/client/components/feed/FeedChannelEditForm.tsx @@ -24,9 +24,13 @@ import { SelectValue, } from '../ui/select'; import { NotificationPicker } from '../notification/NotificationPicker'; +import { LuRefreshCcw } from 'react-icons/lu'; +import md5 from 'md5'; +import dayjs from 'dayjs'; const addFormSchema = z.object({ name: z.string(), + webhookSignature: z.string().optional(), notificationIds: z.array(z.string()).default([]), notifyFrequency: z.enum(['none', 'event', 'day', 'week', 'month']), }); @@ -79,6 +83,38 @@ export const FeedChannelEditForm: React.FC = )} /> + ( + + + {t('Webhook Signature')} + + +
+ +
+
+ + {t('Optional, Webhook Signature for Incoming Webhook')} + + +
+ )} + /> + { - const { channelId, workspaceId, name, notifyFrequency, notificationIds } = - input; + const { + channelId, + workspaceId, + name, + webhookSignature, + notifyFrequency, + notificationIds, + } = input; const channel = await prisma.feedChannel.update({ where: { @@ -147,6 +154,7 @@ export const feedRouter = router({ }, data: { name, + webhookSignature, notifyFrequency, notifications: { set: notificationIds.map((id) => ({