4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-06-26 08:39:24 +00:00

Update matterbridge/Rocket.Chat.Go.SDK (#1087)

This commit is contained in:
Wim
2020-04-16 21:48:53 +02:00
committed by GitHub
parent 976fbcd07f
commit 13c90893c7
5 changed files with 30 additions and 4 deletions

View File

@ -7,6 +7,7 @@ type Message struct {
RoomID string `json:"rid"`
Msg string `json:"msg"`
EditedBy string `json:"editedBy,omitempty"`
Type string `json:"t,omitempty"`
Groupable bool `json:"groupable,omitempty"`
@ -16,6 +17,9 @@ type Message struct {
Mentions []User `json:"mentions,omitempty"`
User *User `json:"u,omitempty"`
Attachments []Attachment `json:"attachments,omitempty"`
PostMessage
// Bot interface{} `json:"bot"`

View File

@ -191,6 +191,26 @@ func getMessageFromData(data interface{}) *models.Message {
func getMessageFromDocument(arg *gabs.Container) *models.Message {
var ts *time.Time
var attachments []models.Attachment
attachmentSrc, err := arg.Path("attachments").Children()
if err != nil {
attachments = make([]models.Attachment, 0)
} else {
attachments = make([]models.Attachment, len(attachmentSrc))
for i, attachment := range attachmentSrc {
attachments[i] = models.Attachment{
Timestamp: stringOrZero(attachment.Path("ts").Data()),
Title: stringOrZero(attachment.Path("title").Data()),
TitleLink: stringOrZero(attachment.Path("title_link").Data()),
TitleLinkDownload: stringOrZero(attachment.Path("title_link_download").Data()),
ImageURL: stringOrZero(attachment.Path("image_url").Data()),
AuthorName: stringOrZero(arg.Path("u.name").Data()),
}
}
}
date := stringOrZero(arg.Path("ts.$date").Data())
if len(date) > 0 {
if ti, err := strconv.ParseFloat(date, 64); err == nil {
@ -202,11 +222,13 @@ func getMessageFromDocument(arg *gabs.Container) *models.Message {
ID: stringOrZero(arg.Path("_id").Data()),
RoomID: stringOrZero(arg.Path("rid").Data()),
Msg: stringOrZero(arg.Path("msg").Data()),
Type: stringOrZero(arg.Path("t").Data()),
Timestamp: ts,
User: &models.User{
ID: stringOrZero(arg.Path("u._id").Data()),
UserName: stringOrZero(arg.Path("u.username").Data()),
},
Attachments: attachments,
}
}

2
vendor/modules.txt vendored
View File

@ -95,7 +95,7 @@ github.com/labstack/gommon/random
github.com/lrstanley/girc
# github.com/magiconair/properties v1.8.1
github.com/magiconair/properties
# github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20190210153444-cc9d05784d5d
# github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20200411204219-d5c18ce75048
github.com/matterbridge/Rocket.Chat.Go.SDK/models
github.com/matterbridge/Rocket.Chat.Go.SDK/realtime
github.com/matterbridge/Rocket.Chat.Go.SDK/rest