Skip to content

Comments

chore: normalize urls extraction for messages#38795

Merged
ggazzo merged 18 commits intodevelopfrom
copilot/add-link-preview-for-schema-less-links
Feb 20, 2026
Merged

chore: normalize urls extraction for messages#38795
ggazzo merged 18 commits intodevelopfrom
copilot/add-link-preview-for-schema-less-links

Conversation

Copy link
Contributor

Copilot AI commented Feb 19, 2026

URL parsing for link previews was called externally in sendMessage and updateMessage functions. This moves the parseUrlsInMessage call into Message.beforeSave to consolidate message preparation logic.
https://rocketchat.atlassian.net/browse/ARCH-1970

Changes

  • IMessageService interface: Added optional previewUrls parameter to beforeSave method signature
  • MessageService.beforeSave: Now calls parseUrlsInMessage(message, previewUrls) internally after markdown parsing
  • sendMessage.ts & updateMessage.ts: Removed direct parseUrlsInMessage calls, now pass previewUrls to beforeSave

Example

Before:

parseUrlsInMessage(message, previewUrls);
message = await Message.beforeSave({ message, room, user });

After:

message = await Message.beforeSave({ message, room, user, previewUrls });

All message processing now flows through a single lifecycle point. Existing callers without previewUrls continue to work unchanged.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Feb 19, 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 19, 2026

⚠️ No Changeset found

Latest commit: e5a3f47

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

Copilot AI changed the title [WIP] Add link preview for links without schema Add link preview support for schema-less URLs Feb 19, 2026
Copilot AI requested a review from ggazzo February 19, 2026 05:14
@ggazzo ggazzo changed the title Add link preview support for schema-less URLs chore: normalize schema extraction for messages Feb 19, 2026
@ggazzo ggazzo marked this pull request as ready for review February 19, 2026 16:33
@ggazzo ggazzo added this to the 8.2.0 milestone Feb 19, 2026
@ggazzo ggazzo changed the title chore: normalize schema extraction for messages chore: normalize urls extraction for messages Feb 19, 2026
@ggazzo ggazzo added the stat: QA assured Means it has been tested and approved by a company insider label Feb 19, 2026
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Feb 19, 2026
@ggazzo
Copy link
Member

ggazzo commented Feb 19, 2026

/jira ARCH-1935

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.

2 issues found across 5 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/meteor/app/lib/server/functions/extractUrlsFromMessageAST.ts">

<violation number="1" location="apps/meteor/app/lib/server/functions/extractUrlsFromMessageAST.ts:23">
P2: Protocol-relative URLs from LINK nodes are pushed without normalization, but tests expect `//` links to be converted to `https://`. Normalize before pushing so schema-less links generate previews correctly.</violation>
</file>

<file name="apps/meteor/app/lib/server/functions/parseUrlsInMessage.ts">

<violation number="1" location="apps/meteor/app/lib/server/functions/parseUrlsInMessage.ts:32">
P2: This conditional skips clearing message.urls when no URLs are found, leaving stale URLs on edits that remove links. Assign message.urls even for an empty list so old previews are cleared.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.55%. Comparing base (260e9af) to head (e5a3f47).
⚠️ Report is 22 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #38795      +/-   ##
===========================================
- Coverage    70.58%   70.55%   -0.03%     
===========================================
  Files         3182     3182              
  Lines       112442   112483      +41     
  Branches     20378    20376       -2     
===========================================
- Hits         79365    79361       -4     
- Misses       31025    31071      +46     
+ Partials      2052     2051       -1     
Flag Coverage Δ
e2e 60.39% <100.00%> (+<0.01%) ⬆️
e2e-api 48.85% <100.00%> (-0.02%) ⬇️
unit 71.47% <100.00%> (-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.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 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 -1.8KiB
queue-worker-service 134MiB 134MiB -302B
ddp-streamer-service 128MiB 128MiB -2.3KiB
account-service 115MiB 115MiB +409B
authorization-service 112MiB 112MiB -676B
presence-service 112MiB 112MiB -362B

📊 Historical Trend

---
config:
  theme: "dark"
  xyChart:
    width: 900
    height: 400
---
xychart
  title "Image Size Evolution by Service (Last 30 Days + This PR)"
  x-axis ["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 23:15", "02/19 23:23", "02/20 03:13", "02/20 04:00 (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-38795
  • Baseline: develop
  • Timestamp: 2026-02-20 04:00:43 UTC
  • Historical data points: 30

Updated: Fri, 20 Feb 2026 04:00:43 GMT

@ggazzo ggazzo force-pushed the copilot/add-link-preview-for-schema-less-links branch from b579743 to 0747a55 Compare February 19, 2026 19:06
@ggazzo ggazzo requested a review from a team as a code owner February 19, 2026 19:35
Copilot AI and others added 8 commits February 19, 2026 18:05
Co-authored-by: ggazzo <5263975+ggazzo@users.noreply.github.com>
Co-authored-by: ggazzo <5263975+ggazzo@users.noreply.github.com>
Co-authored-by: ggazzo <5263975+ggazzo@users.noreply.github.com>
…or URL extraction from message AST. Update parseUrlsInMessage to utilize new URL extraction logic.
Copilot AI and others added 2 commits February 19, 2026 22:05
Co-authored-by: ggazzo <5263975+ggazzo@users.noreply.github.com>
Co-authored-by: ggazzo <5263975+ggazzo@users.noreply.github.com>
Copilot AI changed the title chore: normalize urls extraction for messages Move URL parsing into Message.beforeSave lifecycle hook Feb 19, 2026
… and message processing. Update insertMessage to assign parsed URLs directly to the message object. Enhance parseUrlsInMessage to return structured URL data and clean up unused code. Adjust MessageService to utilize the updated URL parsing logic.
@dionisio-bot dionisio-bot bot removed the stat: ready to merge PR tested and approved waiting for merge label Feb 20, 2026
@ggazzo ggazzo changed the title Move URL parsing into Message.beforeSave lifecycle hook chore: normalize urls extraction for messages Feb 20, 2026
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Feb 20, 2026
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.

2 issues found across 5 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/meteor/server/services/messages/hooks/BeforeSaveJumpToMessage.ts">

<violation number="1" location="apps/meteor/server/services/messages/hooks/BeforeSaveJumpToMessage.ts:141">
P2: Remove debug console logging from this server-side hook to avoid leaking message data and adding noisy logs in production.

(Based on your team's feedback about avoiding console statements in production code.) [FEEDBACK_USED]</violation>
</file>

<file name="apps/meteor/server/services/messages/service.ts">

<violation number="1" location="apps/meteor/server/services/messages/service.ts:239">
P2: Unconditionally assigning `message.urls` breaks the `parseUrls=false` behavior by adding an empty `urls` property. Keep `urls` unset when `parseUrls` is explicitly false.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

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.

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/meteor/app/lib/server/functions/parseUrlsInMessage.ts">

<violation number="1" location="apps/meteor/app/lib/server/functions/parseUrlsInMessage.ts:16">
P2: `parseUrlsInMessage` no longer honors `message.parseUrls === false`, so callers that explicitly disable URL parsing (e.g., webhook payloads with attachments) will still have URLs extracted. This is a behavioral regression; add the guard back so `parseUrls` is respected.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

…sage object. Update MessageService to always parse URLs, simplifying the logic by removing the conditional check for parseUrls.
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.

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/meteor/server/services/messages/service.ts">

<violation number="1" location="apps/meteor/server/services/messages/service.ts:239">
P2: The `parseUrls` flag is no longer honored. `message.urls` is now set even when callers explicitly send `parseUrls: false`, which breaks the documented API behavior and existing tests expecting no `urls` field.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

…lag in beforeSave calls, enhancing URL processing flexibility.
@ggazzo ggazzo force-pushed the copilot/add-link-preview-for-schema-less-links branch from 435a8d4 to e4a7ee9 Compare February 20, 2026 03:08
@ggazzo
Copy link
Member

ggazzo commented Feb 20, 2026

@sampaiodiego fyi

@ggazzo ggazzo merged commit 17be0c1 into develop Feb 20, 2026
44 checks passed
@ggazzo ggazzo deleted the copilot/add-link-preview-for-schema-less-links branch February 20, 2026 16:48
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.

3 participants