Update mautrix-go and give crypto module access to state store

This commit is contained in:
Tulir Asokan
2020-05-05 18:39:28 +03:00
parent 788d932bec
commit 22681875f3
5 changed files with 41 additions and 6 deletions

View File

@ -27,6 +27,7 @@ import (
sync "github.com/sasha-s/go-deadlock"
"maunium.net/go/gomuks/debug"
"maunium.net/go/mautrix/event"
"maunium.net/go/mautrix/id"
)
@ -67,6 +68,26 @@ func (cache *RoomCache) EnableUnloading() {
cache.noUnload = false
}
func (cache *RoomCache) IsEncrypted(roomID id.RoomID) bool {
room := cache.Get(roomID)
return room != nil && room.Encrypted
}
func (cache *RoomCache) FindSharedRooms(userID id.UserID) (shared []id.RoomID) {
cache.Lock()
for _, room := range cache.Map {
if !room.Encrypted {
continue
}
member, ok := room.GetMembers()[userID]
if ok && member.Membership == event.MembershipJoin {
shared = append(shared, room.ID)
}
}
cache.Unlock()
return
}
func (cache *RoomCache) LoadList() error {
cache.Lock()
defer cache.Unlock()