diff options
author | Gary Kim <gary@garykim.dev> | 2020-10-01 16:59:35 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-01 22:59:35 +0200 |
commit | 219a5453f9edaa87aa7aa4b9d5f9c3de9c75b38f (patch) | |
tree | 113553069c5577b4dd96e26b467f4d69a2df6884 /bridge | |
parent | 214a6a13861b9fd495797386f36507373728e577 (diff) | |
download | matterbridge-msglm-219a5453f9edaa87aa7aa4b9d5f9c3de9c75b38f.tar.gz matterbridge-msglm-219a5453f9edaa87aa7aa4b9d5f9c3de9c75b38f.tar.bz2 matterbridge-msglm-219a5453f9edaa87aa7aa4b9d5f9c3de9c75b38f.zip |
Append a suffix if user is a guest user (nctalk) (#1250)
Signed-off-by: Gary Kim <gary@garykim.dev>
Diffstat (limited to 'bridge')
-rw-r--r-- | bridge/nctalk/nctalk.go | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/bridge/nctalk/nctalk.go b/bridge/nctalk/nctalk.go index 94bb1a08..23b59135 100644 --- a/bridge/nctalk/nctalk.go +++ b/bridge/nctalk/nctalk.go @@ -70,6 +70,13 @@ func (b *Btalk) JoinChannel(channel config.ChannelInfo) error { return err } b.rooms = append(b.rooms, newRoom) + + // Config + guestSuffix := " (Guest)" + if b.IsKeySet("GuestSuffix") { + guestSuffix = b.GetString("GuestSuffix") + } + go func() { for msg := range c { // ignore messages that are one of the following @@ -81,7 +88,7 @@ func (b *Btalk) JoinChannel(channel config.ChannelInfo) error { remoteMessage := config.Message{ Text: formatRichObjectString(msg.Message, msg.MessageParameters), Channel: newRoom.room.Token, - Username: msg.ActorDisplayName, + Username: DisplayName(msg, guestSuffix), UserID: msg.ActorID, Account: b.Account, } @@ -144,3 +151,15 @@ func formatRichObjectString(message string, parameters map[string]ocs.RichObject return message } + +func DisplayName(msg ocs.TalkRoomMessageData, suffix string) string { + if msg.ActorType == ocs.ActorGuest { + if msg.ActorDisplayName == "" { + return "Guest" + } + + return msg.ActorDisplayName + suffix + } + + return msg.ActorDisplayName +} |