summaryrefslogtreecommitdiffstats
path: root/vendor/gomod.garykim.dev
diff options
context:
space:
mode:
authorGary Kim <gary@garykim.dev>2021-06-19 15:45:19 -0400
committerGitHub <noreply@github.com>2021-06-19 21:45:19 +0200
commita79e632cdc26f3870b0d8b37f9a94bdcf6f47711 (patch)
tree69a23944ef6ddec50340a2567fc895edec87991a /vendor/gomod.garykim.dev
parentf36498421b7a3fbbe766c88bde4be656ab3a0b86 (diff)
downloadmatterbridge-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/gomod.garykim.dev')
-rw-r--r--vendor/gomod.garykim.dev/nc-talk/room/room.go27
1 files changed, 22 insertions, 5 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 {