summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bridge/nctalk/nctalk.go21
-rw-r--r--go.mod2
-rw-r--r--go.sum2
-rw-r--r--matterbridge.toml.sample3
-rw-r--r--vendor/gomod.garykim.dev/nc-talk/CHANGELOG.md8
-rw-r--r--vendor/gomod.garykim.dev/nc-talk/ocs/message.go21
-rw-r--r--vendor/modules.txt2
7 files changed, 56 insertions, 3 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
+}
diff --git a/go.mod b/go.mod
index bf5513ad..8b72aa89 100644
--- a/go.mod
+++ b/go.mod
@@ -50,7 +50,7 @@ require (
github.com/zfjagann/golang-ring v0.0.0-20190304061218-d34796e0a6c2
golang.org/x/image v0.0.0-20200801110659-972c09e46d76
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43
- gomod.garykim.dev/nc-talk v0.1.3
+ gomod.garykim.dev/nc-talk v0.1.4
gopkg.in/olahol/melody.v1 v1.0.0-20170518105555-d52139073376
layeh.com/gumble v0.0.0-20200818122324-146f9205029b
)
diff --git a/go.sum b/go.sum
index bda19a2b..bb00f750 100644
--- a/go.sum
+++ b/go.sum
@@ -993,6 +993,8 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1N
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gomod.garykim.dev/nc-talk v0.1.3 h1:u4TPUR5++xjNTHoiO82/E8xhGFpCbwwfcY/yUv3Rp60=
gomod.garykim.dev/nc-talk v0.1.3/go.mod h1:zKg8yxCk2KaTy6aPDEfRac0Jik72czX+nRsG8CZuhtc=
+gomod.garykim.dev/nc-talk v0.1.4 h1:U9viudEgq/biocorgWvZRVR+27IPEczYl/yszSvzN+8=
+gomod.garykim.dev/nc-talk v0.1.4/go.mod h1:zKg8yxCk2KaTy6aPDEfRac0Jik72czX+nRsG8CZuhtc=
google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
google.golang.org/api v0.0.0-20181220000619-583d854617af/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample
index c9263e7b..c82b33ce 100644
--- a/matterbridge.toml.sample
+++ b/matterbridge.toml.sample
@@ -1405,6 +1405,9 @@ Login = "talkuser"
# Password of the bot
Password = "talkuserpass"
+# Suffix for Guest Users
+GuestSuffix = " (Guest)"
+
###################################################################
#
# Mumble
diff --git a/vendor/gomod.garykim.dev/nc-talk/CHANGELOG.md b/vendor/gomod.garykim.dev/nc-talk/CHANGELOG.md
index 987b0e19..b30e1f11 100644
--- a/vendor/gomod.garykim.dev/nc-talk/CHANGELOG.md
+++ b/vendor/gomod.garykim.dev/nc-talk/CHANGELOG.md
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [v0.1.4](https://github.com/gary-kim/go-nc-talk/tree/v0.1.4) - 2020-09-22
+
+[Full Changelog](https://github.com/gary-kim/go-nc-talk/compare/v0.1.3...v0.1.4)
+
+### Fixed
+
+- Add ActorType for message data [\#18](https://github.com/gary-kim/go-nc-talk/pull/18) ([@gary-kim](https://github.com/gary-kim))
+
## [v0.1.3](https://github.com/gary-kim/go-nc-talk/tree/v0.1.3) - 2020-09-03
[Full Changelog](https://github.com/gary-kim/go-nc-talk/compare/v0.1.2...v0.1.3)
diff --git a/vendor/gomod.garykim.dev/nc-talk/ocs/message.go b/vendor/gomod.garykim.dev/nc-talk/ocs/message.go
index e23078de..9de28b47 100644
--- a/vendor/gomod.garykim.dev/nc-talk/ocs/message.go
+++ b/vendor/gomod.garykim.dev/nc-talk/ocs/message.go
@@ -22,6 +22,9 @@ import (
// MessageType describes what kind of message a returned Nextcloud Talk message is
type MessageType string
+// ActorType describes what kind of actor a returned Nextcloud Talk message is from
+type ActorType string
+
const (
// MessageComment is a Nextcloud Talk message that is a comment
MessageComment MessageType = "comment"
@@ -31,12 +34,19 @@ const (
// MessageCommand is a Nextcloud Talk message that is a command
MessageCommand MessageType = "command"
+
+ // ActorUser is a Nextcloud Talk message sent by a user
+ ActorUser ActorType = "users"
+
+ // ActorGuest is a Nextcloud Talk message sent by a guest
+ ActorGuest ActorType = "guests"
)
// TalkRoomMessageData describes the data part of a ocs response for a Talk room message
type TalkRoomMessageData struct {
Message string `json:"message"`
ID int `json:"id"`
+ ActorType ActorType `json:"actorType"`
ActorID string `json:"actorId"`
ActorDisplayName string `json:"actorDisplayName"`
SystemMessage string `json:"systemMessage"`
@@ -63,6 +73,17 @@ func (m *TalkRoomMessageData) PlainMessage() string {
return tr
}
+// DisplayName returns the display name for the sender of the message (" (Guest)" is appended if sent by a guest user)
+func (m *TalkRoomMessageData) DisplayName() string {
+ if m.ActorType == ActorGuest {
+ if m.ActorDisplayName == "" {
+ return "Guest"
+ }
+ return m.ActorDisplayName + " (Guest)"
+ }
+ return m.ActorDisplayName
+}
+
// TalkRoomMessage describes an ocs response for a Talk room message
type TalkRoomMessage struct {
OCS talkRoomMessage `json:"ocs"`
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 1c695de0..fb2761d9 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -293,7 +293,7 @@ golang.org/x/text/secure/bidirule
golang.org/x/text/transform
golang.org/x/text/unicode/bidi
golang.org/x/text/unicode/norm
-# gomod.garykim.dev/nc-talk v0.1.3
+# gomod.garykim.dev/nc-talk v0.1.4
gomod.garykim.dev/nc-talk
gomod.garykim.dev/nc-talk/constants
gomod.garykim.dev/nc-talk/ocs