aboutsummaryrefslogtreecommitdiff
path: root/connector/mattermost
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-02-21 15:57:53 +0100
committerAlex Auvolat <alex@adnab.me>2020-02-21 15:57:53 +0100
commitddd5936fb1f92432123a9a30d1d3a1fa644a4f8e (patch)
tree6a06aac9b5e676a2987f4bf612abea5500155ea2 /connector/mattermost
parent92d380aa86dfd3e60f5b8d826ec96c0fbc17614a (diff)
downloadeasybridge-ddd5936fb1f92432123a9a30d1d3a1fa644a4f8e.tar.gz
easybridge-ddd5936fb1f92432123a9a30d1d3a1fa644a4f8e.zip
Files&images Mattermost->Matrix works
Diffstat (limited to 'connector/mattermost')
-rw-r--r--connector/mattermost/mattermost.go24
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