diff options
author | Wim <wim@42.be> | 2020-12-06 17:23:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-06 17:23:37 +0100 |
commit | 9dba3d538588746536c29863baa5837557402a39 (patch) | |
tree | 5682d3807de5a5089518d679a4860f8fc9aadbff /vendor/github.com | |
parent | 2d3c26a4b218279d169da106032a70d3d80c4a53 (diff) | |
download | matterbridge-msglm-9dba3d538588746536c29863baa5837557402a39.tar.gz matterbridge-msglm-9dba3d538588746536c29863baa5837557402a39.tar.bz2 matterbridge-msglm-9dba3d538588746536c29863baa5837557402a39.zip |
Update rocketchat vendor (#1327)
Contains fixes for #992 and adds more random ID
Diffstat (limited to 'vendor/github.com')
-rw-r--r-- | vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/realtime/client.go | 2 | ||||
-rw-r--r-- | vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/realtime/messages.go | 14 |
2 files changed, 7 insertions, 9 deletions
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()), } } } |