Skip to content

Comments

refactor: use options object in sendMessage function signature#38772

Merged
kodiakhq[bot] merged 5 commits intodevelopfrom
refactor/sendMessage-options-object
Feb 18, 2026
Merged

refactor: use options object in sendMessage function signature#38772
kodiakhq[bot] merged 5 commits intodevelopfrom
refactor/sendMessage-options-object

Conversation

@ricardogarim
Copy link
Contributor

@ricardogarim ricardogarim commented Feb 18, 2026

Proposed changes (including videos or screenshots)

This PR refactors the internal sendMessage function signature to use an options object instead of positional parameters.

Before:

export const sendMessage = async function (user: any, message: any, room: any, upsert = false, previewUrls?: string[])

// Callers - unclear what `true` or `false` means
sendMessage(user, message, room, true);
sendMessage(user, message, room, false, previewUrls);

After:

type SendMessageOptions = {
  upsert?: boolean;
  previewUrls?: string[];
};

export const sendMessage = async function (user: any, message: any, room: any, options: SendMessageOptions = {})

// Callers - self-documenting
sendMessage(user, message, room, { upsert: true });
sendMessage(user, message, room, { previewUrls });

Benefits:

  • Self-documenting function calls
  • Easier to extend with new options without breaking existing callers
  • No need to pass false just to reach later positional parameters

Issue(s)

Related to #32703 - This refactoring was suggested during code review to improve the function signature before adding additional parameters.

Further comments

This is a pure internal refactoring with no changes to external APIs (Meteor methods, REST endpoints). The Meteor method sendMessage signature remains unchanged - only the internal function used by server-side code was updated.

This change prepares the codebase for #32703 which needs to add a filesToConfirm parameter. With this refactoring in place, that PR can simply extend the SendMessageOptions type instead of adding yet another positional parameter.

Summary by CodeRabbit

  • Refactor
    • Internal messaging API standardized to use configuration objects for message sending options (e.g., upsert and preview handling), simplifying integrations and improving consistency across chat, livechat, email inbox, external bridge, and call/video flows. End-user behavior remains unchanged while making message delivery and link-preview handling more reliable.

@ricardogarim ricardogarim requested review from a team as code owners February 18, 2026 16:57
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Feb 18, 2026

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Feb 18, 2026

⚠️ No Changeset found

Latest commit: 5146733

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

Walkthrough

The sendMessage function now accepts a single options object (SendMessageOptions with upsert? and previewUrls?) and many callers were updated to pass { upsert: true }, { previewUrls: ... }, or omit the old positional boolean argument.

Changes

Cohort / File(s) Summary
Function definition
apps/meteor/app/lib/server/functions/sendMessage.ts
Added SendMessageOptions and refactored sendMessage to accept options?: SendMessageOptions (destructures upsert and previewUrls) instead of separate positional params.
RPC / method
apps/meteor/app/lib/server/methods/sendMessage.ts
Updated call to pass options object { previewUrls: extraInfo?.previewUrls } instead of a positional boolean.
Livechat hook
apps/meteor/app/livechat/server/hooks/offlineMessageToChannel.ts
Changed fourth arg from true to { upsert: true }.
Slack adapters
apps/meteor/app/slackbridge/server/RocketAdapter.ts, apps/meteor/app/slackbridge/server/SlackAdapter.ts
Replaced positional true with { upsert: true } in sendMessage calls.
Email inbox
apps/meteor/server/features/EmailInbox/EmailInbox_Outgoing.ts
Changed sendMessage call to pass { upsert: true } instead of boolean.
Services — messages / media / video
apps/meteor/server/services/messages/service.ts, apps/meteor/server/services/media-call/service.ts, apps/meteor/server/services/video-conference/service.ts
Updated internal sendMessage invocations to use options object or omit the old fourth positional argument (relying on defaults).
Authentication path
apps/meteor/app/authentication/server/lib/restrictLoginAttempts.ts
Removed explicit final boolean argument from sendMessage call (now omitted).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐇 I hopped through code, neat and light,
Options bundled, tidy and bright.
Upsert snug in an object small,
Preview links ready for the call.
Hooray — messages lined up just right! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: refactoring the sendMessage function to use an options object instead of positional parameters, which is the core objective of this PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ricardogarim ricardogarim marked this pull request as draft February 18, 2026 16:58
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 10 files

@codecov
Copy link

codecov bot commented Feb 18, 2026

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.46%. Comparing base (562d5ce) to head (5146733).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #38772      +/-   ##
===========================================
- Coverage    70.48%   70.46%   -0.03%     
===========================================
  Files         3176     3176              
  Lines       111476   111476              
  Branches     20157    20149       -8     
===========================================
- Hits         78578    78550      -28     
- Misses       30854    30881      +27     
- Partials      2044     2045       +1     
Flag Coverage Δ
e2e 60.43% <ø> (-0.02%) ⬇️
e2e-api 47.76% <33.33%> (ø)
unit 71.43% <ø> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ricardogarim ricardogarim force-pushed the refactor/sendMessage-options-object branch from 0307947 to 6622b09 Compare February 18, 2026 17:08
@ricardogarim
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 18, 2026

📦 Docker Image Size Report

📈 Changes

Service Current Baseline Change Percent
sum of all images 1.1GiB 1.1GiB +11MiB
rocketchat 360MiB 349MiB +11MiB
omnichannel-transcript-service 134MiB 134MiB +137B
queue-worker-service 134MiB 134MiB -956B
ddp-streamer-service 128MiB 128MiB -499B
account-service 115MiB 115MiB +74B
authorization-service 112MiB 112MiB -135B
presence-service 112MiB 112MiB +523B

📊 Historical Trend

---
config:
  theme: "dark"
  xyChart:
    width: 900
    height: 400
---
xychart
  title "Image Size Evolution by Service (Last 30 Days + This PR)"
  x-axis ["11/27 22:32", "11/28 19:05", "12/01 23:01", "12/02 21:57", "12/03 21:00", "12/04 18:17", "12/05 21:56", "12/08 20:15", "12/09 22:17", "12/10 23:26", "12/11 21:56", "12/12 22:45", "12/13 01:34", "12/15 22:31", "12/16 22:18", "12/17 21:04", "12/18 23:12", "12/19 23:27", "12/20 21:03", "12/22 18:54", "12/23 16:16", "12/24 19:38", "12/25 17:51", "12/26 13:18", "12/29 19:01", "12/30 20:52", "02/12 22:57", "02/13 22:38", "02/16 14:04", "02/18 20:20", "02/18 20:50 (PR)"]
  y-axis "Size (GB)" 0 --> 0.5
  line "account-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "authorization-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "ddp-streamer-service" [0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12]
  line "omnichannel-transcript-service" [0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13]
  line "presence-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "queue-worker-service" [0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13]
  line "rocketchat" [0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.35]
Loading

Statistics (last 30 days):

  • 📊 Average: 1.5GiB
  • ⬇️ Minimum: 1.4GiB
  • ⬆️ Maximum: 1.6GiB
  • 🎯 Current PR: 1.1GiB
ℹ️ About this report

This report compares Docker image sizes from this build against the develop baseline.

  • Tag: pr-38772
  • Baseline: develop
  • Timestamp: 2026-02-18 20:50:55 UTC
  • Historical data points: 30

Updated: Wed, 18 Feb 2026 20:50:55 GMT

@ricardogarim ricardogarim marked this pull request as ready for review February 18, 2026 17:23
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 10 files

@pierre-lehnen-rc pierre-lehnen-rc added this to the 8.2.0 milestone Feb 18, 2026
tassoevan
tassoevan previously approved these changes Feb 18, 2026
Co-authored-by: Kevin Aleman <kaleman960@gmail.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
apps/meteor/app/lib/server/functions/sendMessage.ts (1)

17-20: Consider exporting SendMessageOptions for callers that want explicit type annotations.

The type is currently unexported. Callers relying on structural typing work correctly today, but code outside this module that wants to declare a typed intermediate variable (e.g., const opts: SendMessageOptions = { upsert: true }) cannot import it. Given the PR explicitly introduces this type to be extended (e.g., filesToConfirm), exporting it now avoids a follow-up churn when new fields are added.

♻️ Proposed change
-type SendMessageOptions = {
+export type SendMessageOptions = {
 	upsert?: boolean;
 	previewUrls?: string[];
 };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/app/lib/server/functions/sendMessage.ts` around lines 17 - 20,
The SendMessageOptions type is currently internal; export it so external callers
can import and annotate variables (e.g., const opts: SendMessageOptions = {...})
and to make future extensions (like filesToConfirm) non-breaking; modify the
declaration of SendMessageOptions to be exported (export type SendMessageOptions
= {...}) in sendMessage.ts and keep the same fields (upsert, previewUrls) so
consumers can import the symbol and use it in signatures and intermediate
variables.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6622b09 and 23d831a.

📒 Files selected for processing (1)
  • apps/meteor/app/lib/server/functions/sendMessage.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/app/lib/server/functions/sendMessage.ts
🧠 Learnings (1)
📚 Learning: 2025-11-17T14:30:36.271Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 37491
File: packages/desktop-api/src/index.ts:17-27
Timestamp: 2025-11-17T14:30:36.271Z
Learning: In the Rocket.Chat desktop API (`packages/desktop-api/src/index.ts`), the `CustomNotificationOptions` type has an optional `id` field by design. Custom notifications dispatched without an ID cannot be closed programmatically using `closeCustomNotification`, and this is intentional.

Applied to files:

  • apps/meteor/app/lib/server/functions/sendMessage.ts
🧬 Code graph analysis (1)
apps/meteor/app/lib/server/functions/sendMessage.ts (2)
apps/meteor/app/lib/server/methods/sendMessage.ts (1)
  • sendMessage (135-174)
apps/meteor/server/services/messages/service.ts (1)
  • sendMessage (86-88)
⏰ 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). (2)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
🔇 Additional comments (1)
apps/meteor/app/lib/server/functions/sendMessage.ts (1)

225-226: LGTM — destructuring correctly preserves prior defaults.

upsert = false and the optional previewUrls match the old positional-argument semantics. TypeScript will reject any still-unconverted call site passing a raw boolean as the 4th argument at compile time. No unconverted call sites exist; executeSendMessage in the methods file is a different import and already calls sendMessage with the new destructured options signature.

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/meteor/app/lib/server/functions/sendMessage.ts`:
- Around line 17-20: The SendMessageOptions type is currently internal; export
it so external callers can import and annotate variables (e.g., const opts:
SendMessageOptions = {...}) and to make future extensions (like filesToConfirm)
non-breaking; modify the declaration of SendMessageOptions to be exported
(export type SendMessageOptions = {...}) in sendMessage.ts and keep the same
fields (upsert, previewUrls) so consumers can import the symbol and use it in
signatures and intermediate variables.

@ricardogarim ricardogarim added the stat: QA assured Means it has been tested and approved by a company insider label Feb 18, 2026
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Feb 18, 2026
@kodiakhq kodiakhq bot merged commit 42151e2 into develop Feb 18, 2026
44 checks passed
@kodiakhq kodiakhq bot deleted the refactor/sendMessage-options-object branch February 18, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants