diff options
author | Alex Auvolat <alex@adnab.me> | 2020-02-21 18:08:40 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-02-21 18:08:40 +0100 |
commit | fd768a10be36ec31f674fa291fcbe77b78a2855c (patch) | |
tree | bb9e736bfc9425e1ce5ee22379e8d46470af4d18 /appservice | |
parent | ddd5936fb1f92432123a9a30d1d3a1fa644a4f8e (diff) | |
download | easybridge-fd768a10be36ec31f674fa291fcbe77b78a2855c.tar.gz easybridge-fd768a10be36ec31f674fa291fcbe77b78a2855c.zip |
Mattermost media objects in both ways + user/team profile pictures from MM to Matrix
Diffstat (limited to 'appservice')
-rw-r--r-- | appservice/account.go | 19 | ||||
-rw-r--r-- | appservice/server.go | 3 |
2 files changed, 15 insertions, 7 deletions
diff --git a/appservice/account.go b/appservice/account.go index a2b95d7..2df2930 100644 --- a/appservice/account.go +++ b/appservice/account.go @@ -137,7 +137,10 @@ func (a *Account) userInfoUpdatedInternal(user UserID, info *UserInfo) error { } if info.Avatar != nil { - err = fmt.Errorf("Avatar: not implemented") + err2 := mx.ProfileAvatar(mx_user_id, info.Avatar) + if err2 != nil { + err = err2 + } } return err @@ -182,8 +185,10 @@ func (a *Account) roomInfoUpdatedInternal(roomId RoomID, author UserID, info *Ro } if info.Picture != nil { - // TODO - err = fmt.Errorf("Picture: not implemented") + err2 := mx.RoomAvatarAs(mx_room_id, info.Picture, as_mxid) + if err2 != nil { + err = err2 + } } return err @@ -254,8 +259,8 @@ func (a *Account) eventInternal(event *Event) error { return err } - if event.Attachements != nil { - for _, file := range event.Attachements { + if event.Attachments != nil { + for _, file := range event.Attachments { mxfile, err := mx.UploadMedia(file) if err != nil { return err @@ -270,8 +275,8 @@ func (a *Account) eventInternal(event *Event) error { content["info"] = map[string]interface{} { "mimetype": mxfile.Mimetype(), "size": mxfile.Size(), - "width": sz.Width, - "height": sz.Height, + "w": sz.Width, + "h": sz.Height, } } else { content["msgtype"] = "m.file" diff --git a/appservice/server.go b/appservice/server.go index 5a5cebe..d96f27c 100644 --- a/appservice/server.go +++ b/appservice/server.go @@ -123,6 +123,9 @@ func handleTxnEvent(e *mxlib.Event) error { typ := e.Content["msgtype"].(string) if typ == "m.emote" { ev.Type = connector.EVENT_MESSAGE + } else if typ == "m.file" || typ == "m.image" { + ev.Text = "" + ev.Attachments = []connector.MediaObject{mx.ParseMediaInfo(e.Content)} } if pm_room := dbIsPmRoom(e.RoomId); pm_room != nil { |