chore: Refactor/migrate insertMessage to service layer
Proposed changes (including videos or screenshots)
Adds insertMessage to the IMessageService interface in @rocket.chat/core-services
Implements the method on MessageService, delegating to the existing insertMessage function
Removes the direct file import in MessageConverter in favour of consuming Message.insertMessage from @rocket.chat/core-services
Updates the unit test stub to target the new @rocket.chat/core-services import path
Currently, MessageConverter was importing insertMessage directly from an internal function file, bypassing the service layer. This change routes the call through the IMessageService interface, consistent with how the rest of the codebase accesses message operations (e.g. Message.sendMessageWithValidation, Message.deleteMessage). It also fulfils the // TODO: remove and move to Message.Service note on the original function.
Issue(s)
Steps to test or reproduce
Existing unit tests in messageConverter.spec.ts pass with the updated stub path
No TypeScript errors in the affected packages (core-services, apps/meteor)
Further comments
Summary by CodeRabbit
- Refactor
- Routed imported message persistence through core services for more consistent message handling across the app.
- Added a server-side message insertion method to the message service (supports optional upsert), used by the importer.
- Tests
- Updated unit test setup to stub the new core-service-based insertion flow.
- Chores
- Removed an obsolete TODO comment related to message insertion handling.