Skip to content

Commit 3956ec4

Browse files
committed
Creating 'archive email' action
1 parent 1d4a24b commit 3956ec4

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import gmail from "../../gmail.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "gmail-archive-email",
6+
name: "Archive Email",
7+
description: "Archive an email message. [See the documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/modify)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
gmail,
12+
message: {
13+
propDefinition: [
14+
gmail,
15+
"message",
16+
],
17+
},
18+
},
19+
async run({ $ }) {
20+
const {
21+
gmail,
22+
message,
23+
} = this;
24+
25+
const response = await gmail.updateLabels({
26+
message,
27+
removeLabelIds: [
28+
constants.INBOX_LABEL_ID,
29+
],
30+
});
31+
32+
$.export("$summary", `Successfully archived email (ID: ${message})`);
33+
return response;
34+
},
35+
};

components/gmail/common/constants.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ const BODY_TYPES = {
55
};
66
const HISTORICAL_EVENTS = 10;
77
const DEFAULT_LIMIT = 100;
8+
const INBOX_LABEL_ID = "INBOX";
89

910
export default {
1011
USER_ID,
1112
BODY_TYPES,
1213
HISTORICAL_EVENTS,
1314
DEFAULT_LIMIT,
15+
INBOX_LABEL_ID,
1416
};

0 commit comments

Comments
 (0)