diff options
author | Gary Kim <gary@garykim.dev> | 2021-06-19 15:45:19 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-19 21:45:19 +0200 |
commit | a79e632cdc26f3870b0d8b37f9a94bdcf6f47711 (patch) | |
tree | 69a23944ef6ddec50340a2567fc895edec87991a /vendor | |
parent | f36498421b7a3fbbe766c88bde4be656ab3a0b86 (diff) | |
download | matterbridge-msglm-a79e632cdc26f3870b0d8b37f9a94bdcf6f47711.tar.gz matterbridge-msglm-a79e632cdc26f3870b0d8b37f9a94bdcf6f47711.tar.bz2 matterbridge-msglm-a79e632cdc26f3870b0d8b37f9a94bdcf6f47711.zip |
Add support for separate display name (nctalk) (#1506)
Signed-off-by: Gary Kim <gary@garykim.dev>
Diffstat (limited to 'vendor')
-rw-r--r-- | vendor/gomod.garykim.dev/nc-talk/room/room.go | 27 | ||||
-rw-r--r-- | vendor/modules.txt | 2 |
2 files changed, 23 insertions, 6 deletions
diff --git a/vendor/gomod.garykim.dev/nc-talk/room/room.go b/vendor/gomod.garykim.dev/nc-talk/room/room.go index eb72c2c0..9e94f9d7 100644 --- a/vendor/gomod.garykim.dev/nc-talk/room/room.go +++ b/vendor/gomod.garykim.dev/nc-talk/room/room.go @@ -56,6 +56,21 @@ type TalkRoom struct { Token string } +// Message represents a message to be sent +type Message struct { + Message string + ActorDisplayName string + ReplyTo int +} + +func (t *Message) toParameters() map[string]string { + return map[string]string{ + "message": t.Message, + "actorDisplayName": t.ActorDisplayName, + "replyTo": strconv.Itoa(t.ReplyTo), + } +} + // NewTalkRoom returns a new TalkRoom instance // Token should be the Nextcloud Room Token (e.g. "d6zoa2zs" if the room URL is https://cloud.mydomain.me/call/d6zoa2zs) func NewTalkRoom(tuser *user.TalkUser, token string) (*TalkRoom, error) { @@ -71,17 +86,19 @@ func NewTalkRoom(tuser *user.TalkUser, token string) (*TalkRoom, error) { }, nil } -// SendMessage sends a message in the Talk room +// SendMessage sends a string message in the Talk room func (t *TalkRoom) SendMessage(msg string) (*ocs.TalkRoomMessageData, error) { + return t.SendComplexMessage(&Message{Message: msg}) +} + +// SendComplexMessage sends a Message type message in the talk room +func (t *TalkRoom) SendComplexMessage(msg *Message) (*ocs.TalkRoomMessageData, error) { url := t.User.NextcloudURL + constants.BaseEndpoint + "chat/" + t.Token - requestParams := map[string]string{ - "message": msg, - } client := t.User.RequestClient(request.Client{ URL: url, Method: "POST", - Params: requestParams, + Params: msg.toParameters(), }) res, err := client.Do() if err != nil { diff --git a/vendor/modules.txt b/vendor/modules.txt index 9e990f84..4a06f74f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -386,7 +386,7 @@ golang.org/x/text/unicode/norm golang.org/x/text/width # golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 golang.org/x/time/rate -# gomod.garykim.dev/nc-talk v0.2.2 +# gomod.garykim.dev/nc-talk v0.3.0 ## explicit gomod.garykim.dev/nc-talk/constants gomod.garykim.dev/nc-talk/ocs |