Skip to content

Commit 01e2722

Browse files
authored
17235 source gmail sources return too much text (#17236)
* Update Gmail component versions and add plaintext payload option to sources - Bump package versions for @pipedream/gmail to 1.0.2, actions to their respective new versions, and sources to 0.1.0 or 0.3.0. - Introduce 'withTextPayload' option in new email sources to return payload as plaintext, enhancing usability for LLMs. - Refactor message handling in sources and actions to support the new payload format. * pnpm update * Refactor text payload validation in Gmail utils - Simplify the logic for validating and extracting text payloads from messages. - Ensure that the new payload is assigned correctly based on the presence of body data or parts. * pnpm update * Bump Gmail component version to 1.1.1 * pnpm update * pnpm update
1 parent 2db2518 commit 01e2722

File tree

30 files changed

+111
-71
lines changed

30 files changed

+111
-71
lines changed

components/aspsms/aspsms.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/chattermill/chattermill.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/gmail/actions/add-label-to-email/add-label-to-email.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "gmail-add-label-to-email",
55
name: "Add Label to Email",
66
description: "Add label(s) to an email message. [See the docs](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/modify)",
7-
version: "0.0.11",
7+
version: "0.0.12",
88
type: "action",
99
props: {
1010
gmail,

components/gmail/actions/approve-workflow/approve-workflow.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "gmail-approve-workflow",
55
name: "Approve Workflow",
66
description: "Suspend the workflow until approved by email. [See the documentation](https://pipedream.com/docs/code/nodejs/rerun#flowsuspend)",
7-
version: "0.0.8",
7+
version: "0.0.9",
88
type: "action",
99
props: {
1010
gmail,

components/gmail/actions/archive-email/archive-email.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "gmail-archive-email",
66
name: "Archive Email",
77
description: "Archive an email message. [See the documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/modify)",
8-
version: "0.0.6",
8+
version: "0.0.7",
99
type: "action",
1010
props: {
1111
gmail,

components/gmail/actions/create-draft/create-draft.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "gmail-create-draft",
77
name: "Create Draft",
88
description: "Create a draft from your Google Workspace email account. [See the documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.drafts/create)",
9-
version: "0.1.6",
9+
version: "0.1.7",
1010
type: "action",
1111
props: {
1212
gmail,

components/gmail/actions/download-attachment/download-attachment.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "gmail-download-attachment",
88
name: "Download Attachment",
99
description: "Download an attachment by attachmentId to the /tmp directory. [See the documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.messages.attachments/get)",
10-
version: "0.0.10",
10+
version: "0.0.11",
1111
type: "action",
1212
props: {
1313
gmail,

components/gmail/actions/find-email/find-email.mjs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import { convert } from "html-to-text";
2-
import gmail from "../../gmail.app.mjs";
31
import utils from "../../common/utils.mjs";
2+
import gmail from "../../gmail.app.mjs";
43

54
export default {
65
key: "gmail-find-email",
76
name: "Find Email",
87
description: "Find an email using Google's Search Engine. [See the docs](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/list)",
9-
version: "0.1.4",
8+
version: "0.1.5",
109
type: "action",
1110
props: {
1211
gmail,
@@ -56,11 +55,9 @@ export default {
5655
});
5756
const messageIds = messages.map(({ id }) => id);
5857
const messagesToEmit = [];
59-
for await (const message of this.gmail.getAllMessages(messageIds)) {
58+
for await (let message of this.gmail.getAllMessages(messageIds)) {
6059
messagesToEmit.push(message);
6160

62-
let newPayload = "";
63-
6461
const messageIdHeader = message.payload?.headers?.find(
6562
(h) => h.name.toLowerCase() === "message-id",
6663
);
@@ -93,17 +90,9 @@ export default {
9390
message.subject = subjectHeader.value;
9491
}
9592

96-
if (this.withTextPayload) {
97-
if (message.payload?.body?.data && !Array.isArray(message.payload.parts)) {
98-
const decodedBody = utils.decodeBase64Url(message.payload.body.data);
99-
newPayload += convert(decodedBody);
100-
}
101-
102-
if (Array.isArray(message.payload?.parts)) {
103-
newPayload += utils.extractTextFromParts(message.payload.parts);
104-
}
105-
106-
message.payload = newPayload;
93+
const parsedMessage = utils.validateTextPayload(message, this.withTextPayload);
94+
if (parsedMessage) {
95+
message = parsedMessage;
10796
} else {
10897
if (message.payload?.body?.data && !Array.isArray(message.payload.parts)) {
10998
message.payload.body.text = utils.decodeBase64Url(message.payload.body.data);

components/gmail/actions/list-labels/list-labels.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "gmail-list-labels",
55
name: "List Labels",
66
description: "List all the existing labels in the connected account. [See the docs](https://developers.google.com/gmail/api/reference/rest/v1/users.labels/list)",
7-
version: "0.0.7",
7+
version: "0.0.8",
88
type: "action",
99
props: {
1010
gmail,

components/gmail/actions/remove-label-from-email/remove-label-from-email.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "gmail-remove-label-from-email",
55
name: "Remove Label from Email",
66
description: "Remove label(s) from an email message. [See the docs](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/modify)",
7-
version: "0.0.9",
7+
version: "0.0.10",
88
type: "action",
99
props: {
1010
gmail,

0 commit comments

Comments
 (0)