@pipedream/microsoft_outlook 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/add-label-to-email/add-label-to-email.mjs +1 -1
- package/actions/approve-workflow/approve-workflow.mjs +1 -1
- package/actions/create-contact/create-contact.mjs +1 -1
- package/actions/create-draft-email/create-draft-email.mjs +1 -1
- package/actions/download-attachment/download-attachment.mjs +55 -0
- package/actions/find-contacts/find-contacts.mjs +1 -1
- package/actions/find-email/find-email.mjs +1 -1
- package/actions/list-contacts/list-contacts.mjs +1 -1
- package/actions/list-folders/list-folders.mjs +1 -1
- package/actions/list-labels/list-labels.mjs +1 -1
- package/actions/move-email-to-folder/move-email-to-folder.mjs +1 -1
- package/actions/remove-label-from-email/remove-label-from-email.mjs +1 -1
- package/actions/reply-to-email/reply-to-email.mjs +1 -1
- package/actions/send-email/send-email.mjs +1 -1
- package/actions/update-contact/update-contact.mjs +1 -1
- package/microsoft_outlook.app.mjs +39 -0
- package/package.json +1 -1
- package/sources/common/common-new-email.mjs +58 -0
- package/sources/{common.mjs → common/common.mjs} +1 -1
- package/sources/new-attachment-received/new-attachment-received.mjs +96 -0
- package/sources/new-contact/new-contact.mjs +2 -2
- package/sources/new-email/new-email.mjs +2 -52
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "microsoft_outlook-add-label-to-email",
|
|
6
6
|
name: "Add Label to Email",
|
|
7
7
|
description: "Adds a label/category to an email in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/message-update)",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.6",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
microsoftOutlook,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "microsoft_outlook-approve-workflow",
|
|
5
5
|
name: "Approve Workflow",
|
|
6
6
|
description: "Suspend the workflow until approved by email. [See the documentation](https://pipedream.com/docs/code/nodejs/rerun#flowsuspend)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.4",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
microsoftOutlook,
|
|
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
|
|
|
3
3
|
export default {
|
|
4
4
|
type: "action",
|
|
5
5
|
key: "microsoft_outlook-create-contact",
|
|
6
|
-
version: "0.0.
|
|
6
|
+
version: "0.0.13",
|
|
7
7
|
name: "Create Contact",
|
|
8
8
|
description: "Add a contact to the root Contacts folder, [See the documentation](https://docs.microsoft.com/en-us/graph/api/user-post-contacts)",
|
|
9
9
|
props: {
|
|
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
|
|
|
3
3
|
export default {
|
|
4
4
|
type: "action",
|
|
5
5
|
key: "microsoft_outlook-create-draft-email",
|
|
6
|
-
version: "0.0.
|
|
6
|
+
version: "0.0.13",
|
|
7
7
|
name: "Create Draft Email",
|
|
8
8
|
description: "Create a draft email, [See the documentation](https://docs.microsoft.com/en-us/graph/api/user-post-messages)",
|
|
9
9
|
props: {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import microsoftOutlook from "../../microsoft_outlook.app.mjs";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import mime from "mime-types";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
key: "microsoft_outlook-download-attachment",
|
|
7
|
+
name: "Download Attachment",
|
|
8
|
+
description: "Downloads an attachment to the /tmp directory. [See the documentation](https://learn.microsoft.com/en-us/graph/api/attachment-get?view=graph-rest-1.0&tabs=http)",
|
|
9
|
+
version: "0.0.1",
|
|
10
|
+
type: "action",
|
|
11
|
+
props: {
|
|
12
|
+
microsoftOutlook,
|
|
13
|
+
messageId: {
|
|
14
|
+
propDefinition: [
|
|
15
|
+
microsoftOutlook,
|
|
16
|
+
"messageId",
|
|
17
|
+
],
|
|
18
|
+
description: "The identifier of the message containing the attachment to download",
|
|
19
|
+
},
|
|
20
|
+
attachmentId: {
|
|
21
|
+
propDefinition: [
|
|
22
|
+
microsoftOutlook,
|
|
23
|
+
"attachmentId",
|
|
24
|
+
(c) => ({
|
|
25
|
+
messageId: c.messageId,
|
|
26
|
+
}),
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
filename: {
|
|
30
|
+
type: "string",
|
|
31
|
+
label: "Filename",
|
|
32
|
+
description: "The filename to save the attachment as in the /tmp directory",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
async run({ $ }) {
|
|
36
|
+
const response = await this.microsoftOutlook.getAttachment({
|
|
37
|
+
$,
|
|
38
|
+
messageId: this.messageId,
|
|
39
|
+
attachmentId: this.attachmentId,
|
|
40
|
+
responseType: "arraybuffer",
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const rawcontent = response.toString("base64");
|
|
44
|
+
const buffer = Buffer.from(rawcontent, "base64");
|
|
45
|
+
const downloadedFilepath = `/tmp/${this.filename}`;
|
|
46
|
+
fs.writeFileSync(downloadedFilepath, buffer);
|
|
47
|
+
const contentType = mime.lookup(downloadedFilepath);
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
fileName: this.filename,
|
|
51
|
+
contentType,
|
|
52
|
+
filePath: downloadedFilepath,
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
};
|
|
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
|
|
|
3
3
|
export default {
|
|
4
4
|
type: "action",
|
|
5
5
|
key: "microsoft_outlook-find-contacts",
|
|
6
|
-
version: "0.0.
|
|
6
|
+
version: "0.0.13",
|
|
7
7
|
name: "Find Contacts",
|
|
8
8
|
description: "Finds contacts with the given search string. [See the documentation](https://docs.microsoft.com/en-us/graph/api/user-list-contacts)",
|
|
9
9
|
props: {
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "microsoft_outlook-find-email",
|
|
5
5
|
name: "Find Email",
|
|
6
6
|
description: "Search for an email in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/user-list-messages)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.4",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
microsoftOutlook,
|
|
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
|
|
|
3
3
|
export default {
|
|
4
4
|
type: "action",
|
|
5
5
|
key: "microsoft_outlook-list-contacts",
|
|
6
|
-
version: "0.0.
|
|
6
|
+
version: "0.0.13",
|
|
7
7
|
name: "List Contacts",
|
|
8
8
|
description: "Get a contact collection from the default contacts folder, [See the documentation](https://docs.microsoft.com/en-us/graph/api/user-list-contacts)",
|
|
9
9
|
props: {
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "microsoft_outlook-list-folders",
|
|
5
5
|
name: "List Folders",
|
|
6
6
|
description: "Retrieves a list of all folders in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/user-list-mailfolders)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.4",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
microsoftOutlook,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "microsoft_outlook-list-labels",
|
|
5
5
|
name: "List Labels",
|
|
6
6
|
description: "Get all the labels/categories that have been defined for a user. [See the documentation](https://learn.microsoft.com/en-us/graph/api/outlookuser-list-mastercategories)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.6",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
microsoftOutlook,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "microsoft_outlook-move-email-to-folder",
|
|
5
5
|
name: "Move Email to Folder",
|
|
6
6
|
description: "Moves an email to the specified folder in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/message-move)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.4",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
microsoftOutlook,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "microsoft_outlook-remove-label-from-email",
|
|
5
5
|
name: "Remove Label from Email",
|
|
6
6
|
description: "Removes a label/category from an email in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/message-update)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.6",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
microsoftOutlook,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "microsoft_outlook-reply-to-email",
|
|
5
5
|
name: "Reply to Email",
|
|
6
6
|
description: "Reply to an email in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/message-reply)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
microsoftOutlook,
|
|
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
|
|
|
3
3
|
export default {
|
|
4
4
|
type: "action",
|
|
5
5
|
key: "microsoft_outlook-send-email",
|
|
6
|
-
version: "0.0.
|
|
6
|
+
version: "0.0.14",
|
|
7
7
|
name: "Send Email",
|
|
8
8
|
description: "Send an email to one or multiple recipients, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-sendmail)",
|
|
9
9
|
props: {
|
|
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
|
|
|
3
3
|
export default {
|
|
4
4
|
type: "action",
|
|
5
5
|
key: "microsoft_outlook-update-contact",
|
|
6
|
-
version: "0.0.
|
|
6
|
+
version: "0.0.13",
|
|
7
7
|
name: "Update Contact",
|
|
8
8
|
description: "Add a contact to the root Contacts folder, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-post-contacts)",
|
|
9
9
|
props: {
|
|
@@ -170,6 +170,29 @@ export default {
|
|
|
170
170
|
})) || [];
|
|
171
171
|
},
|
|
172
172
|
},
|
|
173
|
+
attachmentId: {
|
|
174
|
+
type: "string",
|
|
175
|
+
label: "Attachment ID",
|
|
176
|
+
description: "The identifier of the attachment to download",
|
|
177
|
+
async options({
|
|
178
|
+
messageId, page,
|
|
179
|
+
}) {
|
|
180
|
+
const limit = DEFAULT_LIMIT;
|
|
181
|
+
const { value: attachments } = await this.listAttachments({
|
|
182
|
+
messageId,
|
|
183
|
+
params: {
|
|
184
|
+
$top: limit,
|
|
185
|
+
$skip: limit * page,
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
return attachments?.map(({
|
|
189
|
+
id: value, name: label,
|
|
190
|
+
}) => ({
|
|
191
|
+
value,
|
|
192
|
+
label,
|
|
193
|
+
})) || [];
|
|
194
|
+
},
|
|
195
|
+
},
|
|
173
196
|
maxResults: {
|
|
174
197
|
type: "integer",
|
|
175
198
|
label: "Max Results",
|
|
@@ -403,6 +426,22 @@ export default {
|
|
|
403
426
|
...args,
|
|
404
427
|
});
|
|
405
428
|
},
|
|
429
|
+
getAttachment({
|
|
430
|
+
messageId, attachmentId, ...args
|
|
431
|
+
}) {
|
|
432
|
+
return this._makeRequest({
|
|
433
|
+
path: `/me/messages/${messageId}/attachments/${attachmentId}/$value`,
|
|
434
|
+
...args,
|
|
435
|
+
});
|
|
436
|
+
},
|
|
437
|
+
listAttachments({
|
|
438
|
+
messageId, ...args
|
|
439
|
+
}) {
|
|
440
|
+
return this._makeRequest({
|
|
441
|
+
path: `/me/messages/${messageId}/attachments`,
|
|
442
|
+
...args,
|
|
443
|
+
});
|
|
444
|
+
},
|
|
406
445
|
async *paginate({
|
|
407
446
|
fn, args = {}, max,
|
|
408
447
|
}) {
|
package/package.json
CHANGED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import common from "./common.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...common,
|
|
5
|
+
props: {
|
|
6
|
+
...common.props,
|
|
7
|
+
folderIds: {
|
|
8
|
+
propDefinition: [
|
|
9
|
+
common.props.microsoftOutlook,
|
|
10
|
+
"folderIds",
|
|
11
|
+
],
|
|
12
|
+
optional: true,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
hooks: {
|
|
16
|
+
...common.hooks,
|
|
17
|
+
async deploy() {
|
|
18
|
+
this.db.set("sentItemFolderId", await this.getFolderIdByName("Sent Items"));
|
|
19
|
+
this.db.set("draftsFolderId", await this.getFolderIdByName("Drafts"));
|
|
20
|
+
|
|
21
|
+
const events = await this.getSampleEvents({
|
|
22
|
+
pageSize: 25,
|
|
23
|
+
});
|
|
24
|
+
if (!events || events.length == 0) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
for (const item of events) {
|
|
28
|
+
this.emitEvent(item);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
async activate() {
|
|
32
|
+
await this.activate({
|
|
33
|
+
changeType: "created",
|
|
34
|
+
resource: "/me/messages",
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
async deactivate() {
|
|
38
|
+
await this.deactivate();
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
methods: {
|
|
42
|
+
...common.methods,
|
|
43
|
+
async getFolderIdByName(name) {
|
|
44
|
+
const { value: folders } = await this.microsoftOutlook.listFolders();
|
|
45
|
+
const folder = folders.find(({ displayName }) => displayName === name);
|
|
46
|
+
return folder?.id;
|
|
47
|
+
},
|
|
48
|
+
isRelevant(item) {
|
|
49
|
+
if (this.folderIds?.length) {
|
|
50
|
+
return this.folderIds.includes(item.parentFolderId);
|
|
51
|
+
}
|
|
52
|
+
// if no folderIds are specified, filter out items in Sent Items & Drafts
|
|
53
|
+
const sentItemFolderId = this.db.get("sentItemFolderId");
|
|
54
|
+
const draftsFolderId = this.db.get("draftsFolderId");
|
|
55
|
+
return item.parentFolderId !== sentItemFolderId && item.parentFolderId !== draftsFolderId;
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import common from "../common/common-new-email.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...common,
|
|
5
|
+
key: "microsoft_outlook-new-attachment-received",
|
|
6
|
+
name: "New Attachment Received (Instant)",
|
|
7
|
+
description: "Emit new event when a new email containing one or more attachments arrives in a specified Microsoft Outlook folder.",
|
|
8
|
+
version: "0.0.1",
|
|
9
|
+
type: "source",
|
|
10
|
+
dedupe: "unique",
|
|
11
|
+
methods: {
|
|
12
|
+
...common.methods,
|
|
13
|
+
async getSampleEvents({ pageSize }) {
|
|
14
|
+
const folders = this.folderIds?.length
|
|
15
|
+
? this.folderIds.map((id) => `/me/mailFolders/${id}/messages`)
|
|
16
|
+
: [
|
|
17
|
+
"/me/messages",
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
const messagesWithAttachments = [];
|
|
21
|
+
for (const folder of folders) {
|
|
22
|
+
const { value: messages } = await this.microsoftOutlook.listMessages({
|
|
23
|
+
resource: folder,
|
|
24
|
+
params: {
|
|
25
|
+
$top: pageSize,
|
|
26
|
+
$filter: "hasAttachments eq true",
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
messagesWithAttachments.push(...messages);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const attachments = [];
|
|
33
|
+
for (const message of messagesWithAttachments) {
|
|
34
|
+
const messageAttachments = await this.getMessageAttachments(message);
|
|
35
|
+
attachments.push(...messageAttachments);
|
|
36
|
+
}
|
|
37
|
+
return attachments;
|
|
38
|
+
},
|
|
39
|
+
async getMessageAttachments(message) {
|
|
40
|
+
const { value: attachments } = await this.microsoftOutlook.listAttachments({
|
|
41
|
+
messageId: message.id,
|
|
42
|
+
});
|
|
43
|
+
if (!attachments?.length) {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
return attachments.map((attachment) => ({
|
|
47
|
+
...attachment,
|
|
48
|
+
messageId: message.id,
|
|
49
|
+
messageSubject: message.subject,
|
|
50
|
+
messageSender: message.sender,
|
|
51
|
+
messageReceivedDateTime: message.receivedDateTime,
|
|
52
|
+
parentFolderId: message.parentFolderId,
|
|
53
|
+
contentBytes: undefined,
|
|
54
|
+
}));
|
|
55
|
+
},
|
|
56
|
+
emitEvent(item) {
|
|
57
|
+
if (this.isRelevant(item)) {
|
|
58
|
+
this.$emit(item, this.generateMeta(item));
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
generateMeta(item) {
|
|
62
|
+
return {
|
|
63
|
+
id: item.contentId,
|
|
64
|
+
summary: `New attachment ${item.name}`,
|
|
65
|
+
ts: Date.parse(item.messageReceivedDateTime),
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
async run(event) {
|
|
70
|
+
const folders = this.folderIds?.length
|
|
71
|
+
? this.folderIds.map((id) => `/me/mailFolders/${id}/messages`)
|
|
72
|
+
: [
|
|
73
|
+
"/me/messages",
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
for (const folder of folders) {
|
|
77
|
+
await this.run({
|
|
78
|
+
event,
|
|
79
|
+
emitFn: async ({ resourceId } = {}) => {
|
|
80
|
+
try {
|
|
81
|
+
const message = await this.microsoftOutlook.getMessage({
|
|
82
|
+
resource: folder,
|
|
83
|
+
messageId: resourceId,
|
|
84
|
+
});
|
|
85
|
+
if (message.hasAttachments) {
|
|
86
|
+
const attachments = await this.getMessageAttachments(message);
|
|
87
|
+
attachments.forEach((item) => this.emitEvent(item));
|
|
88
|
+
}
|
|
89
|
+
} catch {
|
|
90
|
+
console.log(`Could not fetch message with ID: ${resourceId}`);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import common from "../common.mjs";
|
|
1
|
+
import common from "../common/common.mjs";
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
...common,
|
|
5
5
|
key: "microsoft_outlook-new-contact",
|
|
6
6
|
name: "New Contact Event (Instant)",
|
|
7
7
|
description: "Emit new event when a new Contact is created",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.14",
|
|
9
9
|
type: "source",
|
|
10
10
|
hooks: {
|
|
11
11
|
...common.hooks,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import common from "../common.mjs";
|
|
1
|
+
import common from "../common/common-new-email.mjs";
|
|
2
2
|
import md5 from "md5";
|
|
3
3
|
import sampleEmit from "./test-event.mjs";
|
|
4
4
|
|
|
@@ -7,52 +7,11 @@ export default {
|
|
|
7
7
|
key: "microsoft_outlook-new-email",
|
|
8
8
|
name: "New Email Event (Instant)",
|
|
9
9
|
description: "Emit new event when an email is received in specified folders.",
|
|
10
|
-
version: "0.0.
|
|
10
|
+
version: "0.0.17",
|
|
11
11
|
type: "source",
|
|
12
12
|
dedupe: "unique",
|
|
13
|
-
props: {
|
|
14
|
-
...common.props,
|
|
15
|
-
folderIds: {
|
|
16
|
-
propDefinition: [
|
|
17
|
-
common.props.microsoftOutlook,
|
|
18
|
-
"folderIds",
|
|
19
|
-
],
|
|
20
|
-
optional: true,
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
hooks: {
|
|
24
|
-
...common.hooks,
|
|
25
|
-
async deploy() {
|
|
26
|
-
this.db.set("sentItemFolderId", await this.getFolderIdByName("Sent Items"));
|
|
27
|
-
this.db.set("draftsFolderId", await this.getFolderIdByName("Drafts"));
|
|
28
|
-
|
|
29
|
-
const events = await this.getSampleEvents({
|
|
30
|
-
pageSize: 25,
|
|
31
|
-
});
|
|
32
|
-
if (!events || events.length == 0) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
for (const item of events) {
|
|
36
|
-
this.emitEvent(item);
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
async activate() {
|
|
40
|
-
await this.activate({
|
|
41
|
-
changeType: "created",
|
|
42
|
-
resource: "/me/messages",
|
|
43
|
-
});
|
|
44
|
-
},
|
|
45
|
-
async deactivate() {
|
|
46
|
-
await this.deactivate();
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
13
|
methods: {
|
|
50
14
|
...common.methods,
|
|
51
|
-
async getFolderIdByName(name) {
|
|
52
|
-
const { value: folders } = await this.microsoftOutlook.listFolders();
|
|
53
|
-
const folder = folders.find(({ displayName }) => displayName === name);
|
|
54
|
-
return folder?.id;
|
|
55
|
-
},
|
|
56
15
|
async getSampleEvents({ pageSize }) {
|
|
57
16
|
const folders = this.folderIds?.length
|
|
58
17
|
? this.folderIds.map((id) => `/me/mailFolders/${id}/messages`)
|
|
@@ -73,15 +32,6 @@ export default {
|
|
|
73
32
|
}
|
|
74
33
|
return results;
|
|
75
34
|
},
|
|
76
|
-
isRelevant(item) {
|
|
77
|
-
if (this.folderIds?.length) {
|
|
78
|
-
return this.folderIds.includes(item.parentFolderId);
|
|
79
|
-
}
|
|
80
|
-
// if no folderIds are specified, filter out items in Sent Items & Drafts
|
|
81
|
-
const sentItemFolderId = this.db.get("sentItemFolderId");
|
|
82
|
-
const draftsFolderId = this.db.get("draftsFolderId");
|
|
83
|
-
return item.parentFolderId !== sentItemFolderId && item.parentFolderId !== draftsFolderId;
|
|
84
|
-
},
|
|
85
35
|
emitEvent(item) {
|
|
86
36
|
if (this.isRelevant(item)) {
|
|
87
37
|
this.$emit(
|