From bd4281c2007131cc837487036647abf907368306 Mon Sep 17 00:00:00 2001 From: s3lph <5564491+s3lph@users.noreply.github.com> Date: Thu, 1 Oct 2020 23:11:20 +0200 Subject: [PATCH 1/3] nctalk: Add option to use User ID instead of Display Name as nick --- bridge/nctalk/nctalk.go | 10 +++++++--- matterbridge.toml.sample | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/bridge/nctalk/nctalk.go b/bridge/nctalk/nctalk.go index 23b59135cf..539f3fedcc 100644 --- a/bridge/nctalk/nctalk.go +++ b/bridge/nctalk/nctalk.go @@ -76,6 +76,7 @@ func (b *Btalk) JoinChannel(channel config.ChannelInfo) error { if b.IsKeySet("GuestSuffix") { guestSuffix = b.GetString("GuestSuffix") } + userIdAsNick := b.GetBool("UserIdAsNick") go func() { for msg := range c { @@ -88,7 +89,7 @@ func (b *Btalk) JoinChannel(channel config.ChannelInfo) error { remoteMessage := config.Message{ Text: formatRichObjectString(msg.Message, msg.MessageParameters), Channel: newRoom.room.Token, - Username: DisplayName(msg, guestSuffix), + Username: DisplayName(msg, guestSuffix, userIdAsNick), UserID: msg.ActorID, Account: b.Account, } @@ -152,7 +153,7 @@ func formatRichObjectString(message string, parameters map[string]ocs.RichObject return message } -func DisplayName(msg ocs.TalkRoomMessageData, suffix string) string { +func DisplayName(msg ocs.TalkRoomMessageData, suffix string, userIdAsName bool) string { if msg.ActorType == ocs.ActorGuest { if msg.ActorDisplayName == "" { return "Guest" @@ -160,6 +161,9 @@ func DisplayName(msg ocs.TalkRoomMessageData, suffix string) string { return msg.ActorDisplayName + suffix } - + // Use the user ID instead of the display name for non-guest users + if userIdAsName { + return msg.ActorID + } return msg.ActorDisplayName } diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index c82b33ceb2..90926c6699 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -1407,6 +1407,9 @@ Password = "talkuserpass" # Suffix for Guest Users GuestSuffix = " (Guest)" +# If true, use the User ID instead of Display Name for non-guest users +# WARNING: Before using this, verify that your user IDs are indeed human-readable and intended for display. +UserIdAsNick = false ################################################################### # From 227f9496ee05a575cd14b30dcade46e46add5568 Mon Sep 17 00:00:00 2001 From: s3lph <5564491+s3lph@users.noreply.github.com> Date: Thu, 1 Oct 2020 23:18:12 +0200 Subject: [PATCH 2/3] Make golangci-lint happy --- bridge/nctalk/nctalk.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bridge/nctalk/nctalk.go b/bridge/nctalk/nctalk.go index 539f3fedcc..fb38b050fb 100644 --- a/bridge/nctalk/nctalk.go +++ b/bridge/nctalk/nctalk.go @@ -76,7 +76,7 @@ func (b *Btalk) JoinChannel(channel config.ChannelInfo) error { if b.IsKeySet("GuestSuffix") { guestSuffix = b.GetString("GuestSuffix") } - userIdAsNick := b.GetBool("UserIdAsNick") + userIDAsNick := b.GetBool("UserIdAsNick") go func() { for msg := range c { @@ -89,7 +89,7 @@ func (b *Btalk) JoinChannel(channel config.ChannelInfo) error { remoteMessage := config.Message{ Text: formatRichObjectString(msg.Message, msg.MessageParameters), Channel: newRoom.room.Token, - Username: DisplayName(msg, guestSuffix, userIdAsNick), + Username: DisplayName(msg, guestSuffix, userIDAsNick), UserID: msg.ActorID, Account: b.Account, } @@ -153,7 +153,7 @@ func formatRichObjectString(message string, parameters map[string]ocs.RichObject return message } -func DisplayName(msg ocs.TalkRoomMessageData, suffix string, userIdAsName bool) string { +func DisplayName(msg ocs.TalkRoomMessageData, suffix string, userIDAsName bool) string { if msg.ActorType == ocs.ActorGuest { if msg.ActorDisplayName == "" { return "Guest" @@ -162,7 +162,7 @@ func DisplayName(msg ocs.TalkRoomMessageData, suffix string, userIdAsName bool) return msg.ActorDisplayName + suffix } // Use the user ID instead of the display name for non-guest users - if userIdAsName { + if userIDAsName { return msg.ActorID } return msg.ActorDisplayName From f718c5c91e1f39c82da15a594de0be93a40bae14 Mon Sep 17 00:00:00 2001 From: Sebastian P <5564491+s3lph@users.noreply.github.com> Date: Sun, 4 Oct 2020 16:24:36 +0200 Subject: [PATCH 3/3] matterbridge.toml.sample: Add explicit mention of default value for nctalk/UserIdAsNick Co-authored-by: Gary Kim --- matterbridge.toml.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index 90926c6699..a552feb431 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -1407,7 +1407,7 @@ Password = "talkuserpass" # Suffix for Guest Users GuestSuffix = " (Guest)" -# If true, use the User ID instead of Display Name for non-guest users +# If true, use the User ID instead of Display Name for non-guest users (default false) # WARNING: Before using this, verify that your user IDs are indeed human-readable and intended for display. UserIdAsNick = false