Skip to content

Commit bf45537

Browse files
author
Stefan Warnat
committed
Merge branch 'master' of https://github.com/bhopmann/matrix-appservice-webhooks into bhopmann-master
# Conflicts: # src/processing/layers/avatar/slack_icon_emoji.js
2 parents af07a25 + 85dbd16 commit bf45537

File tree

11 files changed

+25
-25
lines changed

11 files changed

+25
-25
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Invite the webhook bridge to your room (`@_webhook:t2bot.io`) and send the messa
1616
"text": "Hello world!",
1717
"format": "plain",
1818
"displayName": "My Cool Webhook",
19-
"avatarUrl": "http://i.imgur.com/IDOBtEJ.png"
19+
"avatar_url": "http://i.imgur.com/IDOBtEJ.png"
2020
}
2121
```
2222

config/sample.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ webhookBot:
1515
# Appearance options for the Matrix bot
1616
appearance:
1717
displayName: "Webhook Bridge"
18-
avatarUrl: "http://i.imgur.com/IDOBtEJ.png" # webhook icon
18+
avatar_url: "http://i.imgur.com/IDOBtEJ.png" # webhook icon
1919

2020
# Provisioning API options
2121
provisioning:

config/schema.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ properties:
3030
properties:
3131
displayName:
3232
type: "string"
33-
avatarUrl:
33+
avatar_url:
3434
type: "string"
3535
logging:
3636
type: "object"

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const cli = new Cli({
2323
localpart: "_webhook",
2424
appearance: {
2525
displayName: "Webhook Bridge",
26-
avatarUrl: "http://i.imgur.com/IDOBtEJ.png" // webhook bridge icon
26+
avatar_url: "http://i.imgur.com/IDOBtEJ.png" // webhook bridge icon
2727
}
2828
},
2929
web: {

src/WebhookBridge.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,18 @@ class WebhookBridge {
129129
LogService.info("WebhookBridge", "Updating appearance of bridge bot");
130130

131131
const desiredDisplayName = this._config.webhookBot.appearance.displayName || "Webhook Bridge";
132-
const desiredAvatarUrl = this._config.webhookBot.appearance.avatarUrl || "http://i.imgur.com/IDOBtEJ.png"; // webhook icon
132+
const desiredAvatarUrl = this._config.webhookBot.appearance.avatar_url || "http://i.imgur.com/IDOBtEJ.png"; // webhook icon
133133

134134
const botIntent = this.getBotIntent();
135135

136136
WebhookStore.getAccountData('bridge').then(botProfile => {
137-
let avatarUrl = botProfile.avatarUrl;
138-
if (!avatarUrl || avatarUrl !== desiredAvatarUrl) {
137+
let avatar_url = botProfile.avatar_url;
138+
if (!avatar_url || avatar_url !== desiredAvatarUrl) {
139139
util.uploadContentFromUrl(this._bridge, desiredAvatarUrl, botIntent).then(mxcUrl => {
140140
LogService.verbose("WebhookBridge", "Avatar MXC URL = " + mxcUrl);
141141
LogService.info("WebhookBridge", "Updating avatar for bridge bot");
142142
botIntent.setAvatarUrl(mxcUrl);
143-
botProfile.avatarUrl = desiredAvatarUrl;
143+
botProfile.avatar_url = desiredAvatarUrl;
144144
WebhookStore.setAccountData('bridge', botProfile);
145145
});
146146
}
@@ -162,8 +162,8 @@ class WebhookBridge {
162162
return WebhookStore.getAccountData(intent.getClient().credentials.userId).then(botProfile => {
163163
const promises = [];
164164

165-
let avatarUrl = botProfile.avatarUrl;
166-
if ((!avatarUrl || avatarUrl !== desiredAvatarUrl) && desiredAvatarUrl) {
165+
let avatar_url = botProfile.avatar_url;
166+
if ((!avatar_url || avatar_url !== desiredAvatarUrl) && desiredAvatarUrl) {
167167
let uploadPromise = Promise.resolve(desiredAvatarUrl);
168168
if (!desiredAvatarUrl.startsWith("mxc://"))
169169
uploadPromise = util.uploadContentFromUrl(this._bridge, desiredAvatarUrl, this.getBotIntent());
@@ -172,7 +172,7 @@ class WebhookBridge {
172172
LogService.verbose("WebhookBridge", "Avatar MXC URL = " + mxcUrl);
173173
LogService.info("WebhookBridge", "Updating avatar for " + intent.getClient().credentials.userId);
174174
return intent.setAvatarUrl(mxcUrl).then(() => {
175-
botProfile.avatarUrl = desiredAvatarUrl;
175+
botProfile.avatar_url = desiredAvatarUrl;
176176
WebhookStore.setAccountData(intent.getClient().credentials.userId, botProfile);
177177
});
178178
}));

src/processing/WebhookReceiver.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class WebhookReceiver {
6060
},
6161
sender: {
6262
displayName: null,
63-
avatarUrl: null,
63+
avatar_url: null,
6464
}
6565
};
6666

@@ -74,7 +74,7 @@ class WebhookReceiver {
7474

7575
// Update profile, try join, fall back to invite, and try to send message
7676
const postFn = () => intent.sendMessage(webhookEvent.hook.roomId, matrixPayload.event);
77-
this._bridge.updateHookProfile(intent, matrixPayload.sender.displayName, matrixPayload.sender.avatarUrl)
77+
this._bridge.updateHookProfile(intent, matrixPayload.sender.displayName, matrixPayload.sender.avatar_url)
7878
.then(() => {
7979
return intent.join(webhookEvent.hook.roomId).then(postFn, err => {
8080
LogService.error("WebhookReceiver", err);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = (webhook, matrix) => {
22
// Note: this technically doesn't do anything and solely exists to make the structure sane
3-
if (!matrix.sender.avatarUrl)
4-
matrix.sender.avatarUrl = null;
5-
};
3+
if (!matrix.sender.avatar_url)
4+
matrix.sender.avatar_url = null;
5+
};
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = (webhook, matrix) => {
2-
if (!matrix.sender.avatarUrl && webhook.avatarUrl)
3-
matrix.sender.avatarUrl = webhook.avatarUrl;
4-
};
2+
if (!matrix.sender.avatar_url && webhook.avatar_url)
3+
matrix.sender.avatar_url = webhook.avatar_url;
4+
};

src/processing/layers/avatar/slack_icon_emoji.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ const cheerio = require("cheerio");
44
emojione.emojiSize = '128';
55

66
module.exports = (webhook, matrix) => {
7-
if (!matrix.sender.avatarUrl && webhook.icon_emoji) {
7+
if (!matrix.sender.avatar_url && webhook.icon_emoji) {
88
// HACK: We really shouldn't have to do this element -> url conversion
99

1010
const imgElement = emojione.shortnameToImage(webhook.icon_emoji);
1111
if (imgElement == webhook.icon_emoji) return;
1212

1313
const srcUrl = cheerio.load(imgElement).attr('src');
14-
matrix.sender.avatarUrl = srcUrl;
14+
matrix.sender.avatar_url = srcUrl;
1515
}
1616
};
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = (webhook, matrix) => {
2-
if (!matrix.sender.avatarUrl && webhook.icon_url)
3-
matrix.sender.avatarUrl = webhook.icon_url;
4-
};
2+
if (!matrix.sender.avatar_url && webhook.icon_url)
3+
matrix.sender.avatar_url = webhook.icon_url;
4+
};

0 commit comments

Comments
 (0)