aboutsummaryrefslogtreecommitdiff
path: root/matrix/rooms
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2020-05-05 18:39:28 +0300
committerTulir Asokan <tulir@maunium.net>2020-05-05 18:39:28 +0300
commit22681875f32fa97f65c9a52e2ee666932706ce95 (patch)
treec5e817a817142c47d40db32285382291aba48347 /matrix/rooms
parent788d932bec16f25a37bb0bbec03a0eaf4bcefffd (diff)
Update mautrix-go and give crypto module access to state store
Diffstat (limited to 'matrix/rooms')
-rw-r--r--matrix/rooms/roomcache.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/matrix/rooms/roomcache.go b/matrix/rooms/roomcache.go
index ffdcad1..d66078c 100644
--- a/matrix/rooms/roomcache.go
+++ b/matrix/rooms/roomcache.go
@@ -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()