4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-06-26 07:29:24 +00:00

Append a suffix if user is a guest user (nctalk) (#1250)

Signed-off-by: Gary Kim <gary@garykim.dev>
This commit is contained in:
Gary Kim
2020-10-01 16:59:35 -04:00
committed by GitHub
parent 214a6a1386
commit 219a5453f9
7 changed files with 56 additions and 3 deletions

View File

@ -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
}