From 15a7b3cd5ceb977789144c2fd8ba0d58833267c2 Mon Sep 17 00:00:00 2001 From: Ricardo Garim Date: Mon, 16 Sep 2024 12:38:30 -0300 Subject: [PATCH 1/5] fix: correct parameter order in callbackHandler --- apps/meteor/app/autotranslate/server/autotranslate.ts | 7 ++++++- apps/meteor/app/integrations/server/triggers.ts | 7 ++++++- apps/meteor/ee/server/lib/engagementDashboard/startup.ts | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/apps/meteor/app/autotranslate/server/autotranslate.ts b/apps/meteor/app/autotranslate/server/autotranslate.ts index f3c6d9e55fdb..23e1b189a792 100644 --- a/apps/meteor/app/autotranslate/server/autotranslate.ts +++ b/apps/meteor/app/autotranslate/server/autotranslate.ts @@ -113,7 +113,12 @@ export class TranslationProviderRegistry { return; } - callbacks.add('afterSaveMessage', provider.translateMessage.bind(provider), callbacks.priority.MEDIUM, 'autotranslate'); + callbacks.add( + 'afterSaveMessage', + (message, { room }) => provider.translateMessage(message, { room }), + callbacks.priority.MEDIUM, + 'autotranslate', + ); } } diff --git a/apps/meteor/app/integrations/server/triggers.ts b/apps/meteor/app/integrations/server/triggers.ts index cdf8acda6a21..64b95827645f 100644 --- a/apps/meteor/app/integrations/server/triggers.ts +++ b/apps/meteor/app/integrations/server/triggers.ts @@ -8,7 +8,12 @@ const callbackHandler = function _callbackHandler(eventType: string) { }; }; -callbacks.add('afterSaveMessage', callbackHandler('sendMessage'), callbacks.priority.LOW, 'integrations-sendMessage'); +callbacks.add( + 'afterSaveMessage', + (message, { room }) => callbackHandler('sendMessage')(message, room), + callbacks.priority.LOW, + 'integrations-sendMessage', +); callbacks.add('afterCreateChannel', callbackHandler('roomCreated'), callbacks.priority.LOW, 'integrations-roomCreated'); callbacks.add('afterCreatePrivateGroup', callbackHandler('roomCreated'), callbacks.priority.LOW, 'integrations-roomCreated'); callbacks.add('afterCreateUser', callbackHandler('userCreated'), callbacks.priority.LOW, 'integrations-userCreated'); diff --git a/apps/meteor/ee/server/lib/engagementDashboard/startup.ts b/apps/meteor/ee/server/lib/engagementDashboard/startup.ts index 159b121f7043..415e0323d525 100644 --- a/apps/meteor/ee/server/lib/engagementDashboard/startup.ts +++ b/apps/meteor/ee/server/lib/engagementDashboard/startup.ts @@ -3,7 +3,12 @@ import { fillFirstDaysOfMessagesIfNeeded, handleMessagesDeleted, handleMessagesS import { fillFirstDaysOfUsersIfNeeded, handleUserCreated } from './users'; export const attachCallbacks = (): void => { - callbacks.add('afterSaveMessage', handleMessagesSent, callbacks.priority.MEDIUM, 'engagementDashboard.afterSaveMessage'); + callbacks.add( + 'afterSaveMessage', + (message, { room }) => handleMessagesSent(message, { room }), + callbacks.priority.MEDIUM, + 'engagementDashboard.afterSaveMessage', + ); callbacks.add('afterDeleteMessage', handleMessagesDeleted, callbacks.priority.MEDIUM, 'engagementDashboard.afterDeleteMessage'); callbacks.add('afterCreateUser', handleUserCreated, callbacks.priority.MEDIUM, 'engagementDashboard.afterCreateUser'); }; From 48d9e429e9fbcf32fe64f35edddc3c4140fdbb64 Mon Sep 17 00:00:00 2001 From: Ricardo Garim Date: Mon, 16 Sep 2024 13:24:02 -0300 Subject: [PATCH 2/5] add changeset --- .changeset/rotten-rabbits-brush.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/rotten-rabbits-brush.md diff --git a/.changeset/rotten-rabbits-brush.md b/.changeset/rotten-rabbits-brush.md new file mode 100644 index 000000000000..4eff9fac38a6 --- /dev/null +++ b/.changeset/rotten-rabbits-brush.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +Fixes the parameter order in callbackHandler and updates the integration logic, autotranslate, and the EngagementDashboard.afterSaveMessage trigger to correctly pass the room parameter. This resolves the malfunction in outgoing webhooks and other use cases impacted by the format change introduced in version 6.12.0. From e294569f768fc7160b6c9a28eb846254b7ec4a53 Mon Sep 17 00:00:00 2001 From: Ricardo Garim Date: Mon, 16 Sep 2024 13:48:51 -0300 Subject: [PATCH 3/5] fix: correct parameter order on irc-brige --- apps/meteor/app/irc/server/irc-bridge/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/meteor/app/irc/server/irc-bridge/index.js b/apps/meteor/app/irc/server/irc-bridge/index.js index 09b7a3568362..a1221dae15c2 100644 --- a/apps/meteor/app/irc/server/irc-bridge/index.js +++ b/apps/meteor/app/irc/server/irc-bridge/index.js @@ -209,7 +209,7 @@ class Bridge { // Chatting callbacks.add( 'afterSaveMessage', - this.onMessageReceived.bind(this, 'local', 'onSaveMessage'), + (message, { room }) => this.onMessageReceived.bind(this, 'local', 'onSaveMessage')(message, room), callbacks.priority.LOW, 'irc-on-save-message', ); From 337d8911c79e8fb381f64f75a0b4087af25aef2c Mon Sep 17 00:00:00 2001 From: Ricardo Garim Date: Mon, 16 Sep 2024 16:49:24 -0300 Subject: [PATCH 4/5] change changeset message --- .changeset/rotten-rabbits-brush.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/rotten-rabbits-brush.md b/.changeset/rotten-rabbits-brush.md index 4eff9fac38a6..916f4cc8034a 100644 --- a/.changeset/rotten-rabbits-brush.md +++ b/.changeset/rotten-rabbits-brush.md @@ -2,4 +2,4 @@ '@rocket.chat/meteor': patch --- -Fixes the parameter order in callbackHandler and updates the integration logic, autotranslate, and the EngagementDashboard.afterSaveMessage trigger to correctly pass the room parameter. This resolves the malfunction in outgoing webhooks and other use cases impacted by the format change introduced in version 6.12.0. +Resolves the issue where outgoing integrations failed to trigger after the version 6.12.0 upgrade by correcting the parameter order from the `afterSaveMessage` callback to listener functions. This ensures the correct room information is passed, restoring the functionality of outgoing webhooks, IRC bridge, Autotranslate, and Engagement Dashboard. From 85077f37f84764a22fc498bc7a12108e96e55e2d Mon Sep 17 00:00:00 2001 From: Ricardo Garim Date: Tue, 17 Sep 2024 08:18:58 -0300 Subject: [PATCH 5/5] change irc-bridge call params --- apps/meteor/app/irc/server/irc-bridge/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/meteor/app/irc/server/irc-bridge/index.js b/apps/meteor/app/irc/server/irc-bridge/index.js index a1221dae15c2..bc5b4f0bc33f 100644 --- a/apps/meteor/app/irc/server/irc-bridge/index.js +++ b/apps/meteor/app/irc/server/irc-bridge/index.js @@ -209,7 +209,7 @@ class Bridge { // Chatting callbacks.add( 'afterSaveMessage', - (message, { room }) => this.onMessageReceived.bind(this, 'local', 'onSaveMessage')(message, room), + (message, { room }) => this.onMessageReceived('local', 'onSaveMessage', message, room), callbacks.priority.LOW, 'irc-on-save-message', );