Skip to content

Commit 24047c4

Browse files
author
Stefan Warnat
committed
Make it possible to use avatar_url and legacy avatarUrl
1 parent bf45537 commit 24047c4

File tree

2 files changed

+3
-25
lines changed

2 files changed

+3
-25
lines changed

src/WebhookBridge.js

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -126,31 +126,6 @@ class WebhookBridge {
126126
*/
127127
_updateBotProfile() {
128128
return;
129-
LogService.info("WebhookBridge", "Updating appearance of bridge bot");
130-
131-
const desiredDisplayName = this._config.webhookBot.appearance.displayName || "Webhook Bridge";
132-
const desiredAvatarUrl = this._config.webhookBot.appearance.avatar_url || "http://i.imgur.com/IDOBtEJ.png"; // webhook icon
133-
134-
const botIntent = this.getBotIntent();
135-
136-
WebhookStore.getAccountData('bridge').then(botProfile => {
137-
let avatar_url = botProfile.avatar_url;
138-
if (!avatar_url || avatar_url !== desiredAvatarUrl) {
139-
util.uploadContentFromUrl(this._bridge, desiredAvatarUrl, botIntent).then(mxcUrl => {
140-
LogService.verbose("WebhookBridge", "Avatar MXC URL = " + mxcUrl);
141-
LogService.info("WebhookBridge", "Updating avatar for bridge bot");
142-
botIntent.setAvatarUrl(mxcUrl);
143-
botProfile.avatar_url = desiredAvatarUrl;
144-
WebhookStore.setAccountData('bridge', botProfile);
145-
});
146-
}
147-
botIntent.getProfileInfo(this._bridge.getBot().getUserId(), 'displayname').then(profile => {
148-
if (profile.displayname != desiredDisplayName) {
149-
LogService.info("WebhookBridge", "Updating display name from '" + profile.displayname + "' to '" + desiredDisplayName + "'");
150-
botIntent.setDisplayName(desiredDisplayName);
151-
}
152-
});
153-
});
154129
}
155130

156131
/**
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
module.exports = (webhook, matrix) => {
22
if (!matrix.sender.avatar_url && webhook.avatar_url)
33
matrix.sender.avatar_url = webhook.avatar_url;
4+
5+
if (!matrix.sender.avatar_url && webhook.avatarUrl)
6+
matrix.sender.avatar_url = webhook.avatarUrl;
47
};

0 commit comments

Comments
 (0)