Skip to content

Commit

Permalink
fix: Messages not being processed for all slack servers (#34148)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-a-pelegrino authored Dec 17, 2024
1 parent 0fcdc3e commit 7bafe03
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/lovely-beers-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixes messages not being processed for all slack servers
23 changes: 11 additions & 12 deletions apps/meteor/app/slackbridge/server/RocketAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}` });
}
}

Expand Down Expand Up @@ -266,15 +265,15 @@ export default class RocketAdapter {

for await (const slack of this.slackAdapters) {
if (addedRoom) {
return;
continue;
}

const slackChannel = await slack.slackAPI.getRoomInfo(slackChannelID);
if (slackChannel) {
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);
Expand All @@ -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 {
Expand Down

0 comments on commit 7bafe03

Please sign in to comment.