diff --git a/changelog.d/408.bugfix b/changelog.d/408.bugfix new file mode 100644 index 00000000..629534f6 --- /dev/null +++ b/changelog.d/408.bugfix @@ -0,0 +1 @@ +Bridge will no longer update user's displayname with a bots name when a bot is modified \ No newline at end of file diff --git a/src/SlackGhost.ts b/src/SlackGhost.ts index 8880cb62..3f095e1d 100644 --- a/src/SlackGhost.ts +++ b/src/SlackGhost.ts @@ -155,7 +155,11 @@ export class SlackGhost { let displayName = message.username || message.user_name; if (room.SlackClient) { // We can be smarter if we have the bot. - if (message.bot_id) { + if (message.bot_id && message.user_id) { + // In the case of operations on bots, we will have both a bot_id and a user_id. + // Ignore updating the displayname in this case. + return; + } else if (message.bot_id) { displayName = await this.getBotName(message.bot_id, room.SlackClient); } else if (message.user_id) { displayName = await this.getDisplayname(room.SlackClient); @@ -245,7 +249,11 @@ export class SlackGhost { } let avatarUrl; let hash: string|undefined; - if (message.bot_id) { + if (message.bot_id && message.user_id) { + // In the case of operations on bots, we will have both a bot_id and a user_id. + // Ignore updating the displayname in this case. + return; + } else if (message.bot_id) { avatarUrl = await this.getBotAvatarUrl(message.bot_id, room.SlackClient); hash = avatarUrl; } else if (message.user_id) {