2
0
mirror of https://github.com/42wim/matterbridge synced 2024-11-03 15:40:24 +00:00

Update rocketchat vendor (#1327)

Contains fixes for #992 and adds more random ID
This commit is contained in:
Wim 2020-12-06 17:23:37 +01:00 committed by GitHub
parent 2d3c26a4b2
commit 9dba3d5385
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 11 deletions

2
go.mod
View File

@ -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

2
go.sum
View File

@ -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=

View File

@ -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())
}

View File

@ -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()),
}
}
}

2
vendor/modules.txt vendored
View File

@ -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