Skip to content

Commit e84d0d4

Browse files
New Gmail action: 'Archive Email' (#16276)
* package update * Creating 'archive email' action --------- Co-authored-by: Danny Roosevelt <[email protected]>
1 parent d878510 commit e84d0d4

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
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
};

components/gmail/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/gmail",
3-
"version": "0.2.10",
3+
"version": "0.3.0",
44
"description": "Pipedream Gmail Components",
55
"main": "gmail.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)