From 74e1f983f0383b58d946bd2a354f0ab71d540485 Mon Sep 17 00:00:00 2001 From: Matti R Date: Thu, 7 Dec 2017 23:59:00 -0500 Subject: [PATCH 1/2] allow matrix to send localpart of username --- gateway/gateway.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gateway/gateway.go b/gateway/gateway.go index 8b1223f0..076424d4 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -287,6 +287,12 @@ func (gw *Gateway) modifyUsername(msg config.Message, dest *bridge.Bridge) strin nick = strings.Replace(nick, "{NICK}", msg.Username, -1) nick = strings.Replace(nick, "{BRIDGE}", br.Name, -1) nick = strings.Replace(nick, "{PROTOCOL}", br.Protocol, -1) + if br.Protocol == "matrix" { + nick_parts := strings.Split(msg.Username, ":") + nick = strings.Replace(nick, "{LOCALPART}", nick_parts[0], -1) + } else { + nick = strings.Replace(nick, "{LOCALPART}", msg.Username, -1) + } return nick } From b95a4703d00bf530506deee303df04a9ffc67827 Mon Sep 17 00:00:00 2001 From: Matti R Date: Fri, 8 Dec 2017 00:42:38 -0500 Subject: [PATCH 2/2] local part needs to be added in destination --- gateway/gateway.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/gateway/gateway.go b/gateway/gateway.go index 076424d4..9c1fbe3c 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -287,12 +287,8 @@ func (gw *Gateway) modifyUsername(msg config.Message, dest *bridge.Bridge) strin nick = strings.Replace(nick, "{NICK}", msg.Username, -1) nick = strings.Replace(nick, "{BRIDGE}", br.Name, -1) nick = strings.Replace(nick, "{PROTOCOL}", br.Protocol, -1) - if br.Protocol == "matrix" { - nick_parts := strings.Split(msg.Username, ":") - nick = strings.Replace(nick, "{LOCALPART}", nick_parts[0], -1) - } else { - nick = strings.Replace(nick, "{LOCALPART}", msg.Username, -1) - } + nick_parts := strings.Split(msg.Username, ":") + nick = strings.Replace(nick, "{LOCALPART}", nick_parts[0], -1) return nick }