mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-18 13:06:32 -06:00
fix: set webhook
This commit is contained in:
parent
ca503b49c6
commit
fcdee75f39
@ -89,7 +89,8 @@ export class EventController {
|
|||||||
instanceId: this.monitor.waInstances[instanceName].instanceId,
|
instanceId: this.monitor.waInstances[instanceName].instanceId,
|
||||||
},
|
},
|
||||||
update: {
|
update: {
|
||||||
...data[this.name],
|
enabled: data[this.name]?.enabled,
|
||||||
|
events: data[this.name].events,
|
||||||
},
|
},
|
||||||
create: {
|
create: {
|
||||||
enabled: data[this.name]?.enabled,
|
enabled: data[this.name]?.enabled,
|
||||||
|
@ -30,18 +30,24 @@ export class WebhookController extends EventController implements EventControlle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('data.webhook', data);
|
||||||
|
|
||||||
return this.prisma.webhook.upsert({
|
return this.prisma.webhook.upsert({
|
||||||
where: {
|
where: {
|
||||||
instanceId: this.monitor.waInstances[instanceName].instanceId,
|
instanceId: this.monitor.waInstances[instanceName].instanceId,
|
||||||
},
|
},
|
||||||
update: {
|
update: {
|
||||||
...data.webhook,
|
enabled: data.webhook?.enabled,
|
||||||
|
events: data.webhook?.events,
|
||||||
|
url: data.webhook?.url,
|
||||||
|
webhookBase64: data.webhook.base64,
|
||||||
|
webhookByEvents: data.webhook.byEvents,
|
||||||
},
|
},
|
||||||
create: {
|
create: {
|
||||||
enabled: data.webhook?.enabled,
|
enabled: data.webhook?.enabled,
|
||||||
events: data.webhook.events,
|
events: data.webhook?.events,
|
||||||
instanceId: this.monitor.waInstances[instanceName].instanceId,
|
instanceId: this.monitor.waInstances[instanceName].instanceId,
|
||||||
url: data.webhook.url,
|
url: data.webhook?.url,
|
||||||
webhookBase64: data.webhook.base64,
|
webhookBase64: data.webhook.base64,
|
||||||
webhookByEvents: data.webhook.byEvents,
|
webhookByEvents: data.webhook.byEvents,
|
||||||
},
|
},
|
||||||
|
@ -22,12 +22,15 @@ const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {
|
|||||||
|
|
||||||
export const webhookSchema: JSONSchema7 = {
|
export const webhookSchema: JSONSchema7 = {
|
||||||
$id: v4(),
|
$id: v4(),
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
webhook: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
enabled: { type: 'boolean' },
|
enabled: { type: 'boolean' },
|
||||||
url: { type: 'string' },
|
url: { type: 'string' },
|
||||||
webhookByEvents: { type: 'boolean' },
|
byEvents: { type: 'boolean' },
|
||||||
webhookBase64: { type: 'boolean' },
|
base64: { type: 'boolean' },
|
||||||
events: {
|
events: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
minItems: 0,
|
minItems: 0,
|
||||||
@ -65,4 +68,7 @@ export const webhookSchema: JSONSchema7 = {
|
|||||||
},
|
},
|
||||||
required: ['enabled', 'url'],
|
required: ['enabled', 'url'],
|
||||||
...isNotEmpty('enabled', 'url'),
|
...isNotEmpty('enabled', 'url'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
required: ['webhook'],
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user