mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
⚡ Small improvements to Mailjet-Node
This commit is contained in:
@@ -62,14 +62,14 @@ export class MailjetTrigger implements INodeType {
|
||||
name: 'email.open',
|
||||
value: 'open',
|
||||
},
|
||||
{
|
||||
name: 'email.spam',
|
||||
value: 'spam',
|
||||
},
|
||||
{
|
||||
name: 'email.sent',
|
||||
value: 'sent',
|
||||
},
|
||||
{
|
||||
name: 'email.spam',
|
||||
value: 'spam',
|
||||
},
|
||||
{
|
||||
name: 'email.unsub',
|
||||
value: 'unsub',
|
||||
@@ -85,17 +85,22 @@ export class MailjetTrigger implements INodeType {
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
if (webhookData.webhookId === undefined) {
|
||||
return false;
|
||||
const endpoint = `/v3/rest/eventcallbackurl`;
|
||||
const responseData = await mailjetApiRequest.call(this, 'GET', endpoint);
|
||||
|
||||
const event = this.getNodeParameter('event') as string;
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
|
||||
for (const webhook of responseData.Data) {
|
||||
if (webhook.EventType === event && webhook.Url === webhookUrl) {
|
||||
// Set webhook-id to be sure that it can be deleted
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
webhookData.webhookId = webhook.ID as string;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
const endpoint = `/v3/rest/eventcallbackurl/${webhookData.webhookId}`;
|
||||
try {
|
||||
await mailjetApiRequest.call(this, 'GET', endpoint);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
return false;
|
||||
},
|
||||
async create(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
|
||||
Reference in New Issue
Block a user