Skip to content

Commit

Permalink
[BUG] Postmark - New Inbound Email Received #11950
Browse files Browse the repository at this point in the history
Sources
 - New Inbound Email Received
  • Loading branch information
luancazarine committed May 15, 2024
1 parent 9a188c6 commit 7674892
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 8 deletions.
42 changes: 37 additions & 5 deletions components/postmark/postmark.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,28 @@ export default {
});
},
},
serverId: {
type: "string",
label: "Server Id",
description: "The identifier of the server.",
async options({ page }) {
const { Servers = [] } = await this.listServers({
params: {
count: LIMIT,
offset: LIMIT * page,
},
});

return Servers.map(({
Name: label, ID: value,
}) => {
return {
label,
value,
};
});
},
},
signatureId: {
type: "string",
label: "Signature Id",
Expand Down Expand Up @@ -155,11 +177,14 @@ export default {
...opts,
});
},
async setServerInfo(data) {
return this.sharedRequest(this, {
endpoint: "server",
method: "put",
data,
setServerInfo({
serverId, ...opts
}) {
return this._makeRequest({
method: "PUT",
tokenType: "account",
path: `servers/${serverId}`,
...opts,
});
},
createDataRemoval(opts = {}) {
Expand Down Expand Up @@ -305,6 +330,13 @@ export default {
...opts,
});
},
listServers(opts = {}) {
return this._makeRequest({
tokenType: "account",
path: "servers",
...opts,
});
},
resendConfirmation({
signatureId, ...opts
}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ export default {
...common,
key: "postmark-new-inbound-email-received",
name: "New Inbound Email Received",
description:
"Emit new event when an email is received by the Postmark server [(See docs here)](https://postmarkapp.com/developer/webhooks/inbound-webhook)",
version: "0.0.3",
description: "Emit new event when an email is received by the Postmark server. This source updates the server's inbound URL. You cannot create multiple inbound sources for the same server. [See the documentation](https://postmarkapp.com/developer/webhooks/inbound-webhook#set-the-webhook-url)",
version: "1.0.0",
type: "source",
props: {
...common.props,
serverId: {
propDefinition: [
common.props.postmark,
"serverId",
],
},
},
methods: {
...common.methods,
getWebhookProps() {
Expand All @@ -19,4 +27,17 @@ export default {
return `New email received! MessageID - ${body.MessageID}`;
},
},
hooks: {
async activate() {
await this.postmark.setServerInfo({
serverId: this.serverId,
data: {
InboundHookUrl: this.http.endpoint,
},
});
},
async deactivate() {
return true;
},
},
};

0 comments on commit 7674892

Please sign in to comment.