From ac1b0540a2f5979346277271ec733d19a0b25228 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 16 Apr 2020 20:16:44 +0300 Subject: Update Encrypted boolean when receiving m.room.encryption event --- matrix/rooms/room.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/matrix/rooms/room.go b/matrix/rooms/room.go index 0c28a9d..50ec28f 100644 --- a/matrix/rooms/room.go +++ b/matrix/rooms/room.go @@ -414,6 +414,10 @@ func (room *Room) UpdateState(evt *event.Event) { room.updateMemberState(evt) case event.StateTopic: 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 { @@ -458,8 +462,8 @@ func (room *Room) GetStateEvent(eventType event.Type, stateKey string) *event.Ev room.lock.RLock() defer room.lock.RUnlock() stateEventMap, _ := room.state[eventType] - event, _ := stateEventMap[stateKey] - return event + evt, _ := stateEventMap[stateKey] + return evt } // getStateEvents returns the state events for the given type. -- cgit v1.2.3