From 9dba3d538588746536c29863baa5837557402a39 Mon Sep 17 00:00:00 2001 From: Wim Date: Sun, 6 Dec 2020 17:23:37 +0100 Subject: [PATCH] Update rocketchat vendor (#1327) Contains fixes for #992 and adds more random ID --- go.mod | 2 +- go.sum | 2 ++ .../Rocket.Chat.Go.SDK/realtime/client.go | 2 +- .../Rocket.Chat.Go.SDK/realtime/messages.go | 14 ++++++-------- vendor/modules.txt | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 396c3605..fe73b388 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/labstack/echo/v4 v4.1.17 github.com/lrstanley/girc v0.0.0-20190801035559-4fc93959e1a7 github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd - github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20200411204219-d5c18ce75048 + github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20201206161339-a8e64af17cde github.com/matterbridge/discordgo v0.22.1 github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible github.com/matterbridge/go-xmpp v0.0.0-20200418225040-c8a3a57b4050 diff --git a/go.sum b/go.sum index 1f792960..96f355d0 100644 --- a/go.sum +++ b/go.sum @@ -497,6 +497,8 @@ github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd h1:xVrqJK3xHRE github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd/go.mod h1:/gBX06Kw0exX1HrwmoBibFA98yBk/jxKpGVeyQbff+s= github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20200411204219-d5c18ce75048 h1:B9HaistmV+MD8/33BXmZe1zPIn+RImAFVXNNSOrwU2E= github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20200411204219-d5c18ce75048/go.mod h1:c6MxwqHD+0HvtAJjsHMIdPCiAwGiQwPRPTp69ACMg8A= +github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20201206161339-a8e64af17cde h1:7txV2EiAMLRUWabaSkLNd11TGclMHSOUGYSRMuE+sOI= +github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20201206161339-a8e64af17cde/go.mod h1:c6MxwqHD+0HvtAJjsHMIdPCiAwGiQwPRPTp69ACMg8A= github.com/matterbridge/discordgo v0.22.1 h1:Wh2NXfvF4egJDxX7jEvtgxJgT/ZOqD/5tfcIsNnHJ9o= github.com/matterbridge/discordgo v0.22.1/go.mod h1:411nZYv0UMMrtppR5glXop1foboJiFAowy+42U+Ahvw= github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible h1:oaOqwbg5HxHRxvAbd84ks0Okwoc1ISyUZ87EiVJFhGI= diff --git a/vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/realtime/client.go b/vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/realtime/client.go index 1dde80bf..45a6a05d 100644 --- a/vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/realtime/client.go +++ b/vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/realtime/client.go @@ -92,5 +92,5 @@ func (c *Client) Close() { // Some of the rocketchat objects need unique IDs specified by the client func (c *Client) newRandomId() string { - return fmt.Sprintf("%f", rand.Float64()) + return fmt.Sprintf("%x%x", rand.Uint64(), time.Now().UTC().UnixNano()) } diff --git a/vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/realtime/messages.go b/vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/realtime/messages.go index 3c3f6fe2..2c112155 100644 --- a/vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/realtime/messages.go +++ b/vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/realtime/messages.go @@ -41,6 +41,10 @@ func (c *Client) SendMessage(m *models.Message) (*models.Message, error) { return nil, err } + if rawResponse == nil { + return nil, fmt.Errorf("rawResponse is %#v", rawResponse) + } + return getMessageFromData(rawResponse.(map[string]interface{})), nil } @@ -95,7 +99,6 @@ func (c *Client) StarMessage(message *models.Message) error { "rid": message.RoomID, "starred": true, }) - if err != nil { return err } @@ -113,7 +116,6 @@ func (c *Client) UnStarMessage(message *models.Message) error { "rid": message.RoomID, "starred": false, }) - if err != nil { return err } @@ -127,7 +129,6 @@ func (c *Client) UnStarMessage(message *models.Message) error { // https://rocket.chat/docs/developer-guides/realtime-api/method-calls/pin-message func (c *Client) PinMessage(message *models.Message) error { _, err := c.ddp.Call("pinMessage", message) - if err != nil { return err } @@ -141,7 +142,6 @@ func (c *Client) PinMessage(message *models.Message) error { // https://rocket.chat/docs/developer-guides/realtime-api/method-calls/unpin-messages func (c *Client) UnPinMessage(message *models.Message) error { _, err := c.ddp.Call("unpinMessage", message) - if err != nil { return err } @@ -154,12 +154,11 @@ func (c *Client) UnPinMessage(message *models.Message) error { // // https://rocket.chat/docs/developer-guides/realtime-api/subscriptions/stream-room-messages/ func (c *Client) SubscribeToMessageStream(channel *models.Channel, msgChannel chan models.Message) error { - if err := c.ddp.Sub("stream-room-messages", channel.ID, send_added_event); err != nil { return err } - //msgChannel := make(chan models.Message, default_buffer_size) + // msgChannel := make(chan models.Message, default_buffer_size) c.ddp.CollectionByName("stream-room-messages").AddUpdateListener(messageExtractor{msgChannel, "update"}) return nil @@ -168,7 +167,6 @@ func (c *Client) SubscribeToMessageStream(channel *models.Channel, msgChannel ch func getMessagesFromUpdateEvent(update ddp.Update) []models.Message { document, _ := gabs.Consume(update["args"]) args, err := document.Children() - if err != nil { // log.Printf("Event arguments are in an unexpected format: %v", err) return make([]models.Message, 0) @@ -206,7 +204,7 @@ func getMessageFromDocument(arg *gabs.Container) *models.Message { TitleLinkDownload: stringOrZero(attachment.Path("title_link_download").Data()), ImageURL: stringOrZero(attachment.Path("image_url").Data()), - AuthorName: stringOrZero(arg.Path("u.name").Data()), + AuthorName: stringOrZero(arg.Path("u.name").Data()), } } } diff --git a/vendor/modules.txt b/vendor/modules.txt index 6f60a023..0ca0199b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -125,7 +125,7 @@ github.com/magiconair/properties # github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd ## explicit github.com/matrix-org/gomatrix -# github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20200411204219-d5c18ce75048 +# github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20201206161339-a8e64af17cde ## explicit github.com/matterbridge/Rocket.Chat.Go.SDK/models github.com/matterbridge/Rocket.Chat.Go.SDK/realtime