From eee0036c7f0d711f0af203bf0fb8dccd42241c1a Mon Sep 17 00:00:00 2001 From: Wim Date: Sat, 8 Apr 2017 00:16:46 +0200 Subject: Modify iconurl correctly (mattermost). Closes #145 --- gateway/gateway.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gateway') 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 } -- cgit v1.2.3