From 219a5453f9edaa87aa7aa4b9d5f9c3de9c75b38f Mon Sep 17 00:00:00 2001 From: Gary Kim Date: Thu, 1 Oct 2020 16:59:35 -0400 Subject: Append a suffix if user is a guest user (nctalk) (#1250) Signed-off-by: Gary Kim --- bridge/nctalk/nctalk.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'bridge') 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 +} -- cgit v1.2.3