-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Microsoft Outlook: New Attachment Received & Download Attachment #16324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
""" WalkthroughThis update introduces new functionality to the Microsoft Outlook integration by adding a "Download Attachment" action and a "New Attachment Received (Instant)" source. The Outlook app component is extended with methods to list and fetch email attachments. The new source emits events for each new email attachment, including detailed metadata, while the new action downloads the specified attachment to a temporary file. Several existing actions and sources receive minor updates, primarily version increments and import path corrections. The package version is also incremented to reflect these enhancements. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant NewAttachmentSource
participant MicrosoftOutlookApp
participant Workflow
User->>NewAttachmentSource: Configure source (optionally set folder)
NewAttachmentSource->>MicrosoftOutlookApp: Subscribe to new message events
MicrosoftOutlookApp-->>NewAttachmentSource: Notifies on new message
NewAttachmentSource->>MicrosoftOutlookApp: Fetch message details
NewAttachmentSource->>MicrosoftOutlookApp: List attachments for message
loop For each attachment
NewAttachmentSource->>Workflow: Emit event with attachment and message metadata
end
sequenceDiagram
participant User
participant DownloadAttachmentAction
participant MicrosoftOutlookApp
participant FileSystem
User->>DownloadAttachmentAction: Provide messageId, attachmentId, filename
DownloadAttachmentAction->>MicrosoftOutlookApp: getAttachment(messageId, attachmentId)
MicrosoftOutlookApp-->>DownloadAttachmentAction: Attachment data (array buffer)
DownloadAttachmentAction->>FileSystem: Write buffer to /tmp/filename
DownloadAttachmentAction-->>User: Return filename, contentType, filePath
Assessment against linked issues
Suggested labels
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
components/microsoft_outlook/sources/new-attachment-received/new-attachment-received.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🔭 Outside diff range comments (1)
components/microsoft_outlook/sources/new-email/new-email.mjs (1)
54-76
:⚠️ Potential issueSame self‑recursion issue in
run()
As with the attachment source, the new e‑mail source’s
run()
overrides the base method but callsthis.run()
internally, leading to infinite recursion.-await this.run({ +await this.processEvents({ event, emitFn: async ({ resourceId } = {}) => {Rename the helper or call the inherited implementation directly.
This affects all live runs of the source.
🧹 Nitpick comments (5)
components/microsoft_outlook/sources/common/common.mjs (1)
5-7
: Clarify unit consistency for renewal intervals.
Currently,getRenewalInterval()
returns seconds when called without an argument, and milliseconds whenperiod
is truthy (day * 2.5 * 1000
). This dual‐unit behavior can be confusing and error‑prone. Consider:
- Renaming the
period
parameter to something likeasMilliseconds
for clarity.- Splitting into two separate functions (e.g.,
getRenewalIntervalSeconds
andgetRenewalIntervalMilliseconds
).
Also verify that the 2.5‑day (60‑hour) renewal period aligns with the Graph API’s 4230‑minute maximum.components/microsoft_outlook/actions/download-attachment/download-attachment.mjs (1)
49-54
: Return object looks good, consider adding success messageThe return object contains all necessary information. Consider adding a user-friendly summary message using
$.export("$summary", "...")
like other actions do.+ $.export("$summary", `Successfully downloaded attachment '${this.filename}'`); return { fileName: this.filename, contentType, filePath: downloadedFilepath, };
components/microsoft_outlook/sources/common/common-new-email.mjs (1)
43-47
: Gracefully handle missing folders
getFolderIdByName()
returnsundefined
when the folder is not found, which then gets persisted to the DB and later compared inisRelevant()
.
If Outlook is configured in a language other than English, the display names “Sent Items” / “Drafts” will differ, leading to unexpected behaviour.Consider:
const folder = folders.find(({ displayName }) => displayName === name); -return folder?.id; +if (!folder) this.$logger.debug(`Folder "${name}" not found`); +return folder?.id ?? null;And make the “sent”/“drafts” names configurable or use the well‑known folder names API (
/me/mailFolders/sentitems
).components/microsoft_outlook/sources/new-attachment-received/new-attachment-received.mjs (2)
14-39
: Speed‑up sample generation with parallel requests
getSampleEvents()
fetches attachments sequentially – first messages per folder, then attachments per message – which can take several seconds for large mailboxes.A low‑risk optimisation:
-const attachments = []; -for (const message of messagesWithAttachments) { - const messageAttachments = await this.getMessageAttachments(message); - attachments.push(...messageAttachments); -} -return attachments; +const attachments = await Promise.all( + messagesWithAttachments.map((m) => this.getMessageAttachments(m)), +); +return attachments.flat();Wrap the
Promise.all
in a throttler if you fear Graph API rate limits.
64-66
: Missing fallback for malformed dates
Date.parse(item.messageReceivedDateTime)
returnsNaN
if the field is missing or non‑ISO.
Consider defaulting toDate.now()
to ensure a valid timestamp for the event metadata.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (22)
components/microsoft_outlook/actions/add-label-to-email/add-label-to-email.mjs
(1 hunks)components/microsoft_outlook/actions/approve-workflow/approve-workflow.mjs
(1 hunks)components/microsoft_outlook/actions/create-contact/create-contact.mjs
(1 hunks)components/microsoft_outlook/actions/create-draft-email/create-draft-email.mjs
(1 hunks)components/microsoft_outlook/actions/download-attachment/download-attachment.mjs
(1 hunks)components/microsoft_outlook/actions/find-contacts/find-contacts.mjs
(1 hunks)components/microsoft_outlook/actions/find-email/find-email.mjs
(1 hunks)components/microsoft_outlook/actions/list-contacts/list-contacts.mjs
(1 hunks)components/microsoft_outlook/actions/list-folders/list-folders.mjs
(1 hunks)components/microsoft_outlook/actions/list-labels/list-labels.mjs
(1 hunks)components/microsoft_outlook/actions/move-email-to-folder/move-email-to-folder.mjs
(1 hunks)components/microsoft_outlook/actions/remove-label-from-email/remove-label-from-email.mjs
(1 hunks)components/microsoft_outlook/actions/reply-to-email/reply-to-email.mjs
(1 hunks)components/microsoft_outlook/actions/send-email/send-email.mjs
(1 hunks)components/microsoft_outlook/actions/update-contact/update-contact.mjs
(1 hunks)components/microsoft_outlook/microsoft_outlook.app.mjs
(2 hunks)components/microsoft_outlook/package.json
(1 hunks)components/microsoft_outlook/sources/common/common-new-email.mjs
(1 hunks)components/microsoft_outlook/sources/common/common.mjs
(1 hunks)components/microsoft_outlook/sources/new-attachment-received/new-attachment-received.mjs
(1 hunks)components/microsoft_outlook/sources/new-contact/new-contact.mjs
(1 hunks)components/microsoft_outlook/sources/new-email/new-email.mjs
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: pnpm publish
🔇 Additional comments (24)
components/microsoft_outlook/actions/list-labels/list-labels.mjs (1)
7-7
: Bump ACK: Version bump aligns with PR conventions
The version increment from"0.0.5"
to"0.0.6"
is consistent with the coordinated updates across Outlook actions, and there are no functional changes in this module.components/microsoft_outlook/actions/create-contact/create-contact.mjs (1)
6-6
: Version update looks good.The version increment from "0.0.12" to "0.0.13" aligns with similar updates across other Microsoft Outlook actions in this PR.
components/microsoft_outlook/microsoft_outlook.app.mjs (3)
173-195
: Well-structured property definition for attachments.The new
attachmentId
property definition is well implemented with proper label, description, and async options method that includes pagination support. This follows the same pattern as other property definitions in the file.
429-436
: Clean implementation of attachment download method.The
getAttachment
method properly uses the Microsoft Graph API endpoint with the/$value
suffix to get the raw content of an attachment.
437-444
: Good implementation of attachment listing method.The
listAttachments
method uses the appropriate Microsoft Graph API endpoint to retrieve attachments for a specified message, and correctly handles additional parameters through theargs
parameter.components/microsoft_outlook/actions/find-contacts/find-contacts.mjs (1)
6-6
: Version update looks good.The version increment from "0.0.12" to "0.0.13" aligns with similar updates across other Microsoft Outlook actions in this PR.
components/microsoft_outlook/actions/update-contact/update-contact.mjs (1)
6-6
: Version update looks good.The version increment from "0.0.12" to "0.0.13" aligns with similar updates across other Microsoft Outlook actions in this PR.
components/microsoft_outlook/actions/reply-to-email/reply-to-email.mjs (1)
7-7
: Approved: Version bump only
The version has been correctly incremented from “0.0.2” to “0.0.3” with no unintended side‑effects.components/microsoft_outlook/actions/move-email-to-folder/move-email-to-folder.mjs (1)
7-7
: Approved: Version bump only
The version has been correctly incremented from “0.0.3” to “0.0.4” with no unintended side‑effects.components/microsoft_outlook/actions/approve-workflow/approve-workflow.mjs (1)
7-7
: Approved: Version bump only
The version has been correctly incremented from “0.0.3” to “0.0.4” with no unintended side‑effects.components/microsoft_outlook/actions/list-contacts/list-contacts.mjs (1)
6-6
: Approved: Version bump only
The version has been correctly incremented from “0.0.12” to “0.0.13” with no unintended side‑effects.components/microsoft_outlook/actions/remove-label-from-email/remove-label-from-email.mjs (1)
7-7
: Approved: Version bump only
The version has been correctly incremented from “0.0.5” to “0.0.6” with no unintended side‑effects.components/microsoft_outlook/sources/common/common.mjs (1)
1-1
: Import path update looks correct.
The relative path now correctly resolves tocomponents/microsoft_outlook/microsoft_outlook.app.mjs
.components/microsoft_outlook/package.json (1)
3-3
: Package version bumped appropriately.
The version has been updated to1.5.0
to encapsulate the new attachment actions and related enhancements. Ensure this matches release notes and any downstream dependencies.components/microsoft_outlook/actions/add-label-to-email/add-label-to-email.mjs (1)
8-8
: Action version bumped to 0.0.6.
No logic changes were made—this aligns with the coordinated version updates across Outlook actions.components/microsoft_outlook/actions/list-folders/list-folders.mjs (1)
7-7
: Action version bump to 0.0.4.
No functional changes here; versions remain consistent across the Microsoft Outlook actions.components/microsoft_outlook/actions/send-email/send-email.mjs (1)
6-6
: Action version incremented to 0.0.14.
No code or logic modifications—this keeps the send‑email action in sync with the broader Outlook integration versioning.components/microsoft_outlook/actions/create-draft-email/create-draft-email.mjs (1)
6-6
: Version increment looks goodThe version has been incremented from "0.0.12" to "0.0.13" as part of the broader update to the Microsoft Outlook integration package.
components/microsoft_outlook/actions/find-email/find-email.mjs (1)
7-7
: Version increment looks goodThe version has been incremented from "0.0.3" to "0.0.4" as part of the broader update to the Microsoft Outlook integration package.
components/microsoft_outlook/sources/new-contact/new-contact.mjs (2)
1-1
: Import path update looks goodThe import path for the common module has been updated from "../common.mjs" to "../common/common.mjs", which aligns with the restructuring of common modules in the Microsoft Outlook sources.
8-8
: Version increment looks goodThe version has been incremented from "0.0.13" to "0.0.14" as part of the broader update to the Microsoft Outlook integration package.
components/microsoft_outlook/actions/download-attachment/download-attachment.mjs (3)
1-4
: Imports look goodThe imports for Microsoft Outlook app, file system (fs), and MIME types are appropriate for the attachment download functionality.
5-34
: Action definition and props look goodThe action is well-defined with appropriate key, name, description, and version. The props are properly structured with clear descriptions, and the attachment ID prop correctly depends on the message ID.
35-42
: API call implementation looks goodThe implementation correctly calls the Microsoft Outlook API to retrieve the attachment with the appropriate parameters and response type.
components/microsoft_outlook/actions/download-attachment/download-attachment.mjs
Show resolved
Hide resolved
components/microsoft_outlook/sources/new-attachment-received/new-attachment-received.mjs
Show resolved
Hide resolved
/approve |
Resolves #16270
Summary by CodeRabbit
New Features
Improvements
Bug Fixes
Chores