summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-04-08 00:16:46 +0200
committerWim <wim@42.be>2017-04-08 00:16:46 +0200
commiteee0036c7f0d711f0af203bf0fb8dccd42241c1a (patch)
tree75c7b42fc2c1d5a102aac8039e6b0a42c84b78a7
parent89c66b9430098f3d1801b8e38af2230932aba387 (diff)
downloadmatterbridge-msglm-eee0036c7f0d711f0af203bf0fb8dccd42241c1a.tar.gz
matterbridge-msglm-eee0036c7f0d711f0af203bf0fb8dccd42241c1a.tar.bz2
matterbridge-msglm-eee0036c7f0d711f0af203bf0fb8dccd42241c1a.zip
Modify iconurl correctly (mattermost). Closes #145
-rw-r--r--bridge/mattermost/mattermost.go1
-rw-r--r--gateway/gateway.go12
2 files changed, 13 insertions, 0 deletions
diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go
index 94b649bb..b9d082e3 100644
--- a/bridge/mattermost/mattermost.go
+++ b/bridge/mattermost/mattermost.go
@@ -101,6 +101,7 @@ func (b *Bmattermost) Send(msg config.Message) error {
}
if !b.Config.UseAPI {
matterMessage := matterhook.OMessage{IconURL: b.Config.IconURL}
+ matterMessage.IconURL = msg.Avatar
matterMessage.Channel = channel
matterMessage.UserName = nick
matterMessage.Type = ""
diff --git a/gateway/gateway.go b/gateway/gateway.go
index 4c2f7463..140bfc4d 100644
--- a/gateway/gateway.go
+++ b/gateway/gateway.go
@@ -190,6 +190,7 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) {
}
log.Debugf("Sending %#v from %s (%s) to %s (%s)", msg, msg.Account, originchannel, dest.Account, channel.Name)
msg.Channel = channel.Name
+ gw.modifyAvatar(&msg, dest)
gw.modifyUsername(&msg, dest)
// for api we need originchannel as channel
if dest.Protocol == "api" {
@@ -229,6 +230,17 @@ func (gw *Gateway) modifyUsername(msg *config.Message, dest *bridge.Bridge) {
msg.Username = nick
}
+func (gw *Gateway) modifyAvatar(msg *config.Message, dest *bridge.Bridge) {
+ iconurl := gw.Config.General.IconURL
+ if iconurl == "" {
+ iconurl = dest.Config.IconURL
+ }
+ iconurl = strings.Replace(iconurl, "{NICK}", msg.Username, -1)
+ if msg.Avatar == "" {
+ msg.Avatar = iconurl
+ }
+}
+
func getChannelID(msg config.Message) string {
return msg.Channel + msg.Account
}