diff options
Diffstat (limited to 'connector/mattermost/mattermost.go')
-rw-r--r-- | connector/mattermost/mattermost.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/connector/mattermost/mattermost.go b/connector/mattermost/mattermost.go index 81adbde..330026a 100644 --- a/connector/mattermost/mattermost.go +++ b/connector/mattermost/mattermost.go @@ -345,6 +345,30 @@ func (mm *Mattermost) handlePosted(msg *model.WebSocketEvent) error { msg_ev.Type = EVENT_ACTION } + // Handle files + if post.FileIds != nil && len(post.FileIds) > 0 { + msg_ev.Attachements = []MediaObject{} + for _, file := range post.Metadata.Files { + blob, resp := mm.conn.Client.GetFile(file.Id) + if resp.Error != nil { + return resp.Error + } + media_object := &BlobMediaObject{ + ObjectFilename: file.Name, + ObjectSize: file.Size, + ObjectMimetype: file.MimeType, + ObjectData: blob, + } + if file.Width > 0 { + media_object.ObjectImageSize = &ImageSize{ + Width: file.Width, + Height: file.Height, + } + } + msg_ev.Attachements = append(msg_ev.Attachements, media_object) + } + } + // Dispatch as PM or as room message if len(strings.Split(channel_name, "__")) == 2 { // Private message, no need to find room id |