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: Messages not being processed for all slack servers #34148

Merged
merged 7 commits into from
Dec 17, 2024
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);
lucas-a-pelegrino marked this conversation as resolved.
Show resolved Hide resolved
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;
lucas-a-pelegrino marked this conversation as resolved.
Show resolved Hide resolved
}

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
Loading