diff options
Diffstat (limited to 'mxlib')
-rw-r--r-- | mxlib/client.go | 30 | ||||
-rw-r--r-- | mxlib/mediaobject.go | 16 | ||||
-rw-r--r-- | mxlib/registration.go | 2 |
3 files changed, 24 insertions, 24 deletions
diff --git a/mxlib/client.go b/mxlib/client.go index e07a67a..f8124d3 100644 --- a/mxlib/client.go +++ b/mxlib/client.go @@ -1,12 +1,12 @@ package mxlib import ( - "strings" "bytes" "encoding/json" "fmt" "net/http" "net/url" + "strings" "time" log "github.com/sirupsen/logrus" @@ -280,7 +280,7 @@ func (mx *Client) RoomAvatarAs(room string, pic connector.MediaObject, as_user s "url": mo.MxcUri(), "info": map[string]interface{}{ "mimetype": mo.Mimetype(), - "size": mo.Size(), + "size": mo.Size(), }, } return mx.PutStateAs(room, "m.room.avatar", "", content, as_user) @@ -309,7 +309,7 @@ func (mx *Client) UploadMedia(m connector.MediaObject) (*MediaObject, error) { mx.Server+"/_matrix/media/r0/upload?filename="+url.QueryEscape(m.Filename()), reader) req.Header.Add("Content-Type", m.Mimetype()) - req.ContentLength = m.Size() // TODO: this wasn't specified as mandatory in the matrix client/server spec, do a PR to fix this + req.ContentLength = m.Size() // TODO: this wasn't specified as mandatory in the matrix client/server spec, do a PR to fix this var resp UploadResponse err = mx.DoAndParse(req, &resp) @@ -323,12 +323,12 @@ func (mx *Client) UploadMedia(m connector.MediaObject) (*MediaObject, error) { } media := &MediaObject{ - mxClient: mx, - filename: m.Filename(), - size: m.Size(), - mimetype: m.Mimetype(), - imageSize: m.ImageSize(), - MxcServer: mxc[0], + mxClient: mx, + filename: m.Filename(), + size: m.Size(), + mimetype: m.Mimetype(), + imageSize: m.ImageSize(), + MxcServer: mxc[0], MxcMediaId: mxc[1], } return media, nil @@ -339,16 +339,16 @@ func (mx *Client) ParseMediaInfo(content map[string]interface{}) *MediaObject { info := content["info"].(map[string]interface{}) mxc := strings.Split(strings.Replace(content["url"].(string), "mxc://", "", 1), "/") media := &MediaObject{ - mxClient: mx, - filename: content["body"].(string), - size: int64(info["size"].(float64)), - mimetype: info["mimetype"].(string), - MxcServer: mxc[0], + mxClient: mx, + filename: content["body"].(string), + size: int64(info["size"].(float64)), + mimetype: info["mimetype"].(string), + MxcServer: mxc[0], MxcMediaId: mxc[1], } if content["msgtype"].(string) == "m.image" { media.imageSize = &connector.ImageSize{ - Width: int(info["w"].(float64)), + Width: int(info["w"].(float64)), Height: int(info["h"].(float64)), } } diff --git a/mxlib/mediaobject.go b/mxlib/mediaobject.go index f29127b..a369cfe 100644 --- a/mxlib/mediaobject.go +++ b/mxlib/mediaobject.go @@ -1,21 +1,21 @@ package mxlib import ( - "io" "fmt" - "net/url" + "io" "net/http" + "net/url" "git.deuxfleurs.fr/Deuxfleurs/easybridge/connector" ) type MediaObject struct { - mxClient *Client - filename string - size int64 - mimetype string - imageSize *connector.ImageSize - MxcServer string + mxClient *Client + filename string + size int64 + mimetype string + imageSize *connector.ImageSize + MxcServer string MxcMediaId string } diff --git a/mxlib/registration.go b/mxlib/registration.go index 5aabdd6..e6cce0f 100644 --- a/mxlib/registration.go +++ b/mxlib/registration.go @@ -10,7 +10,7 @@ type Registration struct { AsToken string `yaml:"as_token"` HsToken string `yaml:"hs_token"` SenderLocalpart string `yaml:"sender_localpart"` - RateLimited bool `yaml:"rate_limited"` + RateLimited bool `yaml:"rate_limited"` Namespaces RegistrationNamespaceSet `yaml:"namespaces"` } |