diff --git a/bridge/config/config.go b/bridge/config/config.go index 994b83488..fc15ed86f 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -211,7 +211,9 @@ type Protocol struct { UseSASL bool // IRC UseTLS bool // IRC UseDiscriminator bool // discord - UseFirstName bool // telegram + UseFullName bool // mattermost + UseFirstName bool // telegram, mattermost + UseLastName bool // mattermost UseUserName bool // discord, matrix, mattermost UseInsecureURL bool // telegram UserName string // IRC diff --git a/bridge/mattermost/handlers.go b/bridge/mattermost/handlers.go index 88e44757c..f7aa4b059 100644 --- a/bridge/mattermost/handlers.go +++ b/bridge/mattermost/handlers.go @@ -5,7 +5,7 @@ import ( "github.com/matterbridge-org/matterbridge/bridge/config" "github.com/matterbridge-org/matterbridge/bridge/helper" - "github.com/matterbridge/matterclient" + "github.com/matterbridge-org/matterclient" "github.com/mattermost/mattermost/server/public/model" ) @@ -144,15 +144,41 @@ func (b *Bmattermost) handleMatterClient(messages chan *config.Message) { } } - // Use nickname instead of username if defined - if !b.GetBool("useusername") { - if nick := b.mc.GetNickName(rmsg.UserID); nick != "" { - rmsg.Username = nick - } - } - - messages <- rmsg - } + // Choose what to use as user nick Nickname/FullName/FirstName/LastName (or Username if neither is set) + switch { + case b.GetBool("UseNickName"): + if nickname := b.mc.GetNickName(rmsg.UserID); nickname != "" { + rmsg.Username = nickname + } + + case b.GetBool("UseFirstName"): + if firstname := b.mc.GetFirstName(rmsg.UserID); firstname != "" { + rmsg.Username = firstname + } + + case b.GetBool("UseLastName"): + if lastname := b.mc.GetLastName(rmsg.UserID); lastname != "" { + rmsg.Username = lastname + } + + case b.GetBool("UseFullName"): + first := b.mc.GetFirstName(rmsg.UserID) + last := b.mc.GetLastName(rmsg.UserID) + + switch { + case first != "" && last != "": + rmsg.Username = first + " " + last + case first != "": + rmsg.Username = first + case last != "": + rmsg.Username = last + default: + rmsg.Username = "NoName" + } + } + + messages <- rmsg + } } func (b *Bmattermost) handleMatterHook(messages chan *config.Message) { diff --git a/bridge/mattermost/helpers.go b/bridge/mattermost/helpers.go index 63e143dda..864865b11 100644 --- a/bridge/mattermost/helpers.go +++ b/bridge/mattermost/helpers.go @@ -7,7 +7,7 @@ import ( "github.com/matterbridge-org/matterbridge/bridge/config" "github.com/matterbridge-org/matterbridge/bridge/helper" "github.com/matterbridge-org/matterbridge/matterhook" - "github.com/matterbridge/matterclient" + "github.com/matterbridge-org/matterclient" "github.com/mattermost/mattermost/server/public/model" ) diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go index 2a9cbf767..9ce40f5e6 100644 --- a/bridge/mattermost/mattermost.go +++ b/bridge/mattermost/mattermost.go @@ -11,7 +11,7 @@ import ( "github.com/matterbridge-org/matterbridge/bridge/config" "github.com/matterbridge-org/matterbridge/bridge/helper" "github.com/matterbridge-org/matterbridge/matterhook" - "github.com/matterbridge/matterclient" + "github.com/matterbridge-org/matterclient" "github.com/rs/xid" ) diff --git a/go.mod b/go.mod index 9d0fd08eb..f3ef39b65 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20211016222428-79310a412696 github.com/matterbridge/gozulipbot v0.0.0-20211023205727-a19d6c1f3b75 github.com/matterbridge/logrus-prefixed-formatter v0.5.3-0.20200523233437-d971309a77ba - github.com/matterbridge/matterclient v0.0.0-20240817214420-3d4c3aef3dc1 + github.com/matterbridge-org/matterclient v0.0.1 github.com/matterbridge/telegram-bot-api/v6 v6.5.0 github.com/mattermost/mattermost/server/public v0.1.6 github.com/mattn/go-mastodon v0.0.10 diff --git a/go.sum b/go.sum index ce4611f49..9bcdbdf6e 100644 --- a/go.sum +++ b/go.sum @@ -190,8 +190,8 @@ github.com/matterbridge/gozulipbot v0.0.0-20211023205727-a19d6c1f3b75 h1:GslZKF7 github.com/matterbridge/gozulipbot v0.0.0-20211023205727-a19d6c1f3b75/go.mod h1:yAjnZ34DuDyPHMPHHjOsTk/FefW4JJjoMMCGt/8uuQA= github.com/matterbridge/logrus-prefixed-formatter v0.5.3-0.20200523233437-d971309a77ba h1:XleOY4IjAEIcxAh+IFwT5JT5Ze3RHiYz6m+4ZfZ0rc0= github.com/matterbridge/logrus-prefixed-formatter v0.5.3-0.20200523233437-d971309a77ba/go.mod h1:iXGEotOvwI1R1SjLxRc+BF5rUORTMtE0iMZBT2lxqAU= -github.com/matterbridge/matterclient v0.0.0-20240817214420-3d4c3aef3dc1 h1:LHzlbT3VIcRFhSPwKpZfT2TU2rUzuA8liF57gSEBuaI= -github.com/matterbridge/matterclient v0.0.0-20240817214420-3d4c3aef3dc1/go.mod h1:quMZkUhnTp/YfbJU6sCgD6qVSPgH1Uxig9/AjgJQHF8= +github.com/matterbridge-org/matterclient v0.0.1 h1:0Wtcf3BrOfnmWV/05mta3lagEIZy03nZAMuXbBq6r0I= +github.com/matterbridge-org/matterclient v0.0.1/go.mod h1:qT2nKnISsB0W9feG5a1C9o0Bnye8H7lwfDEnwCA0yCs= github.com/matterbridge/telegram-bot-api/v6 v6.5.0 h1:wCnHWvt4WGhfognQsuu2OnHyqENBdJRf2mReYTCXggQ= github.com/matterbridge/telegram-bot-api/v6 v6.5.0/go.mod h1:/hSLrs8h/xNsQglQXjwXJ92iZU8XfTGkYUQ7KVDWEVo= github.com/mattermost/go-i18n v1.11.1-0.20211013152124-5c415071e404 h1:Khvh6waxG1cHc4Cz5ef9n3XVCxRWpAKUtqg9PJl5+y8= diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index 060ade681..1d8a3d5a5 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -409,9 +409,13 @@ SkipTLSVerify=true ## RELOADABLE SETTINGS ## Settings below can be reloaded by editing the file -# UseUserName shows the username instead of the server nickname +# Choose what use as user nick NickName/FullName/FirstName/LastName/UserName # OPTIONAL (default false) -UseUserName=false +UseNickName=false +UseFullName=false +UseFirstName=false +UseLastName=false +#if neither is set as true will use username #how to format the list of IRC nicks when displayed in mattermost. #Possible options are "table" and "plain"