@activepieces/piece-microsoft-outlook 0.2.1 → 0.2.3
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/package.json +6 -3
- package/src/i18n/translation.json +7 -1
- package/src/index.js +3 -1
- package/src/index.js.map +1 -1
- package/src/lib/actions/request-approval-send-email.d.ts +5 -0
- package/src/lib/actions/request-approval-send-email.js +106 -0
- package/src/lib/actions/request-approval-send-email.js.map +1 -0
- package/src/lib/triggers/new-attachment.d.ts +3 -0
- package/src/lib/triggers/new-attachment.js +14 -5
- package/src/lib/triggers/new-attachment.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@activepieces/piece-microsoft-outlook",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"dependencies": {
|
|
5
|
+
"@ai-sdk/mcp": "1.0.1 ",
|
|
5
6
|
"@microsoft/microsoft-graph-client": "3.0.7",
|
|
6
7
|
"@microsoft/microsoft-graph-types": "2.40.0",
|
|
8
|
+
"@modelcontextprotocol/sdk": "1.25.2",
|
|
7
9
|
"@sinclair/typebox": "0.34.11",
|
|
8
10
|
"ai": "5.0.104",
|
|
9
11
|
"axios": "1.13.1",
|
|
@@ -11,14 +13,15 @@
|
|
|
11
13
|
"dayjs": "1.11.9",
|
|
12
14
|
"deepmerge-ts": "7.1.0",
|
|
13
15
|
"form-data": "4.0.4",
|
|
16
|
+
"i18next": "23.13.0",
|
|
14
17
|
"mime-types": "2.1.35",
|
|
15
18
|
"nanoid": "3.3.8",
|
|
16
19
|
"semver": "7.6.0",
|
|
17
20
|
"socket.io-client": "4.8.1",
|
|
18
21
|
"zod": "4.1.13",
|
|
19
|
-
"@activepieces/pieces-common": "0.11.
|
|
22
|
+
"@activepieces/pieces-common": "0.11.2",
|
|
20
23
|
"@activepieces/pieces-framework": "0.23.0",
|
|
21
|
-
"@activepieces/shared": "0.
|
|
24
|
+
"@activepieces/shared": "0.32.0",
|
|
22
25
|
"tslib": "2.6.2"
|
|
23
26
|
},
|
|
24
27
|
"resolutions": {
|
|
@@ -85,5 +85,11 @@
|
|
|
85
85
|
"Triggers when a new email is received in the inbox.": "Triggers when a new email is received in the inbox.",
|
|
86
86
|
"Triggers when a new email is delivered into the specified folder.": "Triggers when a new email is delivered into the specified folder.",
|
|
87
87
|
"Triggers when a new email containing one or more attachments arrives.": "Triggers when a new email containing one or more attachments arrives.",
|
|
88
|
-
"
|
|
88
|
+
"From (Sender Email)": "From (Sender Email)",
|
|
89
|
+
"To (Recipient Email)": "To (Recipient Email)",
|
|
90
|
+
"Attachment Name Filter": "Attachment Name Filter",
|
|
91
|
+
"Filter emails from a specific sender (optional). Leave empty to for all senders.": "Filter emails from a specific sender (optional). Leave empty to for all senders.",
|
|
92
|
+
"Filter emails to a specific recipient (optional). Leave empty to for all recipients.": "Filter emails to a specific recipient (optional). Leave empty to for all recipients.",
|
|
93
|
+
"Monitor attachments in a specific folder. Leave empty to monitor all folders.": "Monitor attachments in a specific folder. Leave empty to monitor all folders.",
|
|
94
|
+
"Filter attachments by name (contains). Leave empty to include all attachments.": "Filter attachments by name (contains). Leave empty to include all attachments."
|
|
89
95
|
}
|
package/src/index.js
CHANGED
|
@@ -19,13 +19,14 @@ const auth_1 = require("./lib/common/auth");
|
|
|
19
19
|
const new_attachment_1 = require("./lib/triggers/new-attachment");
|
|
20
20
|
const new_email_in_folder_1 = require("./lib/triggers/new-email-in-folder");
|
|
21
21
|
const new_email_1 = require("./lib/triggers/new-email");
|
|
22
|
+
const request_approval_send_email_1 = require("./lib/actions/request-approval-send-email");
|
|
22
23
|
exports.microsoftOutlook = (0, pieces_framework_1.createPiece)({
|
|
23
24
|
displayName: 'Microsoft Outlook',
|
|
24
25
|
auth: auth_1.microsoftOutlookAuth,
|
|
25
26
|
minimumSupportedRelease: '0.36.1',
|
|
26
27
|
logoUrl: 'https://cdn.activepieces.com/pieces/microsoft-outlook.jpg',
|
|
27
28
|
categories: [shared_1.PieceCategory.PRODUCTIVITY],
|
|
28
|
-
authors: ['lucaslimasouza', 'kishanprmr'],
|
|
29
|
+
authors: ['lucaslimasouza', 'kishanprmr', 'sanket-a11y'],
|
|
29
30
|
actions: [
|
|
30
31
|
send_email_1.sendEmailAction,
|
|
31
32
|
download_email_attachment_1.downloadAttachmentAction,
|
|
@@ -33,6 +34,7 @@ exports.microsoftOutlook = (0, pieces_framework_1.createPiece)({
|
|
|
33
34
|
create_draft_email_1.createDraftEmailAction,
|
|
34
35
|
add_label_to_email_1.addLabelToEmailAction,
|
|
35
36
|
remove_label_from_email_1.removeLabelFromEmailAction,
|
|
37
|
+
request_approval_send_email_1.requestApprovalInMail,
|
|
36
38
|
move_email_to_folder_1.moveEmailToFolderAction,
|
|
37
39
|
send_draft_email_1.sendDraftEmailAction,
|
|
38
40
|
forward_email_1.forwardEmailAction,
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/microsoft-outlook/src/index.ts"],"names":[],"mappings":";;;;AAAA,+DAAwE;AACxE,qEAAkF;AAClF,iDAAqD;AACrD,yEAAyE;AACzE,yEAA0E;AAC1E,uFAAmF;AACnF,yDAA2D;AAC3D,+DAAiE;AACjE,6EAA6E;AAC7E,mFAAmF;AACnF,2DAA6D;AAC7D,qEAAsE;AACtE,yDAA2D;AAC3D,4CAAyD;AACzD,kEAAqE;AACrE,4EAA6E;AAC7E,wDAA2D;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/microsoft-outlook/src/index.ts"],"names":[],"mappings":";;;;AAAA,+DAAwE;AACxE,qEAAkF;AAClF,iDAAqD;AACrD,yEAAyE;AACzE,yEAA0E;AAC1E,uFAAmF;AACnF,yDAA2D;AAC3D,+DAAiE;AACjE,6EAA6E;AAC7E,mFAAmF;AACnF,2DAA6D;AAC7D,qEAAsE;AACtE,yDAA2D;AAC3D,4CAAyD;AACzD,kEAAqE;AACrE,4EAA6E;AAC7E,wDAA2D;AAC3D,2FAAkF;AAErE,QAAA,gBAAgB,GAAG,IAAA,8BAAW,EAAC;IAC3C,WAAW,EAAE,mBAAmB;IAChC,IAAI,EAAE,2BAAoB;IAC1B,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,2DAA2D;IACpE,UAAU,EAAE,CAAC,sBAAa,CAAC,YAAY,CAAC;IACxC,OAAO,EAAE,CAAC,gBAAgB,EAAE,YAAY,EAAC,aAAa,CAAC;IACvD,OAAO,EAAE;QACR,4BAAe;QACf,oDAAwB;QACxB,8BAAgB;QAChB,2CAAsB;QACtB,0CAAqB;QACrB,oDAA0B;QAC1B,mDAAqB;QACrB,8CAAuB;QACvB,uCAAoB;QACpB,kCAAkB;QAClB,4BAAe;QACf,IAAA,yCAAyB,EAAC;YACzB,IAAI,EAAE,2BAAoB;YAC1B,OAAO,EAAE,GAAG,EAAE,CAAC,mCAAmC;YAClD,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC7B,aAAa,EAAE,UAAW,IAA4B,CAAC,YAAY,EAAE;iBACrE,CAAC,CAAA;cAAA;SACF,CAAC;KACF;IACD,QAAQ,EAAE;QACT,2BAAe;QACf,6CAAuB;QACvB,qCAAoB;KACpB;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const requestApprovalInMail: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
recipients: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
subject: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
body: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requestApprovalInMail = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
|
|
7
|
+
const shared_1 = require("@activepieces/shared");
|
|
8
|
+
const auth_1 = require("../common/auth");
|
|
9
|
+
exports.requestApprovalInMail = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: auth_1.microsoftOutlookAuth,
|
|
11
|
+
name: 'request_approval_in_mail',
|
|
12
|
+
displayName: 'Request Approval in Email',
|
|
13
|
+
description: 'Send approval request email and then wait until the email is approved or disapproved',
|
|
14
|
+
props: {
|
|
15
|
+
recipients: pieces_framework_1.Property.ShortText({
|
|
16
|
+
displayName: 'To Email Address',
|
|
17
|
+
description: 'The email address of the recipient who will receive the approval request.',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
subject: pieces_framework_1.Property.ShortText({
|
|
21
|
+
displayName: 'Subject',
|
|
22
|
+
description: 'The subject of the approval request email.',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
body: pieces_framework_1.Property.LongText({
|
|
26
|
+
displayName: 'Body',
|
|
27
|
+
description: 'The main content of the email. You can include details about the approval request here in the html format or plain text.',
|
|
28
|
+
required: true,
|
|
29
|
+
}),
|
|
30
|
+
},
|
|
31
|
+
run(context) {
|
|
32
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
if (context.executionType === shared_1.ExecutionType.BEGIN) {
|
|
34
|
+
try {
|
|
35
|
+
const token = context.auth.access_token;
|
|
36
|
+
const recipients = context.propsValue.recipients;
|
|
37
|
+
const { subject, body } = context.propsValue;
|
|
38
|
+
(0, shared_1.assertNotNullOrUndefined)(token, 'token');
|
|
39
|
+
(0, shared_1.assertNotNullOrUndefined)(recipients, 'recipients');
|
|
40
|
+
(0, shared_1.assertNotNullOrUndefined)(subject, 'subject');
|
|
41
|
+
(0, shared_1.assertNotNullOrUndefined)(body, 'body');
|
|
42
|
+
const approvalLink = context.generateResumeUrl({
|
|
43
|
+
queryParams: { action: 'approve' },
|
|
44
|
+
});
|
|
45
|
+
const disapprovalLink = context.generateResumeUrl({
|
|
46
|
+
queryParams: { action: 'disapprove' },
|
|
47
|
+
});
|
|
48
|
+
const htmlBody = `
|
|
49
|
+
<div>
|
|
50
|
+
<p>${body}</p>
|
|
51
|
+
<br />
|
|
52
|
+
<p>
|
|
53
|
+
<a href="${approvalLink}" style="display: inline-block; padding: 10px 20px; margin-right: 10px; background-color: #28a745; color: white; text-decoration: none; border-radius: 4px;">Approve</a>
|
|
54
|
+
<a href="${disapprovalLink}" style="display: inline-block; padding: 10px 20px; background-color: #dc3545; color: white; text-decoration: none; border-radius: 4px;">Disapprove</a>
|
|
55
|
+
</p>
|
|
56
|
+
</div>
|
|
57
|
+
`;
|
|
58
|
+
const client = microsoft_graph_client_1.Client.initWithMiddleware({
|
|
59
|
+
authProvider: {
|
|
60
|
+
getAccessToken: () => Promise.resolve(context.auth.access_token),
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
const mailPayload = {
|
|
64
|
+
subject,
|
|
65
|
+
body: {
|
|
66
|
+
content: htmlBody,
|
|
67
|
+
contentType: 'html',
|
|
68
|
+
},
|
|
69
|
+
toRecipients: [
|
|
70
|
+
{
|
|
71
|
+
emailAddress: {
|
|
72
|
+
address: recipients,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
};
|
|
77
|
+
const sendResult = yield client.api('/me/sendMail').post({
|
|
78
|
+
message: mailPayload,
|
|
79
|
+
saveToSentItems: true,
|
|
80
|
+
});
|
|
81
|
+
context.run.pause({
|
|
82
|
+
pauseMetadata: {
|
|
83
|
+
type: shared_1.PauseType.WEBHOOK,
|
|
84
|
+
response: {},
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
approved: false, // default approval is false
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
console.error('[RequestApprovalEmail] Error during BEGIN execution:', error);
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
const action = context.resumePayload.queryParams['action'];
|
|
98
|
+
const approved = action === 'approve';
|
|
99
|
+
return {
|
|
100
|
+
approved,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
//# sourceMappingURL=request-approval-send-email.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-approval-send-email.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/microsoft-outlook/src/lib/actions/request-approval-send-email.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,8EAA2D;AAE3D,iDAI8B;AAC9B,yCAAsD;AAEzC,QAAA,qBAAqB,GAAG,IAAA,+BAAY,EAAC;IAChD,IAAI,EAAE,2BAAoB;IAC1B,IAAI,EAAE,0BAA0B;IAChC,WAAW,EAAE,2BAA2B;IACxC,WAAW,EACT,sFAAsF;IACxF,KAAK,EAAE;QACL,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC7B,WAAW,EAAE,kBAAkB;YAC/B,WAAW,EACT,2EAA2E;YAC7E,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,4CAA4C;YACzD,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACtB,WAAW,EAAE,MAAM;YACnB,WAAW,EACT,0HAA0H;YAC5H,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,IAAI,OAAO,CAAC,aAA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F,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC;wBACvD,OAAO,EAAE,WAAW;wBACpB,eAAe,EAAE,IAAI;qBACtB,CAAC,CAAC;oBACH,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC;wBAChB,aAAa,EAAE;4BACb,IAAI,EAAE,kBAAS,CAAC,OAAO;4BACvB,QAAQ,EAAE,EAAE;yBACb;qBACF,CAAC,CAAC;oBAEH,OAAO;wBACL,QAAQ,EAAE,KAAK,EAAE,4BAA4B;qBAC9C,CAAC;gBACJ,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CACX,sDAAsD,EACtD,KAAK,CACN,CAAC;oBACF,MAAM,KAAK,CAAC;gBACd,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;gBAC3D,MAAM,QAAQ,GAAG,MAAM,KAAK,SAAS,CAAC;gBAEtC,OAAO;oBACL,QAAQ;iBACT,CAAC;YACJ,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
2
|
export declare const newAttachmentTrigger: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
3
3
|
folderId: import("@activepieces/pieces-framework").DropdownProperty<string, false, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>> | import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
4
|
+
sender: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
4
5
|
attachmentNameFilter: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
5
6
|
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
6
7
|
folderId: import("@activepieces/pieces-framework").DropdownProperty<string, false, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>> | import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
8
|
+
sender: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
7
9
|
attachmentNameFilter: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
8
10
|
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
9
11
|
folderId: import("@activepieces/pieces-framework").DropdownProperty<string, false, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>> | import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
12
|
+
sender: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
10
13
|
attachmentNameFilter: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
11
14
|
}>;
|
|
@@ -8,10 +8,14 @@ const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
|
8
8
|
const auth_1 = require("../common/auth");
|
|
9
9
|
const props_1 = require("../common/props");
|
|
10
10
|
const shared_1 = require("@activepieces/shared");
|
|
11
|
-
function enrichAttachments(client, messages, files, nameFilter) {
|
|
11
|
+
function enrichAttachments(client, messages, files, nameFilter, senderFilter) {
|
|
12
12
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
var _a, _b;
|
|
13
14
|
const attachments = [];
|
|
14
15
|
for (const message of messages) {
|
|
16
|
+
if (senderFilter && ((_b = (_a = message.sender) === null || _a === void 0 ? void 0 : _a.emailAddress) === null || _b === void 0 ? void 0 : _b.address) && !message.sender.emailAddress.address.toLowerCase().includes(senderFilter.toLowerCase())) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
15
19
|
const attachmentResponse = yield client
|
|
16
20
|
.api(`/me/messages/${message.id}/attachments`)
|
|
17
21
|
.get();
|
|
@@ -43,6 +47,11 @@ exports.newAttachmentTrigger = (0, pieces_framework_1.createTrigger)({
|
|
|
43
47
|
description: 'Monitor attachments in a specific folder. Leave empty to monitor all folders.',
|
|
44
48
|
required: false,
|
|
45
49
|
}),
|
|
50
|
+
sender: pieces_framework_1.Property.ShortText({
|
|
51
|
+
displayName: 'From (Sender Email)',
|
|
52
|
+
description: 'Filter emails from a specific sender (optional). Leave empty to for all senders.',
|
|
53
|
+
required: false,
|
|
54
|
+
}),
|
|
46
55
|
attachmentNameFilter: pieces_framework_1.Property.ShortText({
|
|
47
56
|
displayName: 'Attachment Name Filter',
|
|
48
57
|
description: 'Filter attachments by name (contains). Leave empty to include all attachments.',
|
|
@@ -63,7 +72,7 @@ exports.newAttachmentTrigger = (0, pieces_framework_1.createTrigger)({
|
|
|
63
72
|
},
|
|
64
73
|
test(context) {
|
|
65
74
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
const { folderId, attachmentNameFilter } = context.propsValue;
|
|
75
|
+
const { folderId, attachmentNameFilter, sender } = context.propsValue;
|
|
67
76
|
const client = microsoft_graph_client_1.Client.initWithMiddleware({
|
|
68
77
|
authProvider: {
|
|
69
78
|
getAccessToken: () => Promise.resolve(context.auth.access_token),
|
|
@@ -74,7 +83,7 @@ exports.newAttachmentTrigger = (0, pieces_framework_1.createTrigger)({
|
|
|
74
83
|
.api(`${baseUrl}?$filter=hasAttachments eq true`)
|
|
75
84
|
.top(10)
|
|
76
85
|
.get();
|
|
77
|
-
const attachments = yield enrichAttachments(client, response.value, context.files, attachmentNameFilter);
|
|
86
|
+
const attachments = yield enrichAttachments(client, response.value, context.files, attachmentNameFilter, sender);
|
|
78
87
|
const items = attachments.map((attachment) => ({
|
|
79
88
|
epochMilliSeconds: (0, dayjs_1.default)(attachment['messageReceivedDateTime']).valueOf(),
|
|
80
89
|
data: attachment,
|
|
@@ -88,7 +97,7 @@ exports.newAttachmentTrigger = (0, pieces_framework_1.createTrigger)({
|
|
|
88
97
|
if ((0, shared_1.isNil)(lastFetchEpochMS)) {
|
|
89
98
|
throw new Error("lastPoll doesn't exist in the store.");
|
|
90
99
|
}
|
|
91
|
-
const { folderId, attachmentNameFilter } = context.propsValue;
|
|
100
|
+
const { folderId, attachmentNameFilter, sender } = context.propsValue;
|
|
92
101
|
const client = microsoft_graph_client_1.Client.initWithMiddleware({
|
|
93
102
|
authProvider: {
|
|
94
103
|
getAccessToken: () => Promise.resolve(context.auth.access_token),
|
|
@@ -109,7 +118,7 @@ exports.newAttachmentTrigger = (0, pieces_framework_1.createTrigger)({
|
|
|
109
118
|
break;
|
|
110
119
|
}
|
|
111
120
|
}
|
|
112
|
-
const attachments = yield enrichAttachments(client, messages, context.files, attachmentNameFilter);
|
|
121
|
+
const attachments = yield enrichAttachments(client, messages, context.files, attachmentNameFilter, sender);
|
|
113
122
|
const items = attachments.map((attachment) => ({
|
|
114
123
|
epochMilliSeconds: (0, dayjs_1.default)(attachment['messageReceivedDateTime']).valueOf(),
|
|
115
124
|
data: attachment,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new-attachment.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/microsoft-outlook/src/lib/triggers/new-attachment.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"new-attachment.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/microsoft-outlook/src/lib/triggers/new-attachment.ts"],"names":[],"mappings":";;;;AAAA,qEAAyG;AACzG,8EAA2E;AAE3E,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