Update Encrypted boolean when receiving m.room.encryption event

This commit is contained in:
Tulir Asokan 2020-04-16 20:16:44 +03:00
parent bb5f9156c9
commit ac1b0540a2

View File

@ -414,6 +414,10 @@ func (room *Room) UpdateState(evt *event.Event) {
room.updateMemberState(evt) room.updateMemberState(evt)
case event.StateTopic: case event.StateTopic:
room.topicCache = evt.Content.Topic room.topicCache = evt.Content.Topic
case event.StateEncryption:
if evt.Content.Algorithm == "m.megolm.v1.aes-sha2" {
room.Encrypted = true
}
} }
if evt.Type != event.StateMember { if evt.Type != event.StateMember {
@ -458,8 +462,8 @@ func (room *Room) GetStateEvent(eventType event.Type, stateKey string) *event.Ev
room.lock.RLock() room.lock.RLock()
defer room.lock.RUnlock() defer room.lock.RUnlock()
stateEventMap, _ := room.state[eventType] stateEventMap, _ := room.state[eventType]
event, _ := stateEventMap[stateKey] evt, _ := stateEventMap[stateKey]
return event return evt
} }
// getStateEvents returns the state events for the given type. // getStateEvents returns the state events for the given type.