aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--go.mod2
-rw-r--r--go.sum2
-rw-r--r--matrix/matrix.go39
3 files changed, 20 insertions, 23 deletions
diff --git a/go.mod b/go.mod
index 3a84140..75d4a09 100644
--- a/go.mod
+++ b/go.mod
@@ -21,7 +21,7 @@ require (
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e
gopkg.in/toast.v1 v1.0.0-20180812000517-0a84660828b2
gopkg.in/yaml.v2 v2.2.8
- maunium.net/go/mautrix v0.2.0-beta.3
+ maunium.net/go/mautrix v0.2.0-beta.4
maunium.net/go/mauview v0.1.0
maunium.net/go/tcell v0.1.0
)
diff --git a/go.sum b/go.sum
index 627e4bb..dfaa139 100644
--- a/go.sum
+++ b/go.sum
@@ -75,6 +75,8 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
maunium.net/go/mautrix v0.2.0-beta.3 h1:pm5MQszvzYaLyCEGjyUau4DvzrOw5dT45UAvDLz5zBo=
maunium.net/go/mautrix v0.2.0-beta.3/go.mod h1:WeTUYKrM3/4LZK2bXQ9NRIXnRWKsa+6+OA1gw0nf5G8=
+maunium.net/go/mautrix v0.2.0-beta.4 h1:L7Jpc+8GGc+Qo0DdamACEeU1Ci9G1mergJpsTTgDOUA=
+maunium.net/go/mautrix v0.2.0-beta.4/go.mod h1:WeTUYKrM3/4LZK2bXQ9NRIXnRWKsa+6+OA1gw0nf5G8=
maunium.net/go/mauview v0.1.0 h1:x2WdkKI2zdriJuPAB0CKlwmnHGE7W9xfM5z6RgG+IIg=
maunium.net/go/mauview v0.1.0/go.mod h1:og9WbzmWe9SNYNyOFlCv8qa9zMcOvG2nzRJ5vYyud9U=
maunium.net/go/tcell v0.1.0 h1:XzsEoGCvOw5nac+tlkSLzQcliLYTN4PrtA7ar2ptjSM=
diff --git a/matrix/matrix.go b/matrix/matrix.go
index 722883d..d0fd2f4 100644
--- a/matrix/matrix.go
+++ b/matrix/matrix.go
@@ -26,7 +26,6 @@ import (
"io"
"io/ioutil"
"net/http"
- "net/url"
"os"
"path"
"path/filepath"
@@ -37,18 +36,18 @@ import (
"github.com/pkg/errors"
- "maunium.net/go/gomuks/lib/open"
- "maunium.net/go/gomuks/matrix/muksevt"
"maunium.net/go/mautrix"
"maunium.net/go/mautrix/event"
"maunium.net/go/mautrix/format"
"maunium.net/go/mautrix/id"
+ "maunium.net/go/mautrix/pushrules"
"maunium.net/go/gomuks/config"
"maunium.net/go/gomuks/debug"
"maunium.net/go/gomuks/interface"
+ "maunium.net/go/gomuks/lib/open"
+ "maunium.net/go/gomuks/matrix/muksevt"
"maunium.net/go/gomuks/matrix/rooms"
- "maunium.net/go/mautrix/pushrules"
)
// Container is a wrapper for a mautrix Client and some other stuff.
@@ -301,11 +300,12 @@ func init() {
}
type StubSyncingModal struct{}
-func (s StubSyncingModal) SetIndeterminate() {}
+
+func (s StubSyncingModal) SetIndeterminate() {}
func (s StubSyncingModal) SetMessage(s2 string) {}
-func (s StubSyncingModal) SetSteps(i int) {}
-func (s StubSyncingModal) Step() {}
-func (s StubSyncingModal) Close() {}
+func (s StubSyncingModal) SetSteps(i int) {}
+func (s StubSyncingModal) Step() {}
+func (s StubSyncingModal) Close() {}
// OnLogin initializes the syncer and updates the room list.
func (c *Container) OnLogin() {
@@ -1009,14 +1009,14 @@ func (c *Container) DownloadToDisk(uri id.ContentURI, target string) (fullPath s
}
defer file.Close()
- var resp *http.Response
- resp, err = c.client.Client.Get(c.GetDownloadURL(uri))
+ var body io.ReadCloser
+ body, err = c.client.Download(uri)
if err != nil {
return
}
- defer resp.Body.Close()
+ defer body.Close()
- _, err = io.Copy(file, resp.Body)
+ _, err = io.Copy(file, body)
if err != nil {
return
}
@@ -1051,24 +1051,19 @@ func (c *Container) Download(uri id.ContentURI) (data []byte, err error) {
}
func (c *Container) GetDownloadURL(uri id.ContentURI) string {
- dlURL, _ := url.Parse(c.client.HomeserverURL.String())
- if dlURL.Scheme == "" {
- dlURL.Scheme = "https"
- }
- dlURL.Path = path.Join(dlURL.Path, "/_matrix/media/r0/download", uri.Homeserver, uri.FileID)
- return dlURL.String()
+ return c.client.GetDownloadURL(uri)
}
func (c *Container) download(uri id.ContentURI, cacheFile string) (data []byte, err error) {
- var resp *http.Response
- resp, err = c.client.Client.Get(c.GetDownloadURL(uri))
+ var body io.ReadCloser
+ body, err = c.client.Download(uri)
if err != nil {
return
}
- defer resp.Body.Close()
+ defer body.Close()
var buf bytes.Buffer
- _, err = io.Copy(&buf, resp.Body)
+ _, err = io.Copy(&buf, body)
if err != nil {
return
}