From 7bafe0390ea5f05084215c977c5604e09a605aa8 Mon Sep 17 00:00:00 2001 From: Lucas Pelegrino Date: Tue, 17 Dec 2024 18:11:19 -0300 Subject: [PATCH] fix: Messages not being processed for all slack servers (#34148) --- .changeset/lovely-beers-argue.md | 5 ++++ .../app/slackbridge/server/RocketAdapter.js | 23 +++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 .changeset/lovely-beers-argue.md diff --git a/.changeset/lovely-beers-argue.md b/.changeset/lovely-beers-argue.md new file mode 100644 index 000000000000..a01a97535e48 --- /dev/null +++ b/.changeset/lovely-beers-argue.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/meteor": patch +--- + +Fixes messages not being processed for all slack servers diff --git a/apps/meteor/app/slackbridge/server/RocketAdapter.js b/apps/meteor/app/slackbridge/server/RocketAdapter.js index 245e28c72203..70418d407443 100644 --- a/apps/meteor/app/slackbridge/server/RocketAdapter.js +++ b/apps/meteor/app/slackbridge/server/RocketAdapter.js @@ -62,8 +62,9 @@ export default class RocketAdapter { try { if (!slack.getSlackChannel(rocketMessageDeleted.rid)) { // This is on a channel that the rocket bot is not subscribed on this slack server - return; + continue; } + rocketLogger.debug('onRocketMessageDelete', rocketMessageDeleted); await slack.postDeleteMessage(rocketMessageDeleted); } catch (err) { @@ -134,22 +135,23 @@ export default class RocketAdapter { try { if (!slack.getSlackChannel(rocketMessage.rid)) { // This is on a channel that the rocket bot is not subscribed - return; + continue; } rocketLogger.debug('onRocketMessage', rocketMessage); if (rocketMessage.editedAt) { // This is an Edit Event await this.processMessageChanged(rocketMessage, slack); - return rocketMessage; + continue; } // Ignore messages originating from Slack if (rocketMessage._id.indexOf('slack-') === 0) { - return rocketMessage; + continue; } if (rocketMessage.file) { - return this.processFileShare(rocketMessage, slack); + await this.processFileShare(rocketMessage, slack); + continue; } // A new message from Rocket.Chat @@ -206,10 +208,7 @@ export default class RocketAdapter { } } - const message = `${text} ${fileName}`; - - rocketMessage.msg = message; - await slack.postMessage(slack.getSlackChannel(rocketMessage.rid), rocketMessage); + await slack.postMessage(slack.getSlackChannel(rocketMessage.rid), { ...rocketMessage, msg: `${text} ${fileName}` }); } } @@ -266,7 +265,7 @@ export default class RocketAdapter { for await (const slack of this.slackAdapters) { if (addedRoom) { - return; + continue; } const slackChannel = await slack.slackAPI.getRoomInfo(slackChannelID); @@ -274,7 +273,7 @@ export default class RocketAdapter { const members = await slack.slackAPI.getMembers(slackChannelID); if (!members) { rocketLogger.error('Could not fetch room members'); - return; + continue; } const rocketRoom = await Rooms.findOneByName(slackChannel.name); @@ -288,7 +287,7 @@ export default class RocketAdapter { if (!rocketUserCreator) { rocketLogger.error({ msg: 'Could not fetch room creator information', creator: slackChannel.creator }); - return; + continue; } try {