Skip to content

Commit 72ffb85

Browse files
[ACTION] Gmail Find Email actions return too much text #16824 (#16830)
* adds payload validation * some adjusts * pnpm update * Apply suggestions from code review --------- Co-authored-by: Danny Roosevelt <[email protected]>
1 parent d6b3b4b commit 72ffb85

File tree

18 files changed

+46
-32
lines changed

18 files changed

+46
-32
lines changed

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.8",
7+
version: "0.0.9",
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.4",
7+
version: "0.0.5",
88
type: "action",
99
props: {
1010
gmail,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import gmail from "../../gmail.app.mjs";
21
import constants from "../../common/constants.mjs";
2+
import gmail from "../../gmail.app.mjs";
33

44
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.2",
8+
version: "0.0.3",
99
type: "action",
1010
props: {
1111
gmail,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import gmail from "../../gmail.app.mjs";
21
import { ConfigurationError } from "@pipedream/platform";
32
import utils from "../../common/utils.mjs";
3+
import gmail from "../../gmail.app.mjs";
44

55
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.1",
9+
version: "0.1.2",
1010
type: "action",
1111
props: {
1212
gmail,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import gmail from "../../gmail.app.mjs";
1+
import { ConfigurationError } from "@pipedream/platform";
22
import fs from "fs";
33
import path from "path";
4-
import { ConfigurationError } from "@pipedream/platform";
4+
import gmail from "../../gmail.app.mjs";
55

66
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.6",
10+
version: "0.0.7",
1111
type: "action",
1212
props: {
1313
gmail,

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import { convert } from "html-to-text";
12
import gmail from "../../gmail.app.mjs";
23

34
export default {
45
key: "gmail-find-email",
56
name: "Find Email",
67
description: "Find an email using Google's Search Engine. [See the docs](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/list)",
7-
version: "0.0.11",
8+
version: "0.1.0",
89
type: "action",
910
props: {
1011
gmail,
@@ -14,6 +15,12 @@ export default {
1415
"q",
1516
],
1617
},
18+
withTextPayload: {
19+
type: "boolean",
20+
label: "Return payload as plaintext",
21+
description: "Convert the payload response into a single text field. **This reduces the size of the payload and makes it easier for LLMs work with.**",
22+
default: false,
23+
},
1724
labels: {
1825
propDefinition: [
1926
gmail,
@@ -47,14 +54,21 @@ export default {
4754
maxResults: this.maxResults,
4855
});
4956
const messageIds = messages.map(({ id }) => id);
50-
const messagesToEmit = await this.gmail.getMessages(messageIds);
57+
let messagesToEmit = await this.gmail.getMessages(messageIds);
5158

5259
for await (const message of messagesToEmit) {
60+
let newPayload = "";
5361
for (const part of message.payload?.parts || []) {
5462
if (part.body.data) {
55-
part.body.text = Buffer.from(part.body.data, "base64").toString("utf-8");
63+
const payload = Buffer.from(part.body.data, "base64").toString("utf-8");
64+
this.withTextPayload
65+
? newPayload += convert(payload)
66+
: part.body.text = payload;
5667
}
5768
}
69+
if (this.withTextPayload) {
70+
message.payload = newPayload;
71+
}
5872
}
5973

6074
const suffix = messagesToEmit.length === 1

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.3",
7+
version: "0.0.4",
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.5",
7+
version: "0.0.6",
88
type: "action",
99
props: {
1010
gmail,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import gmail from "../../gmail.app.mjs";
21
import { ConfigurationError } from "@pipedream/platform";
32
import utils from "../../common/utils.mjs";
3+
import gmail from "../../gmail.app.mjs";
44

55
export default {
66
key: "gmail-send-email",
77
name: "Send Email",
88
description: "Send an email from your Google Workspace email account. [See the documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/send)",
9-
version: "0.1.9",
9+
version: "0.1.10",
1010
type: "action",
1111
props: {
1212
gmail,

components/gmail/actions/update-org-signature/update-org-signature.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import googleCloud from "../../../google_cloud/google_cloud.app.mjs";
2-
import base from "../update-primary-signature/update-primary-signature.mjs";
32
import gmail from "../../gmail.app.mjs";
3+
import base from "../update-primary-signature/update-primary-signature.mjs";
44

55
export default {
66
...base,
77
key: "gmail-update-org-signature",
88
name: "Update Signature for Email in Organization",
99
description: `Update the signature for a specific email address in an organization.
1010
A Google Cloud service account with delegated domain-wide authority is required for this action. [See the documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.settings.sendAs/update)`,
11-
version: "0.0.6",
11+
version: "0.0.7",
1212
type: "action",
1313
props: {
1414
gmail,

0 commit comments

Comments
 (0)