Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct parameter order in afterSaveMessage to restore outgoing webhooks and related features #33295

Merged
merged 6 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rotten-rabbits-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

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.
7 changes: 6 additions & 1 deletion apps/meteor/app/autotranslate/server/autotranslate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);
}
}

Expand Down
7 changes: 6 additions & 1 deletion apps/meteor/app/integrations/server/triggers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
ricardogarim marked this conversation as resolved.
Show resolved Hide resolved
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');
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/irc/server/irc-bridge/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
ricardogarim marked this conversation as resolved.
Show resolved Hide resolved
callbacks.priority.LOW,
'irc-on-save-message',
);
Expand Down
7 changes: 6 additions & 1 deletion apps/meteor/ee/server/lib/engagementDashboard/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
};
Expand Down
Loading