mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 03:48:12 +03:00
Fix exception when getting models on some redacted event
An exception was triggered because the excepted model body was null for redacted events
This commit is contained in:
parent
0209cc4969
commit
2477632e2b
1 changed files with 2 additions and 10 deletions
|
@ -26,10 +26,8 @@ import org.matrix.android.sdk.api.session.crypto.model.OlmDecryptionResult
|
|||
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
|
||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomMemberContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconLocationDataContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessagePollContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageStickerContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageType
|
||||
import org.matrix.android.sdk.api.session.room.model.message.asMessageAudioEvent
|
||||
import org.matrix.android.sdk.api.session.room.model.relation.RelationDefaultContent
|
||||
|
@ -400,14 +398,8 @@ fun Event.getRelationContent(): RelationDefaultContent? {
|
|||
return if (isEncrypted()) {
|
||||
content.toModel<EncryptedEventContent>()?.relatesTo
|
||||
} else {
|
||||
content.toModel<MessageContent>()?.relatesTo ?: run {
|
||||
// Special cases when there is only a local msgtype for some event types
|
||||
when (getClearType()) {
|
||||
EventType.STICKER -> getClearContent().toModel<MessageStickerContent>()?.relatesTo
|
||||
in EventType.BEACON_LOCATION_DATA.values -> getClearContent().toModel<MessageBeaconLocationDataContent>()?.relatesTo
|
||||
else -> getClearContent()?.get("m.relates_to")?.toContent().toModel()
|
||||
}
|
||||
}
|
||||
content.toModel<MessageContent>()?.relatesTo
|
||||
?: getClearContent()?.get("m.relates_to")?.toContent().toModel() // Special cases when there is only a local msgtype for some event types
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue