Update rocketchat vendor (#1327)
Contains fixes for #992 and adds more random ID
This commit is contained in:
parent
2d3c26a4b2
commit
9dba3d5385
2
go.mod
2
go.mod
|
@ -21,7 +21,7 @@ require (
|
||||||
github.com/labstack/echo/v4 v4.1.17
|
github.com/labstack/echo/v4 v4.1.17
|
||||||
github.com/lrstanley/girc v0.0.0-20190801035559-4fc93959e1a7
|
github.com/lrstanley/girc v0.0.0-20190801035559-4fc93959e1a7
|
||||||
github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd
|
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/discordgo v0.22.1
|
||||||
github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible
|
github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible
|
||||||
github.com/matterbridge/go-xmpp v0.0.0-20200418225040-c8a3a57b4050
|
github.com/matterbridge/go-xmpp v0.0.0-20200418225040-c8a3a57b4050
|
||||||
|
|
2
go.sum
2
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/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 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-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 h1:Wh2NXfvF4egJDxX7jEvtgxJgT/ZOqD/5tfcIsNnHJ9o=
|
||||||
github.com/matterbridge/discordgo v0.22.1/go.mod h1:411nZYv0UMMrtppR5glXop1foboJiFAowy+42U+Ahvw=
|
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=
|
github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible h1:oaOqwbg5HxHRxvAbd84ks0Okwoc1ISyUZ87EiVJFhGI=
|
||||||
|
|
|
@ -92,5 +92,5 @@ func (c *Client) Close() {
|
||||||
|
|
||||||
// Some of the rocketchat objects need unique IDs specified by the client
|
// Some of the rocketchat objects need unique IDs specified by the client
|
||||||
func (c *Client) newRandomId() string {
|
func (c *Client) newRandomId() string {
|
||||||
return fmt.Sprintf("%f", rand.Float64())
|
return fmt.Sprintf("%x%x", rand.Uint64(), time.Now().UTC().UnixNano())
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,10 @@ func (c *Client) SendMessage(m *models.Message) (*models.Message, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if rawResponse == nil {
|
||||||
|
return nil, fmt.Errorf("rawResponse is %#v", rawResponse)
|
||||||
|
}
|
||||||
|
|
||||||
return getMessageFromData(rawResponse.(map[string]interface{})), nil
|
return getMessageFromData(rawResponse.(map[string]interface{})), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +99,6 @@ func (c *Client) StarMessage(message *models.Message) error {
|
||||||
"rid": message.RoomID,
|
"rid": message.RoomID,
|
||||||
"starred": true,
|
"starred": true,
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -113,7 +116,6 @@ func (c *Client) UnStarMessage(message *models.Message) error {
|
||||||
"rid": message.RoomID,
|
"rid": message.RoomID,
|
||||||
"starred": false,
|
"starred": false,
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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
|
// https://rocket.chat/docs/developer-guides/realtime-api/method-calls/pin-message
|
||||||
func (c *Client) PinMessage(message *models.Message) error {
|
func (c *Client) PinMessage(message *models.Message) error {
|
||||||
_, err := c.ddp.Call("pinMessage", message)
|
_, err := c.ddp.Call("pinMessage", message)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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
|
// https://rocket.chat/docs/developer-guides/realtime-api/method-calls/unpin-messages
|
||||||
func (c *Client) UnPinMessage(message *models.Message) error {
|
func (c *Client) UnPinMessage(message *models.Message) error {
|
||||||
_, err := c.ddp.Call("unpinMessage", message)
|
_, err := c.ddp.Call("unpinMessage", message)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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/
|
// https://rocket.chat/docs/developer-guides/realtime-api/subscriptions/stream-room-messages/
|
||||||
func (c *Client) SubscribeToMessageStream(channel *models.Channel, msgChannel chan models.Message) error {
|
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 {
|
if err := c.ddp.Sub("stream-room-messages", channel.ID, send_added_event); err != nil {
|
||||||
return err
|
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"})
|
c.ddp.CollectionByName("stream-room-messages").AddUpdateListener(messageExtractor{msgChannel, "update"})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -168,7 +167,6 @@ func (c *Client) SubscribeToMessageStream(channel *models.Channel, msgChannel ch
|
||||||
func getMessagesFromUpdateEvent(update ddp.Update) []models.Message {
|
func getMessagesFromUpdateEvent(update ddp.Update) []models.Message {
|
||||||
document, _ := gabs.Consume(update["args"])
|
document, _ := gabs.Consume(update["args"])
|
||||||
args, err := document.Children()
|
args, err := document.Children()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// log.Printf("Event arguments are in an unexpected format: %v", err)
|
// log.Printf("Event arguments are in an unexpected format: %v", err)
|
||||||
return make([]models.Message, 0)
|
return make([]models.Message, 0)
|
||||||
|
@ -206,7 +204,7 @@ func getMessageFromDocument(arg *gabs.Container) *models.Message {
|
||||||
TitleLinkDownload: stringOrZero(attachment.Path("title_link_download").Data()),
|
TitleLinkDownload: stringOrZero(attachment.Path("title_link_download").Data()),
|
||||||
ImageURL: stringOrZero(attachment.Path("image_url").Data()),
|
ImageURL: stringOrZero(attachment.Path("image_url").Data()),
|
||||||
|
|
||||||
AuthorName: stringOrZero(arg.Path("u.name").Data()),
|
AuthorName: stringOrZero(arg.Path("u.name").Data()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ github.com/magiconair/properties
|
||||||
# github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd
|
# github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd
|
||||||
## explicit
|
## explicit
|
||||||
github.com/matrix-org/gomatrix
|
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
|
## explicit
|
||||||
github.com/matterbridge/Rocket.Chat.Go.SDK/models
|
github.com/matterbridge/Rocket.Chat.Go.SDK/models
|
||||||
github.com/matterbridge/Rocket.Chat.Go.SDK/realtime
|
github.com/matterbridge/Rocket.Chat.Go.SDK/realtime
|
||||||
|
|
Loading…
Reference in New Issue