aboutsummaryrefslogtreecommitdiff
path: root/matrix
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2020-07-30 14:34:49 +0300
committerTulir Asokan <tulir@maunium.net>2020-07-30 14:34:49 +0300
commit0d12947b1f70745d8023c89e22432f2a1353dfbb (patch)
tree048d98d1484851caaffc3c5463619442d8fee734 /matrix
parentecdd4f08cb262c8f0c988209e6296c068e1d4cf3 (diff)
parent2f5f0674b600f129204958c810843d998f6a2f6a (diff)
Merge branch 'verification'
Fixes #160 Fixes #161
Diffstat (limited to 'matrix')
-rw-r--r--matrix/crypto.go4
-rw-r--r--matrix/matrix.go6
-rw-r--r--matrix/rooms/roomcache.go13
3 files changed, 20 insertions, 3 deletions
diff --git a/matrix/crypto.go b/matrix/crypto.go
index 158a1f2..c549e8a 100644
--- a/matrix/crypto.go
+++ b/matrix/crypto.go
@@ -55,7 +55,9 @@ func (c *Container) initCrypto() error {
if err != nil {
return errors.Wrap(err, "failed to open crypto store")
}
- c.crypto = crypto.NewOlmMachine(c.client, cryptoLogger{}, cryptoStore, c.config.Rooms)
+ crypt := crypto.NewOlmMachine(c.client, cryptoLogger{}, cryptoStore, c.config.Rooms)
+ crypt.AllowUnverifiedDevices = !c.config.SendToVerifiedOnly
+ c.crypto = crypt
err = c.crypto.Load()
if err != nil {
return errors.Wrap(err, "failed to create olm machine")
diff --git a/matrix/matrix.go b/matrix/matrix.go
index b07fa82..f7f308b 100644
--- a/matrix/matrix.go
+++ b/matrix/matrix.go
@@ -162,6 +162,8 @@ func (c *Container) PasswordLogin(user, password string) error {
},
Password: password,
InitialDeviceDisplayName: "gomuks",
+
+ StoreCredentials: true,
})
if err != nil {
return err
@@ -171,8 +173,6 @@ func (c *Container) PasswordLogin(user, password string) error {
}
func (c *Container) finishLogin(resp *mautrix.RespLogin) {
- c.client.SetCredentials(resp.UserID, resp.AccessToken)
- c.client.DeviceID = resp.DeviceID
c.config.UserID = resp.UserID
c.config.DeviceID = resp.DeviceID
c.config.AccessToken = resp.AccessToken
@@ -218,6 +218,8 @@ func (c *Container) SingleSignOn() error {
Type: "m.login.token",
Token: loginToken,
InitialDeviceDisplayName: "gomuks",
+
+ StoreCredentials: true,
})
if err != nil {
respondHTML(w, http.StatusForbidden, err.Error())
diff --git a/matrix/rooms/roomcache.go b/matrix/rooms/roomcache.go
index 5af0c5b..168278b 100644
--- a/matrix/rooms/roomcache.go
+++ b/matrix/rooms/roomcache.go
@@ -73,6 +73,19 @@ func (cache *RoomCache) IsEncrypted(roomID id.RoomID) bool {
return room != nil && room.Encrypted
}
+func (cache *RoomCache) GetEncryptionEvent(roomID id.RoomID) *event.EncryptionEventContent {
+ room := cache.Get(roomID)
+ evt := room.GetStateEvent(event.StateEncryption, "")
+ if evt == nil {
+ return nil
+ }
+ content, ok := evt.Content.Parsed.(*event.EncryptionEventContent)
+ if !ok {
+ return nil
+ }
+ return content
+}
+
func (cache *RoomCache) FindSharedRooms(userID id.UserID) (shared []id.RoomID) {
// FIXME this disables unloading so TouchNode wouldn't try to double-lock
cache.DisableUnloading()