-
Notifications
You must be signed in to change notification settings - Fork 5.5k
18109 microsoft outlook #18295
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
18109 microsoft outlook #18295
Conversation
- Added userId and sharedFolderId props for retrieving messages from shared folders. - Introduced search, filter, and orderBy props for more refined email searches. - Implemented listUsers and listSharedFolders methods for user and folder management. - Added new action to find emails in shared folders. - Updated existing actions and sources with version bumps and minor fixes. - Bumped component version to 1.6.0.
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Warning Rate limit exceeded@luancazarine has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 21 minutes and 27 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
WalkthroughAdds shared-folder support to the Microsoft Outlook integration: new app propDefinitions and methods for listing users, shared folders, and shared-folder messages; a new action to find emails in a shared folder; a new polling source (and test fixture) for new emails in shared folders; plus multiple version bumps, minor import reorderings, and a package version update. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant Action as Find Shared Folder Email
participant App as Microsoft Outlook App
participant Graph as Microsoft Graph
User->>Action: run(userId, sharedFolderId, $search/$filter/$orderby, maxResults)
Action->>App: listSharedFolderMessages({ userId, sharedFolderId, $search, $filter, $orderby, paginate })
App->>Graph: GET /users/{userId}/mailFolders/{sharedFolderId}/messages
Graph-->>App: 200 OK (paged results)
loop pages
App-->>Action: messages[]
end
Action-->>User: collected emails + summary
sequenceDiagram
autonumber
participant Source as New Email in Shared Folder (Source)
participant DB as Source DB
participant App as Microsoft Outlook App
participant Graph as Microsoft Graph
Note left of Source: deploy()
Source->>App: listSharedFolderMessages({ filter: createdDateTime gt lastDate, orderBy: createdDateTime desc, paginate, top })
App->>Graph: GET .../messages?$filter=...&$orderby=...
Graph-->>App: paged results
App-->>Source: messages[]
Source->>DB: set lastDate = newest.createdDateTime
Note left of Source: run()
Source->>DB: get lastDate
Source->>App: listSharedFolderMessages with updated filter/order
App->>Graph: GET messages (paged)
Graph-->>App: results
App-->>Source: messages[]
loop emit oldest→newest
Source-->>EventSink: emit({ id: conversationId, ts: createdDateTime, body: message })
end
Source->>DB: update lastDate
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
…, new-attachment-received, and new-email sources
…mHQ/pipedream into 18109-microsoft-outlook
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: 9
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (6)
components/microsoft_outlook/actions/remove-label-from-email/remove-label-from-email.mjs (1)
34-47
: Guard against undefined categories and no-op when label absent
message?.categories
can be undefined.labels.indexOf(...)
will throw. Also, avoid sendingundefined
back to Graph.Apply this diff:
- let labels = message?.categories; - - const index = labels.indexOf(this.label); - if (index > -1) { - labels.splice(index, 1); - } + const labels = Array.isArray(message?.categories) + ? [ ...message.categories ] + : []; + if (!labels.includes(this.label)) { + $.export("$summary", "Label not found on message. No changes made."); + return message; + } + const updatedCategories = labels.filter((l) => l !== this.label); @@ - data: { - categories: labels, - }, + data: { categories: updatedCategories },components/microsoft_outlook/microsoft_outlook.app.mjs (1)
268-281
: Allow per-request header overrides (needed for $search)
_getHeaders
ignores theheaders
argument from_makeRequest
, making it impossible to setConsistencyLevel: eventual
for$search
.- _getHeaders() { - return { - "Authorization": `Bearer ${this.$auth.oauth_access_token}`, - "accept": "application/json", - "Content-Type": "application/json", - }; - }, + _getHeaders(extra = {}) { + return { + "Authorization": `Bearer ${this.$auth.oauth_access_token}`, + "accept": "application/json", + "Content-Type": "application/json", + ...extra, + }; + },components/microsoft_outlook/actions/create-contact/create-contact.mjs (1)
49-55
: Guard optional props to prevent runtime errors.
this.emailAddresses
may be undefined and...this.expand
will throw ifexpand
is undefined/null. Align with the pattern used elsewhere.- emailAddresses: this.emailAddresses.map((a, i) => ({ - address: a, - name: `Email #${i + 1}`, - })), + emailAddresses: Array.isArray(this.emailAddresses) + ? this.emailAddresses.map((a, i) => ({ + address: a, + name: `Email #${i + 1}`, + })) + : undefined, businessPhones: this.businessPhones, - ...this.expand, + ...(this.expand ?? {}),components/microsoft_outlook/actions/add-label-to-email/add-label-to-email.mjs (1)
35-49
: Handle messages without categories to avoid TypeError.
message?.categories
can be undefined;includes
and spread would throw.- const labels = message?.categories; + const labels = Array.isArray(message?.categories) ? message.categories : [];components/microsoft_outlook/actions/download-attachment/download-attachment.mjs (1)
48-53
: Avoid path traversal and unnecessary base64 conversions.Current code allows
../
infilename
to escape/tmp
, and it round-trips through base64 unnecessarily.- const rawcontent = response.toString("base64"); - const buffer = Buffer.from(rawcontent, "base64"); - const downloadedFilepath = `/tmp/${this.filename}`; - fs.writeFileSync(downloadedFilepath, buffer); - const contentType = mime.lookup(downloadedFilepath); + const buffer = Buffer.isBuffer(response) ? response : Buffer.from(response); + const safeName = path.basename(this.filename || "attachment"); + const baseDir = this.syncDir || "/tmp"; + const downloadedFilepath = path.join(baseDir, safeName); + fs.writeFileSync(downloadedFilepath, buffer); + const contentType = mime.lookup(safeName) || "application/octet-stream";Add required import at the top:
import path from "path";components/microsoft_outlook/actions/find-email/find-email.mjs (1)
41-52
: Ensure Graph$search
queries includeConsistencyLevel: eventual
header
listMessages
incomponents/microsoft_outlook/microsoft_outlook.app.mjs
currently forwardsparams
without setting the required header. Add logic to merge or injectConsistencyLevel: eventual
(for example, extend_getHeaders
to accept and merge custom headers whenparams.$search
is present).
🧹 Nitpick comments (9)
components/microsoft_outlook/actions/approve-workflow/approve-workflow.mjs (1)
30-35
: Avoid spreading the entire component instance into the message body.
Limit props passed to the message to just what’s needed to prevent leaking unrelated props and reduce coupling.Apply:
- const opts = { - content: `Click here to approve the workflow: ${resume_url}, \nand cancel here: ${cancel_url}`, - ccRecipients: [], - bccRecipients: [], - ...this, - }; + const opts = { + content: `Click here to approve the workflow: ${resume_url}, \nand cancel here: ${cancel_url}`, + recipients: this.recipients, + subject: this.subject, + ccRecipients: [], + bccRecipients: [], + };components/microsoft_outlook/actions/reply-to-email/reply-to-email.mjs (1)
70-72
: Validate usage ofexpand
.
Ifexpand
is intended for Graph’s$expand
query param, it shouldn’t be spread into the message body. EnsurereplyToEmail
handles it as a query option instead.components/microsoft_outlook/actions/move-email-to-folder/move-email-to-folder.mjs (1)
18-25
: Prop naming/type consistency for folder selection.
You referencepropDefinition: ["folderIds"]
but expose a singlefolderId
string. Confirm the underlying prop returns a single ID, or rename/adjust for clarity.components/microsoft_outlook/microsoft_outlook.app.mjs (2)
208-230
: Shared folder options: avoid deep recursive fan-out and encode IDsCurrent recursion can explode requests and ignores URL encoding. Suggest limiting recursion for options and encoding IDs in the method it calls.
- async options({ - userId, page, - }) { - const sharedFolders = await this.listSharedFolders({ - userId, - params: { - $top: DEFAULT_LIMIT, - $skip: DEFAULT_LIMIT * page, - }, - }); - - return sharedFolders?.map(({ - id: value, displayName, - }) => ({ - value, - label: displayName, - })) || []; - }, + async options({ userId, page }) { + const limit = DEFAULT_LIMIT; + const sharedFolders = await this.listSharedFolders({ + userId, + // Only page the current level to keep options responsive + params: { $top: limit, $skip: limit * page }, + }); + return sharedFolders?.map((f) => ({ + value: f.id, + label: f.displayName || f.id, + })) || []; + },
239-255
: Doc quality nit: clarify examples for search/filter/orderMinor wording refinements improve UX; current behavior unchanged.
If desired, I can submit a small copy edit PR across these descriptions for consistency.
components/microsoft_outlook/actions/update-contact/update-contact.mjs (1)
64-65
: Parse/guardexpand
to avoid spreading non-objects.Use the same
parseObject
pattern used in send-email to safely handle JSON strings and undefined.- ...this.expand, + ...parseObject(this.expand),Additional import required at the top of the file:
import { parseObject } from "../../common/utils.mjs";components/microsoft_outlook/sources/new-email-in-shared-folder/new-email-in-shared-folder.mjs (3)
59-66
: Advance the cursor based on the max timestamp, not array position.Coupling watermarking to result order is brittle (especially if ordering fails). Compute the newest timestamp, then emit oldest→newest.
let responseArray = []; for await (const item of items) { responseArray.push(item); } - if (responseArray.length) this._setLastDate(responseArray[0].createdDateTime); - - for (const item of responseArray.reverse()) { + if (responseArray.length) { + const newest = responseArray.reduce( + (max, { createdDateTime }) => createdDateTime > max ? createdDateTime : max, + lastDate, + ); + this._setLastDate(newest); + } + + responseArray.sort((a, b) => + new Date(a.createdDateTime) - new Date(b.createdDateTime)); + for (const item of responseArray) {
50-52
: PreferreceivedDateTime
for email polling semantics.For “new email” signals,
receivedDateTime
is typically the more accurate field to filter/order/emit by.- "$orderby": "createdDateTime desc", - "$filter": `createdDateTime gt ${lastDate}`, + "$orderby": "receivedDateTime desc", + "$filter": `receivedDateTime gt ${lastDate}`,- if (responseArray.length) { - const newest = responseArray.reduce( - (max, { createdDateTime }) => createdDateTime > max ? createdDateTime : max, + if (responseArray.length) { + const newest = responseArray.reduce( + (max, { receivedDateTime }) => receivedDateTime > max ? receivedDateTime : max, lastDate, ); this._setLastDate(newest); } - responseArray.sort((a, b) => - new Date(a.createdDateTime) - new Date(b.createdDateTime)); + responseArray.sort((a, b) => + new Date(a.receivedDateTime) - new Date(b.receivedDateTime));- ts: item.createdDateTime, + ts: item.receivedDateTime,Also applies to: 64-64, 72-72
8-8
: Tighten description wording.It selects a single folder; use singular.
- description: "Emit new event when an email is received in specified shared folders.", + description: "Emit an event when an email is received in the specified shared folder.",
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 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/find-shared-folder-email/find-shared-folder-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
(4 hunks)components/microsoft_outlook/package.json
(1 hunks)components/microsoft_outlook/sources/new-contact/new-contact.mjs
(1 hunks)components/microsoft_outlook/sources/new-email-in-shared-folder/new-email-in-shared-folder.mjs
(1 hunks)components/microsoft_outlook/sources/new-email-in-shared-folder/test-event.mjs
(1 hunks)components/microsoft_outlook/sources/new-email/new-email.mjs
(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
components/microsoft_outlook/actions/find-shared-folder-email/find-shared-folder-email.mjs (2)
components/microsoft_outlook/actions/find-email/find-email.mjs (2)
items
(42-52)emails
(54-54)components/microsoft_outlook/sources/new-email-in-shared-folder/new-email-in-shared-folder.mjs (1)
items
(46-57)
components/microsoft_outlook/sources/new-email-in-shared-folder/new-email-in-shared-folder.mjs (1)
components/microsoft_outlook/actions/find-shared-folder-email/find-shared-folder-email.mjs (1)
items
(57-70)
components/microsoft_outlook/microsoft_outlook.app.mjs (1)
components/reddit/reddit.app.mjs (1)
displayName
(461-464)
🪛 Gitleaks (8.27.2)
components/microsoft_outlook/sources/new-email-in-shared-folder/test-event.mjs
7-7: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Lint Code Base
- GitHub Check: pnpm publish
- GitHub Check: Publish TypeScript components
- GitHub Check: Verify TypeScript components
🔇 Additional comments (25)
components/microsoft_outlook/package.json (1)
3-3
: Version bump looks appropriate for new features.Minor bump from 1.5.x to 1.6.0 matches the added shared-folder capabilities in this release. Ensure CHANGELOG and release notes reflect the new action/source.
components/microsoft_outlook/actions/list-folders/list-folders.mjs (1)
7-7
: Version increment only — OK.No functional changes; version bump to 0.0.7 aligns with the package release.
components/microsoft_outlook/sources/new-email/new-email.mjs (1)
2-2
: Import reordering — no behavioral impact.Order change is harmless. Confirm it satisfies your eslint/import-order rules to avoid churn in future diffs.
components/microsoft_outlook/actions/list-contacts/list-contacts.mjs (1)
6-6
: Action version bump acknowledged.No logic changes; version 0.0.16 is fine and consistent with other action bumps.
components/microsoft_outlook/actions/find-contacts/find-contacts.mjs (1)
6-6
: Action version bump acknowledged.No functional modifications detected; 0.0.16 aligns with the release set.
components/microsoft_outlook/actions/approve-workflow/approve-workflow.mjs (1)
7-7
: Version bump only — LGTM.components/microsoft_outlook/sources/new-contact/new-contact.mjs (2)
8-8
: Version bump only — LGTM.
45-55
: No recursion:run
correctly delegates tocommon.methods.run
common.methods.run
is defined in components/microsoft_outlook/sources/common/common.mjs and is invoked viathis.run(...)
, so there’s no self-recursion risk.components/microsoft_outlook/actions/reply-to-email/reply-to-email.mjs (1)
7-7
: Version bump only — LGTM.components/microsoft_outlook/actions/list-labels/list-labels.mjs (1)
7-7
: Version bump only — LGTM.components/microsoft_outlook/actions/move-email-to-folder/move-email-to-folder.mjs (1)
7-7
: Version bump only — LGTM.components/microsoft_outlook/actions/create-draft-email/create-draft-email.mjs (2)
2-2
: Import reorder is fineNo functional impact.
7-7
: Version bump LGTMNo compatibility concerns from this change alone.
components/microsoft_outlook/actions/remove-label-from-email/remove-label-from-email.mjs (1)
7-7
: Version bump LGTMMatches the PR-wide versioning pattern.
components/microsoft_outlook/microsoft_outlook.app.mjs (1)
455-463
: Verify required Graph OAuth scopes for shared folder operations
Confirm that your app’s OAuth configuration grants delegatedMail.Read.Shared
or applicationMail.Read
(+ directory scopes) for the newlistSharedFolderMessages
(and related) actions—missing scopes will cause 403s.components/microsoft_outlook/actions/create-contact/create-contact.mjs (1)
6-6
: Version bump looks good.No behavioral change introduced.
components/microsoft_outlook/actions/update-contact/update-contact.mjs (1)
6-6
: Version bump looks good.No functional changes.
components/microsoft_outlook/actions/add-label-to-email/add-label-to-email.mjs (2)
2-2
: Import reorder is fine.No side effects expected.
8-8
: Version bump looks good.Public metadata only.
components/microsoft_outlook/actions/download-attachment/download-attachment.mjs (2)
3-3
: Import position change is fine.No behavior change.
9-9
: Version bump looks good.No functional changes.
components/microsoft_outlook/actions/send-email/send-email.mjs (2)
2-2
: Import reorder looks fine.No observed side effects.
7-7
: Version bump looks good.Public metadata only.
components/microsoft_outlook/actions/find-email/find-email.mjs (1)
22-33
: PropDefinition migration LGTM.Switching
filter
/orderBy
to sharedpropDefinition
s improves consistency across actions.components/microsoft_outlook/actions/find-shared-folder-email/find-shared-folder-email.mjs (1)
56-70
: LGTM on shared-folder query wiring.Correctly forwards
userId
,sharedFolderId
, and$search
/$filter
/$orderby
tolistSharedFolderMessages
.
components/microsoft_outlook/actions/update-contact/update-contact.mjs
Outdated
Show resolved
Hide resolved
components/microsoft_outlook/sources/new-email-in-shared-folder/new-email-in-shared-folder.mjs
Show resolved
Hide resolved
components/microsoft_outlook/sources/new-email-in-shared-folder/new-email-in-shared-folder.mjs
Show resolved
Hide resolved
components/microsoft_outlook/sources/new-email-in-shared-folder/test-event.mjs
Show resolved
Hide resolved
…e-contact description for clarity
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.
Hi @luancazarine lgtm! Ready for QA!
Resolves #18109
Summary by CodeRabbit
New Features
Chores