Multiple operations on webhooks (#7807)
fixes #7792 WIP :) https://github.com/user-attachments/assets/91f16744-c002-4f24-9cdd-cff79743cab1 --------- Co-authored-by: martmull <martmull@hotmail.fr>
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import { Logger } from '@nestjs/common';
|
||||
|
||||
import { Like } from 'typeorm';
|
||||
import { ArrayContains } from 'typeorm';
|
||||
|
||||
import { ObjectMetadataInterface } from 'src/engine/metadata-modules/field-metadata/interfaces/object-metadata.interface';
|
||||
|
||||
@ -54,10 +54,10 @@ export class CallWebhookJobsJob {
|
||||
|
||||
const webhooks = await webhookRepository.find({
|
||||
where: [
|
||||
{ operation: Like(`%${eventName}%`) },
|
||||
{ operation: Like(`%*.${operation}%`) },
|
||||
{ operation: Like(`%${nameSingular}.*%`) },
|
||||
{ operation: Like('%*.*%') },
|
||||
{ operations: ArrayContains([eventName]) },
|
||||
{ operations: ArrayContains([`*.${operation}`]) },
|
||||
{ operations: ArrayContains([`${nameSingular}.*`]) },
|
||||
{ operations: ArrayContains(['*.*']) },
|
||||
],
|
||||
});
|
||||
|
||||
@ -80,12 +80,9 @@ export class CallWebhookJobsJob {
|
||||
);
|
||||
});
|
||||
|
||||
if (webhooks.length) {
|
||||
webhooks.length > 0 &&
|
||||
this.logger.log(
|
||||
`CallWebhookJobsJob on eventName '${eventName}' called on webhooks ids [\n"${webhooks
|
||||
.map((webhook) => webhook.id)
|
||||
.join('",\n"')}"\n]`,
|
||||
`CallWebhookJobsJob on eventName '${eventName}' triggered webhooks with ids [\n"${webhooks.map((webhook) => webhook.id).join('",\n"')}"\n]`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -189,3 +189,9 @@ export class FieldMetadataDefaultValuePhones {
|
||||
@IsObject()
|
||||
additionalPhones: object | null;
|
||||
}
|
||||
|
||||
export class FieldMetadataDefaultArray {
|
||||
@ValidateIf((_object, value) => value !== null)
|
||||
@IsArray()
|
||||
value: string[] | null;
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import {
|
||||
FieldMetadataDefaultActor,
|
||||
FieldMetadataDefaultArray,
|
||||
FieldMetadataDefaultValueAddress,
|
||||
FieldMetadataDefaultValueBoolean,
|
||||
FieldMetadataDefaultValueCurrency,
|
||||
@ -48,6 +49,7 @@ type FieldMetadataDefaultValueMapping = {
|
||||
[FieldMetadataType.RAW_JSON]: FieldMetadataDefaultValueRawJson;
|
||||
[FieldMetadataType.RICH_TEXT]: FieldMetadataDefaultValueRichText;
|
||||
[FieldMetadataType.ACTOR]: FieldMetadataDefaultActor;
|
||||
[FieldMetadataType.ARRAY]: FieldMetadataDefaultArray;
|
||||
};
|
||||
|
||||
export type FieldMetadataClassValidation =
|
||||
|
||||
@ -400,6 +400,7 @@ export const VIEW_STANDARD_FIELD_IDS = {
|
||||
export const WEBHOOK_STANDARD_FIELD_IDS = {
|
||||
targetUrl: '20202020-1229-45a8-8cf4-85c9172aae12',
|
||||
operation: '20202020-15b7-458e-bf30-74770a54410c',
|
||||
operations: '20202020-15b7-458e-bf30-74770a54411c',
|
||||
description: '20202020-15b7-458e-bf30-74770a54410d',
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user