Merge pull request #1562 from automatisch/AUT-615
feat(mailerlite): add spam complaint trigger
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import defineApp from '../../helpers/define-app.js';
|
||||
import addAuthHeader from './common/add-auth-header.js';
|
||||
import auth from './auth/index.js';
|
||||
import triggers from './triggers/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'MailerLite',
|
||||
@@ -13,4 +14,5 @@ export default defineApp({
|
||||
primaryColor: '09C269',
|
||||
beforeRequest: [addAuthHeader],
|
||||
auth,
|
||||
triggers,
|
||||
});
|
||||
|
3
packages/backend/src/apps/mailerlite/triggers/index.js
Normal file
3
packages/backend/src/apps/mailerlite/triggers/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import spamComplaint from './spam-complaint/index.js';
|
||||
|
||||
export default [spamComplaint];
|
@@ -0,0 +1,78 @@
|
||||
import Crypto from 'crypto';
|
||||
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'Spam complaint',
|
||||
key: 'spamComplaint',
|
||||
type: 'webhook',
|
||||
description: 'Triggers when a subscriber reports an email as spam.',
|
||||
|
||||
async run($) {
|
||||
const dataItem = {
|
||||
raw: $.request.body,
|
||||
meta: {
|
||||
internalId: Crypto.randomUUID(),
|
||||
},
|
||||
};
|
||||
|
||||
$.pushTriggerItem(dataItem);
|
||||
},
|
||||
|
||||
async testRun($) {
|
||||
const computedWebhookEvent = {
|
||||
id: Crypto.randomUUID(),
|
||||
sent: 1,
|
||||
email: 'user@automatisch.io',
|
||||
fields: {
|
||||
city: 'City',
|
||||
name: 'Name',
|
||||
phone: '',
|
||||
state: 'State',
|
||||
z_i_p: null,
|
||||
company: 'Company',
|
||||
country: 'Country',
|
||||
last_name: 'Last Name',
|
||||
},
|
||||
source: '',
|
||||
status: 'junk',
|
||||
optin_ip: null,
|
||||
forget_at: null,
|
||||
open_rate: 0,
|
||||
click_rate: 0,
|
||||
created_at: new Date().toISOString(),
|
||||
deleted_at: null,
|
||||
ip_address: null,
|
||||
updated_at: new Date().toISOString(),
|
||||
opens_count: 0,
|
||||
opted_in_at: null,
|
||||
clicks_count: 0,
|
||||
subscribed_at: new Date().toISOString(),
|
||||
unsubscribed_at: null,
|
||||
};
|
||||
|
||||
const dataItem = {
|
||||
raw: computedWebhookEvent,
|
||||
meta: {
|
||||
internalId: computedWebhookEvent.id,
|
||||
},
|
||||
};
|
||||
|
||||
$.pushTriggerItem(dataItem);
|
||||
},
|
||||
|
||||
async registerHook($) {
|
||||
const payload = {
|
||||
name: $.flow.id,
|
||||
events: ['subscriber.spam_reported'],
|
||||
url: $.webhookUrl,
|
||||
};
|
||||
|
||||
const { data } = await $.http.post('/webhooks', payload);
|
||||
|
||||
await $.flow.setRemoteWebhookId(data.data.id);
|
||||
},
|
||||
|
||||
async unregisterHook($) {
|
||||
await $.http.delete(`/webhooks/${$.flow.remoteWebhookId}`);
|
||||
},
|
||||
});
|
@@ -256,7 +256,10 @@ export default defineConfig({
|
||||
text: 'MailerLite',
|
||||
collapsible: true,
|
||||
collapsed: true,
|
||||
items: [{ text: 'Connection', link: '/apps/mailerlite/connection' }],
|
||||
items: [
|
||||
{ text: 'Triggers', link: '/apps/mailerlite/triggers' },
|
||||
{ text: 'Connection', link: '/apps/mailerlite/connection' },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Mattermost',
|
||||
|
12
packages/docs/pages/apps/mailerlite/triggers.md
Normal file
12
packages/docs/pages/apps/mailerlite/triggers.md
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
favicon: /favicons/mailerlite.svg
|
||||
items:
|
||||
- name: Spam Complaint
|
||||
desc: Triggers when a subscriber reports an email as spam.
|
||||
---
|
||||
|
||||
<script setup>
|
||||
import CustomListing from '../../components/CustomListing.vue'
|
||||
</script>
|
||||
|
||||
<CustomListing />
|
@@ -25,6 +25,7 @@ The following integrations are currently supported by Automatisch.
|
||||
- [HTTP Request](/apps/http-request/actions)
|
||||
- [HubSpot](/apps/hubspot/actions)
|
||||
- [Invoice Ninja](/apps/invoice-ninja/triggers)
|
||||
- [MailerLite](/apps/mailerlite/triggers)
|
||||
- [Mattermost](/apps/mattermost/actions)
|
||||
- [Miro](/apps/miro/actions)
|
||||
- [Notion](/apps/notion/triggers)
|
||||
|
Reference in New Issue
Block a user