From 77a1514c900a0d422a616a548496a48cf6baf35f Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 24 Jul 2020 21:47:22 +0300 Subject: Add device list and legacy verification commands --- matrix/matrix.go | 6 ++++-- matrix/rooms/roomcache.go | 13 +++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'matrix') 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() -- cgit v1.2.3