Skip to content

Commit b55b626

Browse files
committed
updates
1 parent 1f57408 commit b55b626

File tree

4 files changed

+39
-3
lines changed

4 files changed

+39
-3
lines changed

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ 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.8",
9+
version: "0.1.9",
1010
type: "action",
1111
props: {
1212
gmail,
@@ -84,6 +84,7 @@ export default {
8484
label: "In Reply To",
8585
description: "Specify the `message-id` this email is replying to.",
8686
optional: true,
87+
reloadProps: true,
8788
},
8889
mimeType: {
8990
propDefinition: [
@@ -92,6 +93,22 @@ export default {
9293
],
9394
},
9495
},
96+
additionalProps(existingProps) {
97+
const props = {};
98+
if (this.inReplyTo) {
99+
props.replyAll = {
100+
type: "boolean",
101+
label: "Reply All",
102+
description: "Set to `true` to send reply to emails in the \"From\", \"To\", \"CC\", and \"BCC\" (if available) of the original email",
103+
optional: true,
104+
reloadProps: true,
105+
};
106+
}
107+
existingProps.to.hidden = !!this.replyAll;
108+
existingProps.cc.hidden = !!this.replyAll;
109+
existingProps.bcc.hidden = !!this.replyAll;
110+
return props;
111+
},
95112
async run({ $ }) {
96113
this.attachmentFilenames = utils.parseArray(this.attachmentFilenames);
97114
this.attachmentUrlsOrPaths = utils.parseArray(this.attachmentUrlsOrPaths);
@@ -100,7 +117,7 @@ export default {
100117
}
101118
const opts = await this.gmail.getOptionsToSendEmail($, this);
102119
const response = await this.gmail.sendEmail(opts);
103-
$.export("$summary", `Successfully sent email to ${this.to}`);
120+
$.export("$summary", `Successfully sent email to ${opts.to}`);
104121
return response;
105122
},
106123
};

components/gmail/gmail.app.mjs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,23 @@ export default {
303303
opts.inReplyTo = inReplyTo;
304304
opts.references = inReplyTo;
305305
opts.threadId = repliedMessage.threadId;
306+
if (props.replyAll) {
307+
const from = repliedMessage.payload.headers.find(({ name }) => name.toLowerCase() === "from");
308+
const to = repliedMessage.payload.headers.find(({ name }) => name.toLowerCase() === "to");
309+
const cc = repliedMessage.payload.headers.find(({ name }) => name.toLowerCase() === "cc");
310+
const bcc = repliedMessage.payload.headers.find(({ name }) => name.toLowerCase() === "bcc");
311+
opts.to = from.value.split(",");
312+
opts.to.push(...to.value.split(","));
313+
opts.to = [
314+
...new Set(opts.to),
315+
];
316+
if (cc) {
317+
opts.cc = cc.value;
318+
}
319+
if (bcc) {
320+
opts.bcc = bcc.value;
321+
}
322+
}
306323
} catch (err) {
307324
opts.threadId = props.inReplyTo;
308325
}

components/gmail/sources/common/base.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ export default {
7575
"subject": this.getHeaderValue(headers, "subject"),
7676
"from": this.parseEmail(this.getHeaderValue(headers, "from")),
7777
"to": this.parseEmail(this.getHeaderValue(headers, "to")),
78+
"cc": this.parseEmail(this.getHeaderValue(headers, "cc")),
79+
"bcc": this.parseEmail(this.getHeaderValue(headers, "bcc")),
7880
"reply-to": this.parseEmail(this.getHeaderValue(headers, "reply-to")),
7981
"date": this.getHeaderValue(headers, "date"),
8082
"snippet": msg.snippet,

components/gmail/sources/new-email-received/new-email-received.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default {
1515
name: "New Email Received",
1616
description: "Emit new event when a new email is received.",
1717
type: "source",
18-
version: "0.2.3",
18+
version: "0.2.4",
1919
dedupe: "unique",
2020
props: {
2121
gmail,

0 commit comments

Comments
 (0)