feat: add webhookSignature in feed channel
This commit is contained in:
parent
f592466d62
commit
6b3631eae1
@ -275,6 +275,9 @@ importers:
|
|||||||
lucide-react:
|
lucide-react:
|
||||||
specifier: ^0.358.0
|
specifier: ^0.358.0
|
||||||
version: 0.358.0(react@18.2.0)
|
version: 0.358.0(react@18.2.0)
|
||||||
|
md5:
|
||||||
|
specifier: ^2.3.0
|
||||||
|
version: 2.3.0
|
||||||
millify:
|
millify:
|
||||||
specifier: ^6.1.0
|
specifier: ^6.1.0
|
||||||
version: 6.1.0
|
version: 6.1.0
|
||||||
@ -378,6 +381,9 @@ importers:
|
|||||||
'@types/lodash-es':
|
'@types/lodash-es':
|
||||||
specifier: ^4.17.12
|
specifier: ^4.17.12
|
||||||
version: 4.17.12
|
version: 4.17.12
|
||||||
|
'@types/md5':
|
||||||
|
specifier: ^2.3.5
|
||||||
|
version: 2.3.5
|
||||||
'@types/react':
|
'@types/react':
|
||||||
specifier: ^18.2.22
|
specifier: ^18.2.22
|
||||||
version: 18.2.78
|
version: 18.2.78
|
||||||
|
@ -24,9 +24,13 @@ import {
|
|||||||
SelectValue,
|
SelectValue,
|
||||||
} from '../ui/select';
|
} from '../ui/select';
|
||||||
import { NotificationPicker } from '../notification/NotificationPicker';
|
import { NotificationPicker } from '../notification/NotificationPicker';
|
||||||
|
import { LuRefreshCcw } from 'react-icons/lu';
|
||||||
|
import md5 from 'md5';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
const addFormSchema = z.object({
|
const addFormSchema = z.object({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
|
webhookSignature: z.string().optional(),
|
||||||
notificationIds: z.array(z.string()).default([]),
|
notificationIds: z.array(z.string()).default([]),
|
||||||
notifyFrequency: z.enum(['none', 'event', 'day', 'week', 'month']),
|
notifyFrequency: z.enum(['none', 'event', 'day', 'week', 'month']),
|
||||||
});
|
});
|
||||||
@ -79,6 +83,38 @@ export const FeedChannelEditForm: React.FC<FeedChannelEditFormProps> =
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="webhookSignature"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel optional={true}>
|
||||||
|
{t('Webhook Signature')}
|
||||||
|
</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<div className="flex">
|
||||||
|
<Input className="rounded-r-none" {...field} />
|
||||||
|
<Button
|
||||||
|
className="rounded-l-none"
|
||||||
|
type="button"
|
||||||
|
Icon={LuRefreshCcw}
|
||||||
|
onClick={() => {
|
||||||
|
form.setValue(
|
||||||
|
'webhookSignature',
|
||||||
|
md5(dayjs().valueOf().toString())
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</FormControl>
|
||||||
|
<FormDescription>
|
||||||
|
{t('Optional, Webhook Signature for Incoming Webhook')}
|
||||||
|
</FormDescription>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="notificationIds"
|
name="notificationIds"
|
||||||
|
@ -70,6 +70,7 @@
|
|||||||
"leaflet": "^1.9.4",
|
"leaflet": "^1.9.4",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"lucide-react": "^0.358.0",
|
"lucide-react": "^0.358.0",
|
||||||
|
"md5": "^2.3.0",
|
||||||
"millify": "^6.1.0",
|
"millify": "^6.1.0",
|
||||||
"next-themes": "^0.2.1",
|
"next-themes": "^0.2.1",
|
||||||
"pretty-ms": "^9.0.0",
|
"pretty-ms": "^9.0.0",
|
||||||
@ -106,6 +107,7 @@
|
|||||||
"@types/leaflet": "^1.9.8",
|
"@types/leaflet": "^1.9.8",
|
||||||
"@types/loadable__component": "^5.13.8",
|
"@types/loadable__component": "^5.13.8",
|
||||||
"@types/lodash-es": "^4.17.12",
|
"@types/lodash-es": "^4.17.12",
|
||||||
|
"@types/md5": "^2.3.5",
|
||||||
"@types/react": "^18.2.22",
|
"@types/react": "^18.2.22",
|
||||||
"@types/react-beautiful-dnd": "^13.1.8",
|
"@types/react-beautiful-dnd": "^13.1.8",
|
||||||
"@types/react-dom": "^18.2.7",
|
"@types/react-dom": "^18.2.7",
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "FeedChannel" ADD COLUMN "webhookSignature" VARCHAR(100) NOT NULL DEFAULT '';
|
@ -540,12 +540,13 @@ enum FeedChannelNotifyFrequency {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model FeedChannel {
|
model FeedChannel {
|
||||||
id String @id @default(cuid()) @db.VarChar(30)
|
id String @id @default(cuid()) @db.VarChar(30)
|
||||||
workspaceId String @db.VarChar(30)
|
workspaceId String @db.VarChar(30)
|
||||||
name String
|
name String
|
||||||
notifyFrequency FeedChannelNotifyFrequency @default(day)
|
webhookSignature String @default("") @db.VarChar(100)
|
||||||
createdAt DateTime @default(now()) @db.Timestamptz(6)
|
notifyFrequency FeedChannelNotifyFrequency @default(day)
|
||||||
updatedAt DateTime @updatedAt @db.Timestamptz(6)
|
createdAt DateTime @default(now()) @db.Timestamptz(6)
|
||||||
|
updatedAt DateTime @updatedAt @db.Timestamptz(6)
|
||||||
|
|
||||||
workspace Workspace @relation(fields: [workspaceId], references: [id], onUpdate: Cascade, onDelete: Cascade)
|
workspace Workspace @relation(fields: [workspaceId], references: [id], onUpdate: Cascade, onDelete: Cascade)
|
||||||
events FeedEvent[]
|
events FeedEvent[]
|
||||||
|
@ -7,6 +7,7 @@ export const FeedChannelModelSchema = z.object({
|
|||||||
id: z.string(),
|
id: z.string(),
|
||||||
workspaceId: z.string(),
|
workspaceId: z.string(),
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
|
webhookSignature: z.string(),
|
||||||
notifyFrequency: z.nativeEnum(FeedChannelNotifyFrequency),
|
notifyFrequency: z.nativeEnum(FeedChannelNotifyFrequency),
|
||||||
createdAt: z.date(),
|
createdAt: z.date(),
|
||||||
updatedAt: z.date(),
|
updatedAt: z.date(),
|
||||||
|
@ -124,6 +124,7 @@ export const feedRouter = router({
|
|||||||
.merge(
|
.merge(
|
||||||
FeedChannelModelSchema.pick({
|
FeedChannelModelSchema.pick({
|
||||||
name: true,
|
name: true,
|
||||||
|
webhookSignature: true,
|
||||||
notifyFrequency: true,
|
notifyFrequency: true,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
@ -137,8 +138,14 @@ export const feedRouter = router({
|
|||||||
.nullable()
|
.nullable()
|
||||||
)
|
)
|
||||||
.mutation(async ({ input }) => {
|
.mutation(async ({ input }) => {
|
||||||
const { channelId, workspaceId, name, notifyFrequency, notificationIds } =
|
const {
|
||||||
input;
|
channelId,
|
||||||
|
workspaceId,
|
||||||
|
name,
|
||||||
|
webhookSignature,
|
||||||
|
notifyFrequency,
|
||||||
|
notificationIds,
|
||||||
|
} = input;
|
||||||
|
|
||||||
const channel = await prisma.feedChannel.update({
|
const channel = await prisma.feedChannel.update({
|
||||||
where: {
|
where: {
|
||||||
@ -147,6 +154,7 @@ export const feedRouter = router({
|
|||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
name,
|
name,
|
||||||
|
webhookSignature,
|
||||||
notifyFrequency,
|
notifyFrequency,
|
||||||
notifications: {
|
notifications: {
|
||||||
set: notificationIds.map((id) => ({
|
set: notificationIds.map((id) => ({
|
||||||
|
Loading…
Reference in New Issue
Block a user