From ddd5936fb1f92432123a9a30d1d3a1fa644a4f8e Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 21 Feb 2020 15:57:53 +0100 Subject: Files&images Mattermost->Matrix works --- connector/mattermost/mattermost.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'connector/mattermost') 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 -- cgit v1.2.3