aboutsummaryrefslogtreecommitdiff
path: root/mxlib/client.go
diff options
context:
space:
mode:
Diffstat (limited to 'mxlib/client.go')
-rw-r--r--mxlib/client.go30
1 files changed, 15 insertions, 15 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)),
}
}