feat(webhook/handler): use UUID for internal ids
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
|
import Crypto from 'node:crypto';
|
||||||
import { Response } from 'express';
|
import { Response } from 'express';
|
||||||
import bcrypt from 'bcrypt';
|
|
||||||
import { IRequest, ITriggerItem } from '@automatisch/types';
|
import { IRequest, ITriggerItem } from '@automatisch/types';
|
||||||
|
|
||||||
import Flow from '../../models/flow';
|
import Flow from '../../models/flow';
|
||||||
@@ -57,7 +57,6 @@ export default async (request: IRequest, response: Response) => {
|
|||||||
|
|
||||||
// in case trigger type is 'webhook'
|
// in case trigger type is 'webhook'
|
||||||
let payload = request.body;
|
let payload = request.body;
|
||||||
let rawInternalId: string | Buffer = request.rawBody;
|
|
||||||
|
|
||||||
// in case it's our built-in generic webhook trigger
|
// in case it's our built-in generic webhook trigger
|
||||||
if (isWebhookApp) {
|
if (isWebhookApp) {
|
||||||
@@ -66,14 +65,12 @@ export default async (request: IRequest, response: Response) => {
|
|||||||
body: request.body,
|
body: request.body,
|
||||||
query: request.query,
|
query: request.query,
|
||||||
};
|
};
|
||||||
|
|
||||||
rawInternalId = JSON.stringify(payload);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const triggerItem: ITriggerItem = {
|
const triggerItem: ITriggerItem = {
|
||||||
raw: payload,
|
raw: payload,
|
||||||
meta: {
|
meta: {
|
||||||
internalId: await bcrypt.hash(rawInternalId, 1),
|
internalId: Crypto.randomUUID(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user