Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/gmail/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/gmail",
"version": "0.1.6",
"version": "0.1.7",
"description": "Pipedream Gmail Components",
"main": "gmail.app.mjs",
"keywords": [
Expand Down
32 changes: 27 additions & 5 deletions components/gmail/sources/common/base.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,39 @@ export default {
decodedContent: Buffer.from(firstPart.body.data, "base64").toString(),
};
},
parseEmail(emailStr) {
if (!emailStr) {
return undefined;
}

const regex = /^(.*)<(.+)>$/;
const match = emailStr.match(regex);

if (match) {
return {
name: match[1].trim(),
email: match[2].trim(),
};
}
return {
name: null,
email: emailStr.trim(),
};
},
getHeaderValue(headers, key) {
return headers.find(({ name }) => name.toLowerCase() === key)?.value;
},
processEmail(msg) {
// Process and structure the email data
const headers = msg.payload.headers;
return {
"id": msg.id,
"threadId": msg.threadId,
"subject": headers.find((h) => h.name.toLowerCase() === "subject")?.value,
"from": headers.find((h) => h.name.toLowerCase() === "from")?.value,
"to": headers.find((h) => h.name.toLowerCase() === "to")?.value,
"reply-to": headers.find((h) => h.name.toLowerCase() === "reply-to")?.value,
"date": headers.find((h) => h.name.toLowerCase() === "date")?.value,
"subject": this.getHeaderValue(headers, "subject"),
"from": this.parseEmail(this.getHeaderValue(headers, "from")),
"to": this.parseEmail(this.getHeaderValue(headers, "to")),
"reply-to": this.parseEmail(this.getHeaderValue(headers, "reply-to")),
"date": this.getHeaderValue(headers, "date"),
"snippet": msg.snippet,
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "gmail-new-attachment-received",
name: "New Attachment Received",
description: "Emit new event for each attachment in a message received. This source is capped at 100 max new messages per run.",
version: "0.0.4",
version: "0.0.5",
type: "source",
dedupe: "unique",
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "gmail-new-email-matching-search",
name: "New Email Matching Search",
description: "Emit new event when an email matching the search criteria is received. This source is capped at 100 max new messages per run.",
version: "0.0.3",
version: "0.0.4",
type: "source",
dedupe: "unique",
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default {
name: "New Email Received",
description: "Emit new event when a new email is received.",
type: "source",
version: "0.1.3",
version: "0.1.4",
dedupe: "unique",
props: {
gmail,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
name: "New Labeled Email",
description: "Emit new event when a new email is labeled.",
type: "source",
version: "0.0.4",
version: "0.0.5",
dedupe: "unique",
props: {
...common.props,
Expand Down
2 changes: 1 addition & 1 deletion components/gmail/sources/new-sent-email/new-sent-email.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "gmail-new-sent-email",
name: "New Sent Email",
description: "Emit new event for each new email sent. (Maximum of 100 events emited per execution)",
version: "0.0.4",
version: "0.0.5",
type: "source",
dedupe: "unique",
props: {
Expand Down
Loading