Skip to content

Commit a4f63bd

Browse files
committed
parse expand prop
1 parent 08d1824 commit a4f63bd

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import microsoftOutlook from "../../microsoft_outlook.app.mjs";
2+
import { parseObject } from "../../common/utils.mjs";
23

34
export default {
45
type: "action",
@@ -63,7 +64,7 @@ export default {
6364
$,
6465
data: {
6566
...await this.microsoftOutlook.prepareMessageBody(this),
66-
...this.expand,
67+
...parseObject(this.expand),
6768
},
6869
});
6970
$.export("$summary", "Email draft has been created.");

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import microsoftOutlook from "../../microsoft_outlook.app.mjs";
2+
import { parseObject } from "../../common/utils.mjs";
23

34
export default {
45
type: "action",
56
key: "microsoft_outlook-send-email",
6-
version: "0.0.15",
7+
version: "0.0.16",
78
name: "Send Email",
89
description: "Send an email to one or multiple recipients, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-sendmail)",
910
props: {
@@ -64,7 +65,7 @@ export default {
6465
data: {
6566
message: {
6667
...await this.microsoftOutlook.prepareMessageBody(this),
67-
...this.expand,
68+
...parseObject(this.expand),
6869
},
6970
},
7071
});
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
export const parseObject = (obj) => {
2+
if (!obj) {
3+
return {};
4+
}
5+
6+
if (typeof obj === "string") {
7+
try {
8+
return JSON.parse(obj);
9+
} catch {
10+
return obj;
11+
}
12+
}
13+
14+
if (Array.isArray(obj)) {
15+
return obj.map(parseObject);
16+
}
17+
18+
if (typeof obj === "object") {
19+
return Object.fromEntries(Object.entries(obj).map(([
20+
key,
21+
value,
22+
]) => [
23+
key,
24+
parseObject(value),
25+
]));
26+
}
27+
28+
return obj;
29+
};

0 commit comments

Comments
 (0)