From 392ee8f57bd209ffb07f36b1c0a4533d95d755e4 Mon Sep 17 00:00:00 2001 From: AlexanderShK <113863493+AlexanderShK@users.noreply.github.com> Date: Fri, 8 Dec 2023 14:03:02 +0300 Subject: [PATCH 1/4] Update config.go update variables added UseFullName and UseLastName --- bridge/config/config.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bridge/config/config.go b/bridge/config/config.go index 18c6092082..82ffb8d748 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -169,7 +169,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 From 1addf9fca7a35f769fb41988d341d56fe11b09e5 Mon Sep 17 00:00:00 2001 From: AlexanderShK <113863493+AlexanderShK@users.noreply.github.com> Date: Fri, 8 Dec 2023 14:06:51 +0300 Subject: [PATCH 2/4] Update users.go Added functions for First and Last names --- .../matterbridge/matterclient/users.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/vendor/github.com/matterbridge/matterclient/users.go b/vendor/github.com/matterbridge/matterclient/users.go index 30ea51a260..93e6bd701e 100644 --- a/vendor/github.com/matterbridge/matterclient/users.go +++ b/vendor/github.com/matterbridge/matterclient/users.go @@ -12,6 +12,22 @@ func (m *Client) GetNickName(userID string) string { return "" } +func (m *Client) GetFirstName(userID string) string { + if user := m.GetUser(userID); user != nil { + return user.FirstName + } + + return "" +} + +func (m *Client) GetLastName(userID string) string { + if user := m.GetUser(userID); user != nil { + return user.LastName + } + + return "" +} + func (m *Client) GetStatus(userID string) string { res, _, err := m.Client.GetUserStatus(userID, "") if err != nil { From 5e38c949f2adbef6507cd3fb12ddb5543fed7baf Mon Sep 17 00:00:00 2001 From: AlexanderShK <113863493+AlexanderShK@users.noreply.github.com> Date: Fri, 8 Dec 2023 14:13:19 +0300 Subject: [PATCH 3/4] Update handlers.go Add ability to use FullName, FirstName, LastName, NickName or UserName(if neither is set) as nick for Mattermost --- bridge/mattermost/handlers.go | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/bridge/mattermost/handlers.go b/bridge/mattermost/handlers.go index 8c4ea36526..06c86a060e 100644 --- a/bridge/mattermost/handlers.go +++ b/bridge/mattermost/handlers.go @@ -142,12 +142,30 @@ 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 - } - } + // Choose what to use as user nick Nickname/FullName/FirstName/LastName (or Username if neither is set) + if b.GetBool("UseNickName") { + if b.mc.GetNickName(rmsg.UserID) != "" { + rmsg.Username = b.mc.GetNickName(rmsg.UserID) + } + } else if b.GetBool("UseFirstName") { + if b.mc.GetFirstName(rmsg.UserID) != "" { + rmsg.Username = b.mc.GetFirstName(rmsg.UserID) + } + } else if b.GetBool("UseLastName") { + if b.mc.GetLastName(rmsg.UserID) != "" { + rmsg.Username = b.mc.GetLastName(rmsg.UserID) + } + } else if b.GetBool("UseFullName") { + if b.mc.GetFirstName(rmsg.UserID) != "" && b.mc.GetLastName(rmsg.UserID) != "" { + rmsg.Username = b.mc.GetFirstName(rmsg.UserID) + " " + b.mc.GetLastName(rmsg.UserID) + } else if b.mc.GetFirstName(rmsg.UserID) != "" { + rmsg.Username = b.mc.GetFirstName(rmsg.UserID) + } else if b.mc.GetLastName(rmsg.UserID) != "" { + rmsg.Username = b.mc.GetLastName(rmsg.UserID) + } else { + rmsg.Username = "" + } + } messages <- rmsg } From b502420de89c9f1c5825f2a6e01a0a323ae5366c Mon Sep 17 00:00:00 2001 From: AlexanderShK <113863493+AlexanderShK@users.noreply.github.com> Date: Fri, 8 Dec 2023 14:29:42 +0300 Subject: [PATCH 4/4] Update matterbridge.toml.sample Added examples NickName/FullName/FirstName/LastName/UserName for Mattermost --- matterbridge.toml.sample | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index 5932b269a3..6156f71629 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"