Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

feat: add trigger Message Edited and Message Deleted for integration outgoing

Open zscontributor opened this issue 7 months ago β€’ 3 comments

Proposed changes (including videos or screenshots)

When a user edits or deletes a message, Rocket.Chat will also send the corresponding information through the webhook (similar to the Message Sent trigger). If an external system wants to synchronize message data with Rocket.Chat, it can use the message_id to handle all related logic for that specific message.

  1. add Trigger Message Edited image

  2. add Trigger Message Deleted image

  3. Rocket.chat send data via webhook when trigger Message Edited image

  4. Rocket.chat send data via webhook when trigger Message Deleted image

Issue(s)

https://github.com/RocketChat/feature-requests/issues/952

Steps to test or reproduce

Further comments

zscontributor avatar Jun 05 '25 09:06 zscontributor

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

dionisio-bot[bot] avatar Jun 05 '25 09:06 dionisio-bot[bot]

πŸ¦‹ Changeset detected

Latest commit: 1fb779c3b87103c10c8a47b4e3be94408e8dc6fc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 41 packages
Name Type
@rocket.chat/meteor Major
@rocket.chat/core-typings Major
@rocket.chat/rest-typings Major
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/freeswitch Patch
@rocket.chat/fuselage-ui-kit Major
@rocket.chat/gazzodown Major
@rocket.chat/http-router Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-avatar Major
@rocket.chat/ui-client Major
@rocket.chat/ui-contexts Major
@rocket.chat/web-ui-registration Major
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/license Patch
@rocket.chat/media-calls Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/models Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-video-conf Major
@rocket.chat/ui-voip Major
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch

Not sure what this means? Click here to learn what changesets are.

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

changeset-bot[bot] avatar Jun 05 '25 09:06 changeset-bot[bot]

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jun 05 '25 09:06 CLAassistant

Walkthrough

Adds two outgoing trigger events, messageEdited and messageDeleted: event definitions, type updates, trigger handler mapping, callback registrations for edit/delete, invocation on delete, translations, and unit + E2E tests covering both flows.

Changes

Cohort / File(s) Summary
Changeset & Docs
\.changeset/feat-trigger-outgoing-add-edit-and-delete-events.md
Adds changeset documenting the feature.
Type Definitions
packages/core-typings/src/IIntegration.ts
Extends OutgoingIntegrationEvent to include 'messageEdited' and 'messageDeleted'.
Event Configuration & I18n
apps/meteor/app/integrations/lib/outgoingEvents.ts, packages/i18n/src/locales/en.i18n.json
Adds outgoing event entries and English translations for messageEdited and messageDeleted.
Trigger Handler & Mapping
apps/meteor/app/integrations/server/lib/triggerHandler.ts
Maps event args for messageEdited/messageDeleted, adds optional isDeleted?: boolean, guards outgoingEvents access, and includes message/room/user in payloads; sets isEdited/isDeleted appropriately.
Trigger Registrations
apps/meteor/app/integrations/server/triggers.ts
Updates afterSaveMessage signature (typed IMessage), triggers messageEdited when appropriate, and registers afterDeleteMessage to emit messageDeleted.
Delete Flow Invocation
apps/meteor/app/lib/server/functions/deleteMessage.ts
Invokes triggerHandler.executeTriggers('messageDeleted', deletedMsg, room, user) when a message is deleted.
Unit Tests
apps/meteor/tests/unit/server/integrations/triggerHandler.spec.ts, apps/meteor/tests/unit/server/integrations/triggers.spec.ts
Adds unit tests covering trigger execution, argument mapping, isEdited/isDeleted flags, disabled integrations, multiple integrations, and error/edge cases for both events.
End-to-End Tests
apps/meteor/tests/e2e/integrations/message-triggers.spec.ts
Adds E2E tests that create integrations for edit/delete, exercise edit and delete flows via API/UI, and validate integration lifecycle (enable/disable/delete).

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant App as Rocket.Chat App
    participant Callbacks as Callback Registry
    participant Handler as TriggerHandler
    participant Integration as Outgoing Integration

    rect rgb(200,230,255)
    Note over User,Integration: Message Edited flow
    User->>App: Edit message
    App->>Callbacks: afterSaveMessage(message, {room})
    Callbacks->>Handler: executeTriggers('messageEdited', message, room, editor)
    Handler->>Handler: mapEventArgsToData('messageEdited')
    Handler->>Integration: HTTP POST (payload with isEdited=true, message, user, room)
    Integration-->>Handler: 2xx/response
    end

    rect rgb(230,200,255)
    Note over User,Integration: Message Deleted flow
    User->>App: Delete message
    App->>Callbacks: afterDeleteMessage(message, room)
    Callbacks->>Handler: executeTriggers('messageDeleted', message, room, deleter)
    Handler->>Handler: mapEventArgsToData('messageDeleted')
    Handler->>Integration: HTTP POST (payload with isDeleted=true, message, user, room)
    Integration-->>Handler: 2xx/response
    end

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Review mapping logic in triggerHandler.ts for accurate fields (isEdited/isDeleted, message text vs attachments).
  • Verify triggers.ts callback conditions (editedAt/editedBy handling) and the new afterDeleteMessage registration.
  • Confirm delete flow integration in deleteMessage.ts and correct user attribution.
  • Inspect added tests for robustness and whether any private method overrides could mask issues.

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • tassoevan
  • d-gubert
  • lucas-a-pelegrino

Poem

🐰 A tap, a tweak, a vanished lineβ€”
Webhooks hop and bells align,
Edited flags and deleted trace,
Triggered tales set forth apace,
Tests nibble carrots, code feels fine. πŸ₯•

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
βœ… Passed checks (2 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title accurately describes the main change: adding two new outgoing integration triggers for message edited and deleted events, which aligns with all substantial changes across multiple files.
✨ Finishing touches
πŸ§ͺ Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

πŸ“œ Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 89c273ae1beef4413aa2c2d2fbc538efb8958721 and 1fb779c3b87103c10c8a47b4e3be94408e8dc6fc.

πŸ“’ Files selected for processing (1)
  • packages/i18n/src/locales/en.i18n.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/i18n/src/locales/en.i18n.json

[!TIP]

πŸ“ Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests β€” including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. πŸ“ Description β€” Summarize the main change in 50–60 words, explaining what was done.
  2. πŸ““ References β€” List relevant issues, discussions, documentation, or related PRs.
  3. πŸ“¦ Dependencies & Requirements β€” Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. πŸ“Š Contributor Summary β€” Include a Markdown table showing contributions: | Contributor | Lines Added | Lines Removed | Files Changed |
  5. βœ”οΈ Additional Notes β€” Add any extra reviewer context. Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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.

coderabbitai[bot] avatar Nov 19 '25 02:11 coderabbitai[bot]

Please review and merge this PR!

zscontributor avatar Nov 19 '25 02:11 zscontributor