Skip to content

Commit cdff516

Browse files
committed
microsoft_outlook components
1 parent b51211a commit cdff516

File tree

13 files changed

+173
-9
lines changed

13 files changed

+173
-9
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import microsoftOutlook from "../../microsoft_outlook.app.mjs";
2+
3+
export default {
4+
key: "microsoft_outlook-add-label-to-email",
5+
name: "Add Label to Email",
6+
description: "Adds a label/category to an email in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/message-update)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
microsoftOutlook,
11+
messageId: {
12+
propDefinition: [
13+
microsoftOutlook,
14+
"messageId",
15+
],
16+
},
17+
labelId: {
18+
propDefinition: [
19+
microsoftOutlook,
20+
"labelId",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const message = await this.microsoftOutlook.getMessage({
26+
$,
27+
messageId: this.messageId,
28+
});
29+
30+
const labels = message?.categories;
31+
32+
const response = await this.microsoftOutlook.updateMessage({
33+
$,
34+
messageId: this.messageId,
35+
data: {
36+
categories: [
37+
...labels,
38+
this.labelId,
39+
],
40+
},
41+
});
42+
$.export("$summary", "Successfully added label to message.");
43+
return response;
44+
},
45+
};

components/microsoft_outlook/actions/create-contact/create-contact.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
33
export default {
44
type: "action",
55
key: "microsoft_outlook-create-contact",
6-
version: "0.0.7",
6+
version: "0.0.8",
77
name: "Create Contact",
88
description: "Add a contact to the root Contacts folder, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-post-contacts)",
99
props: {

components/microsoft_outlook/actions/create-draft-email/create-draft-email.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
33
export default {
44
type: "action",
55
key: "microsoft_outlook-create-draft-email",
6-
version: "0.0.7",
6+
version: "0.0.8",
77
name: "Create Draft Email",
88
description: "Create a draft email, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-post-messages)",
99
props: {

components/microsoft_outlook/actions/find-contacts/find-contacts.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
33
export default {
44
type: "action",
55
key: "microsoft_outlook-find-contacts",
6-
version: "0.0.7",
6+
version: "0.0.8",
77
name: "Find Contacts",
88
description: "Finds contacts with given search string",
99
props: {

components/microsoft_outlook/actions/list-contacts/list-contacts.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
33
export default {
44
type: "action",
55
key: "microsoft_outlook-list-contacts",
6-
version: "0.0.7",
6+
version: "0.0.8",
77
name: "List Contacts",
88
description: "Get a contact collection from the default contacts folder, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-list-contacts)",
99
props: {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import microsoftOutlook from "../../microsoft_outlook.app.mjs";
2+
3+
export default {
4+
key: "microsoft_outlook-list-labels",
5+
name: "List Labels",
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.1",
8+
type: "action",
9+
props: {
10+
microsoftOutlook,
11+
},
12+
async run({ $ }) {
13+
const { value } = await this.microsoftOutlook.listLabels({
14+
$,
15+
});
16+
$.export("$summary", `Successfully retrieved ${value.length} label${value.length != 1
17+
? "s"
18+
: ""}.`);
19+
return value;
20+
},
21+
};
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import microsoftOutlook from "../../microsoft_outlook.app.mjs";
2+
3+
export default {
4+
key: "microsoft_outlook-remove-label-from-email",
5+
name: "Remove Label from Email",
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.1",
8+
type: "action",
9+
props: {
10+
microsoftOutlook,
11+
messageId: {
12+
propDefinition: [
13+
microsoftOutlook,
14+
"messageId",
15+
],
16+
},
17+
labelId: {
18+
propDefinition: [
19+
microsoftOutlook,
20+
"labelId",
21+
],
22+
description: "The identifier of the label/category to remove",
23+
},
24+
},
25+
async run({ $ }) {
26+
const message = await this.microsoftOutlook.getMessage({
27+
$,
28+
messageId: this.messageId,
29+
});
30+
let labels = message?.categories; console.log(labels);
31+
32+
const index = labels.indexOf(this.labelId); console.log(index);
33+
if (index > -1) {
34+
labels.splice(index, 1); console.log(labels);
35+
}
36+
37+
const response = await this.microsoftOutlook.updateMessage({
38+
$,
39+
messageId: this.messageId,
40+
data: {
41+
categories: labels,
42+
},
43+
});
44+
$.export("$summary", "Successfully removed label from message.");
45+
return response;
46+
},
47+
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
33
export default {
44
type: "action",
55
key: "microsoft_outlook-send-email",
6-
version: "0.0.8",
6+
version: "0.0.9",
77
name: "Send Email",
88
description: "Send an email to one or multiple recipients, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-sendmail)",
99
props: {

components/microsoft_outlook/actions/update-contact/update-contact.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
33
export default {
44
type: "action",
55
key: "microsoft_outlook-update-contact",
6-
version: "0.0.7",
6+
version: "0.0.8",
77
name: "Update Contact",
88
description: "Add a contact to the root Contacts folder, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-post-contacts)",
99
props: {

components/microsoft_outlook/microsoft_outlook.app.mjs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,41 @@ export default {
100100
type: "object",
101101
optional: true,
102102
},
103+
labelId: {
104+
type: "string",
105+
label: "Label ID",
106+
description: "The identifier of the label/category to add",
107+
async options() {
108+
const { value: labels } = await this.listLabels();
109+
return labels?.map(({
110+
id: value, displayName: label,
111+
}) => ({
112+
value,
113+
label,
114+
})) || [];
115+
},
116+
},
117+
messageId: {
118+
type: "string",
119+
label: "Message ID",
120+
description: "The identifier of the message to update",
121+
async options({ page }) {
122+
const limit = 50;
123+
const { value } = await this.listMessages({
124+
params: {
125+
$top: limit,
126+
$skip: limit * page,
127+
$orderby: "createdDateTime desc",
128+
},
129+
});
130+
return value?.map(({
131+
id: value, subject: label,
132+
}) => ({
133+
value,
134+
label,
135+
})) || [];
136+
},
137+
},
103138
},
104139
methods: {
105140
_getUrl(path) {
@@ -286,5 +321,20 @@ export default {
286321
...args,
287322
});
288323
},
324+
listLabels(args = {}) {
325+
return this._makeRequest({
326+
path: "/me/outlook/masterCategories",
327+
...args,
328+
});
329+
},
330+
updateMessage({
331+
messageId, ...args
332+
}) {
333+
return this._makeRequest({
334+
method: "PATCH",
335+
path: `/me/messages/${messageId}`,
336+
...args,
337+
});
338+
},
289339
},
290340
};

0 commit comments

Comments
 (0)