From 23f610a647c956b7ffe18701b6444033dd1425df Mon Sep 17 00:00:00 2001 From: Lucas Pelegrino Date: Mon, 9 Dec 2024 11:47:01 -0300 Subject: [PATCH 1/4] fix: replaces return for continue inside the loop --- apps/meteor/app/slackbridge/server/RocketAdapter.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/meteor/app/slackbridge/server/RocketAdapter.js b/apps/meteor/app/slackbridge/server/RocketAdapter.js index 245e28c72203..bf94b6229c4e 100644 --- a/apps/meteor/app/slackbridge/server/RocketAdapter.js +++ b/apps/meteor/app/slackbridge/server/RocketAdapter.js @@ -134,22 +134,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 From 11ad11e0ff29c4d424d52a3a2f7964b0ab1650a6 Mon Sep 17 00:00:00 2001 From: Lucas Pelegrino Date: Mon, 9 Dec 2024 12:56:58 -0300 Subject: [PATCH 2/4] chore: adds changeset --- .changeset/lovely-beers-argue.md | 5 +++++ 1 file changed, 5 insertions(+) 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 From 4f901297df21d7d5d4df0f5cb6acee75fbc01d4f Mon Sep 17 00:00:00 2001 From: Lucas Pelegrino Date: Tue, 10 Dec 2024 12:22:18 -0300 Subject: [PATCH 3/4] refactor: defines new object instead of modifying rocketMessage directly --- apps/meteor/app/slackbridge/server/RocketAdapter.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/apps/meteor/app/slackbridge/server/RocketAdapter.js b/apps/meteor/app/slackbridge/server/RocketAdapter.js index bf94b6229c4e..7b50dcb24d9a 100644 --- a/apps/meteor/app/slackbridge/server/RocketAdapter.js +++ b/apps/meteor/app/slackbridge/server/RocketAdapter.js @@ -207,10 +207,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}` }); } } From b4bbbcb3f68b71595b028b968c2d91d28a459f80 Mon Sep 17 00:00:00 2001 From: Lucas Pelegrino Date: Thu, 12 Dec 2024 16:00:43 -0300 Subject: [PATCH 4/4] fix: replaces instances of return usage inside await loops --- apps/meteor/app/slackbridge/server/RocketAdapter.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/meteor/app/slackbridge/server/RocketAdapter.js b/apps/meteor/app/slackbridge/server/RocketAdapter.js index 7b50dcb24d9a..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) { @@ -264,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); @@ -272,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); @@ -286,7 +287,7 @@ export default class RocketAdapter { if (!rocketUserCreator) { rocketLogger.error({ msg: 'Could not fetch room creator information', creator: slackChannel.creator }); - return; + continue; } try {