Skip to content

Commit

Permalink
Merge pull request #408 from matrix-org/hs/no-update-botid-userid
Browse files Browse the repository at this point in the history
Ensure user's profile is not modified when they delete a bot
  • Loading branch information
Half-Shot authored May 11, 2020
2 parents 27c7c0a + 1be593d commit 7a56c1b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/408.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bridge will no longer update user's displayname with a bots name when a bot is modified
12 changes: 10 additions & 2 deletions src/SlackGhost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 7a56c1b

Please sign in to comment.