mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-23 04:22:02 -06:00
fix: fix webhook integration
This commit is contained in:
parent
3b39f13180
commit
68f57aa507
@ -30,27 +30,24 @@ export class WebhookController extends EventController {
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await this.get(instanceName);
|
||||
|
||||
return this.prisma.webhook.update({
|
||||
where: {
|
||||
instanceId: this.monitor.waInstances[instanceName].instanceId,
|
||||
},
|
||||
data,
|
||||
});
|
||||
} catch (err) {
|
||||
return this.prisma.webhook.create({
|
||||
data: {
|
||||
enabled: data.enabled,
|
||||
events: data.events,
|
||||
instanceId: this.monitor.waInstances[instanceName].instanceId,
|
||||
url: data.url,
|
||||
webhookBase64: data.webhookBase64,
|
||||
webhookByEvents: data.webhookByEvents,
|
||||
},
|
||||
});
|
||||
}
|
||||
await this.get(instanceName);
|
||||
|
||||
return this.prisma.webhook.upsert({
|
||||
where: {
|
||||
instanceId: this.monitor.waInstances[instanceName].instanceId,
|
||||
},
|
||||
update: {
|
||||
...data,
|
||||
},
|
||||
create: {
|
||||
enabled: data.enabled,
|
||||
events: data.events,
|
||||
instanceId: this.monitor.waInstances[instanceName].instanceId,
|
||||
url: data.url,
|
||||
webhookBase64: data.webhookBase64,
|
||||
webhookByEvents: data.webhookByEvents,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public async get(instanceName: string): Promise<wa.LocalWebHook> {
|
||||
|
Loading…
Reference in New Issue
Block a user