aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2020-04-20 22:46:41 +0300
committerTulir Asokan <tulir@maunium.net>2020-04-20 22:46:41 +0300
commit6b4adccce22b6c2ea81d9dbdd78657ea46f1acbc (patch)
tree4a289d2d8832db45fa9ce02fb57a7d05fa34f3da
parentbc80bc458b8ac9e74780883545116dade8df9bf9 (diff)
Fix loading member events
-rw-r--r--matrix/matrix.go7
-rw-r--r--matrix/rooms/room.go6
2 files changed, 12 insertions, 1 deletions
diff --git a/matrix/matrix.go b/matrix/matrix.go
index 617bbd5..303184f 100644
--- a/matrix/matrix.go
+++ b/matrix/matrix.go
@@ -890,11 +890,18 @@ func (c *Container) LeaveRoom(roomID id.RoomID) error {
}
func (c *Container) FetchMembers(room *rooms.Room) error {
+ debug.Print("Fetching member list for", room.ID)
members, err := c.client.Members(room.ID, mautrix.ReqMembers{At: room.LastPrevBatch})
if err != nil {
return err
}
+ debug.Printf("Fetched %d members for %s", len(members.Chunk), room.ID)
for _, evt := range members.Chunk {
+ err := evt.Content.ParseRaw(evt.Type)
+ if err != nil {
+ debug.Printf("Failed to parse member event of %s: %v", evt.GetStateKey(), err)
+ continue
+ }
room.UpdateState(evt)
}
room.MembersFetched = true
diff --git a/matrix/rooms/room.go b/matrix/rooms/room.go
index 7feae89..0238cfb 100644
--- a/matrix/rooms/room.go
+++ b/matrix/rooms/room.go
@@ -213,6 +213,10 @@ func (room *Room) Unload() bool {
debug.Print("Unloading", room.ID)
room.Save()
room.state = nil
+ room.memberCache = nil
+ room.exMemberCache = nil
+ room.firstMemberCache = nil
+ room.secondMemberCache = nil
if room.postUnload != nil {
room.postUnload()
}
@@ -408,7 +412,7 @@ func (room *Room) UpdateState(evt *event.Event) {
case *event.TopicEventContent:
room.topicCache = content.Topic
case *event.EncryptionEventContent:
- if content.Algorithm == "m.megolm.v1.aes-sha2" {
+ if content.Algorithm == event.AlgorithmMegolmV1 {
room.Encrypted = true
}
}