From c8d7fdeedcc2fe596055da000bfa8c23c4ba5cab Mon Sep 17 00:00:00 2001 From: Wim Date: Sun, 6 Feb 2022 17:33:41 +0100 Subject: Add UseUsername option (mattermost). Fixes #1665 (#1714) --- bridge/config/config.go | 2 +- bridge/mattermost/handlers.go | 12 ++++++++---- matterbridge.toml.sample | 4 ++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/bridge/config/config.go b/bridge/config/config.go index 16b397f3..18c60920 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -170,7 +170,7 @@ type Protocol struct { UseTLS bool // IRC UseDiscriminator bool // discord UseFirstName bool // telegram - UseUserName bool // discord, matrix + UseUserName bool // discord, matrix, mattermost UseInsecureURL bool // telegram UserName string // IRC VerboseJoinPart bool // IRC diff --git a/bridge/mattermost/handlers.go b/bridge/mattermost/handlers.go index 5ad40115..00c9445d 100644 --- a/bridge/mattermost/handlers.go +++ b/bridge/mattermost/handlers.go @@ -177,8 +177,10 @@ func (b *Bmattermost) handleMatterClient(messages chan *config.Message) { } // Use nickname instead of username if defined - if nick := b.mc.GetNickName(rmsg.UserID); nick != "" { - rmsg.Username = nick + if !b.GetBool("useusername") { + if nick := b.mc.GetNickName(rmsg.UserID); nick != "" { + rmsg.Username = nick + } } messages <- rmsg @@ -232,8 +234,10 @@ func (b *Bmattermost) handleMatterClient6(messages chan *config.Message) { } // Use nickname instead of username if defined - if nick := b.mc6.GetNickName(rmsg.UserID); nick != "" { - rmsg.Username = nick + if !b.GetBool("useusername") { + if nick := b.mc6.GetNickName(rmsg.UserID); nick != "" { + rmsg.Username = nick + } } messages <- rmsg diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index 8bc0f6c1..63a614d1 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -408,6 +408,10 @@ SkipTLSVerify=true ## RELOADABLE SETTINGS ## Settings below can be reloaded by editing the file +# UseUserName shows the username instead of the server nickname +# OPTIONAL (default false) +UseUserName=false + #how to format the list of IRC nicks when displayed in mattermost. #Possible options are "table" and "plain" #OPTIONAL (default plain) -- cgit v1.2.3