summaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
Diffstat (limited to 'vendor')
-rw-r--r--vendor/gomod.garykim.dev/nc-talk/room/room.go27
-rw-r--r--vendor/modules.txt2
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