Fix loading member events
This commit is contained in:
parent
bc80bc458b
commit
6b4adccce2
@ -890,11 +890,18 @@ func (c *Container) LeaveRoom(roomID id.RoomID) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Container) FetchMembers(room *rooms.Room) 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})
|
members, err := c.client.Members(room.ID, mautrix.ReqMembers{At: room.LastPrevBatch})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
debug.Printf("Fetched %d members for %s", len(members.Chunk), room.ID)
|
||||||
for _, evt := range members.Chunk {
|
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.UpdateState(evt)
|
||||||
}
|
}
|
||||||
room.MembersFetched = true
|
room.MembersFetched = true
|
||||||
|
@ -213,6 +213,10 @@ func (room *Room) Unload() bool {
|
|||||||
debug.Print("Unloading", room.ID)
|
debug.Print("Unloading", room.ID)
|
||||||
room.Save()
|
room.Save()
|
||||||
room.state = nil
|
room.state = nil
|
||||||
|
room.memberCache = nil
|
||||||
|
room.exMemberCache = nil
|
||||||
|
room.firstMemberCache = nil
|
||||||
|
room.secondMemberCache = nil
|
||||||
if room.postUnload != nil {
|
if room.postUnload != nil {
|
||||||
room.postUnload()
|
room.postUnload()
|
||||||
}
|
}
|
||||||
@ -408,7 +412,7 @@ func (room *Room) UpdateState(evt *event.Event) {
|
|||||||
case *event.TopicEventContent:
|
case *event.TopicEventContent:
|
||||||
room.topicCache = content.Topic
|
room.topicCache = content.Topic
|
||||||
case *event.EncryptionEventContent:
|
case *event.EncryptionEventContent:
|
||||||
if content.Algorithm == "m.megolm.v1.aes-sha2" {
|
if content.Algorithm == event.AlgorithmMegolmV1 {
|
||||||
room.Encrypted = true
|
room.Encrypted = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user