Keep track of related events to a poll which had failed to be decrypted
This commit is contained in:
parent
f4cbc0ba7f
commit
14b75f35b1
@ -23,5 +23,7 @@ data class PollResponseAggregatedSummary(
|
|||||||
val nbOptions: Int = 0,
|
val nbOptions: Int = 0,
|
||||||
// The list of the eventIDs used to build the summary (might be out of sync if chunked received from message chunk)
|
// The list of the eventIDs used to build the summary (might be out of sync if chunked received from message chunk)
|
||||||
val sourceEvents: List<String>,
|
val sourceEvents: List<String>,
|
||||||
val localEchos: List<String>
|
val localEchos: List<String>,
|
||||||
|
// list of related event ids which are encrypted due to decryption failure
|
||||||
|
val encryptedRelatedEventIds: List<String>,
|
||||||
)
|
)
|
||||||
|
@ -40,9 +40,6 @@ internal class EventInsertLiveObserver @Inject constructor(
|
|||||||
|
|
||||||
private val lock = Mutex()
|
private val lock = Mutex()
|
||||||
|
|
||||||
// TODO should we create a dedicated UnableToDecryptEntity or EncryptedEventEntity?
|
|
||||||
// and process them into a dedicated observer?
|
|
||||||
// Create also a new LiveProcessor interface for the new entity?
|
|
||||||
override val query = Monarchy.Query {
|
override val query = Monarchy.Query {
|
||||||
it.where(EventInsertEntity::class.java).equalTo(EventInsertEntityFields.CAN_BE_PROCESSED, true)
|
it.where(EventInsertEntity::class.java).equalTo(EventInsertEntityFields.CAN_BE_PROCESSED, true)
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,8 @@ internal object PollResponseAggregatedSummaryEntityMapper {
|
|||||||
closedTime = entity.closedTime,
|
closedTime = entity.closedTime,
|
||||||
localEchos = entity.sourceLocalEchoEvents.toList(),
|
localEchos = entity.sourceLocalEchoEvents.toList(),
|
||||||
sourceEvents = entity.sourceEvents.toList(),
|
sourceEvents = entity.sourceEvents.toList(),
|
||||||
nbOptions = entity.nbOptions
|
nbOptions = entity.nbOptions,
|
||||||
|
encryptedRelatedEventIds = entity.encryptedRelatedEventIds.toList(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +41,8 @@ internal object PollResponseAggregatedSummaryEntityMapper {
|
|||||||
nbOptions = model.nbOptions,
|
nbOptions = model.nbOptions,
|
||||||
closedTime = model.closedTime,
|
closedTime = model.closedTime,
|
||||||
sourceEvents = RealmList<String>().apply { addAll(model.sourceEvents) },
|
sourceEvents = RealmList<String>().apply { addAll(model.sourceEvents) },
|
||||||
sourceLocalEchoEvents = RealmList<String>().apply { addAll(model.localEchos) }
|
sourceLocalEchoEvents = RealmList<String>().apply { addAll(model.localEchos) },
|
||||||
|
encryptedRelatedEventIds = RealmList<String>().apply { addAll(model.encryptedRelatedEventIds) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,9 +33,10 @@ internal open class PollResponseAggregatedSummaryEntity(
|
|||||||
|
|
||||||
// The list of the eventIDs used to build the summary (might be out of sync if chunked received from message chunk)
|
// The list of the eventIDs used to build the summary (might be out of sync if chunked received from message chunk)
|
||||||
var sourceEvents: RealmList<String> = RealmList(),
|
var sourceEvents: RealmList<String> = RealmList(),
|
||||||
var sourceLocalEchoEvents: RealmList<String> = RealmList()
|
var sourceLocalEchoEvents: RealmList<String> = RealmList(),
|
||||||
|
// list of related event ids which are encrypted due to decryption failure
|
||||||
|
var encryptedRelatedEventIds: RealmList<String> = RealmList(),
|
||||||
) : RealmObject() {
|
) : RealmObject() {
|
||||||
|
|
||||||
// TODO add a list of related eventIds which could not be decrypted
|
|
||||||
companion object
|
companion object
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,8 @@ import org.matrix.android.sdk.internal.database.model.threads.ThreadSummaryEntit
|
|||||||
SpaceParentSummaryEntity::class,
|
SpaceParentSummaryEntity::class,
|
||||||
UserPresenceEntity::class,
|
UserPresenceEntity::class,
|
||||||
ThreadSummaryEntity::class,
|
ThreadSummaryEntity::class,
|
||||||
ThreadListPageEntity::class
|
ThreadListPageEntity::class,
|
||||||
|
UnableToDecryptEventEntity::class,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
internal class SessionRealmModule
|
internal class SessionRealmModule
|
||||||
|
@ -75,7 +75,7 @@ internal class EncryptedEventRelationsAggregationProcessor @Inject constructor(
|
|||||||
RelationType.REFERENCE -> {
|
RelationType.REFERENCE -> {
|
||||||
// can we / should we do we something for UTD reference??
|
// can we / should we do we something for UTD reference??
|
||||||
Timber.w("## UTD reference in room $roomId related to ${encryptedEventContent.relatesTo.eventId}")
|
Timber.w("## UTD reference in room $roomId related to ${encryptedEventContent.relatesTo.eventId}")
|
||||||
encryptedReferenceAggregationProcessor.handle(realm, event, roomId, isLocalEcho, encryptedEventContent.relatesTo.eventId)
|
encryptedReferenceAggregationProcessor.handle(realm, event, isLocalEcho, encryptedEventContent.relatesTo.eventId)
|
||||||
}
|
}
|
||||||
RelationType.ANNOTATION -> {
|
RelationType.ANNOTATION -> {
|
||||||
// can we / should we do we something for UTD annotation??
|
// can we / should we do we something for UTD annotation??
|
||||||
|
@ -18,6 +18,8 @@ package org.matrix.android.sdk.internal.session.room.aggregation.utd
|
|||||||
|
|
||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
import org.matrix.android.sdk.api.session.events.model.Event
|
import org.matrix.android.sdk.api.session.events.model.Event
|
||||||
|
import org.matrix.android.sdk.internal.database.model.PollResponseAggregatedSummaryEntity
|
||||||
|
import org.matrix.android.sdk.internal.database.model.PollResponseAggregatedSummaryEntityFields
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class EncryptedReferenceAggregationProcessor @Inject constructor() {
|
class EncryptedReferenceAggregationProcessor @Inject constructor() {
|
||||||
@ -26,23 +28,28 @@ class EncryptedReferenceAggregationProcessor @Inject constructor() {
|
|||||||
fun handle(
|
fun handle(
|
||||||
realm: Realm,
|
realm: Realm,
|
||||||
event: Event,
|
event: Event,
|
||||||
roomId: String,
|
|
||||||
isLocalEcho: Boolean,
|
isLocalEcho: Boolean,
|
||||||
relatedEventId: String?
|
relatedEventId: String?
|
||||||
) {
|
) {
|
||||||
if(isLocalEcho || relatedEventId.isNullOrEmpty()) return
|
if (isLocalEcho || relatedEventId.isNullOrEmpty()) return
|
||||||
|
|
||||||
handlePollReference(realm = realm, event = event, roomId = roomId, relatedEventId = relatedEventId)
|
handlePollReference(realm = realm, event = event, relatedEventId = relatedEventId)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO how to check this is working?
|
|
||||||
private fun handlePollReference(
|
private fun handlePollReference(
|
||||||
realm: Realm,
|
realm: Realm,
|
||||||
event: Event,
|
event: Event,
|
||||||
roomId: String,
|
|
||||||
relatedEventId: String
|
relatedEventId: String
|
||||||
) {
|
) {
|
||||||
// TODO check if relatedEventId is referencing any existing poll event in DB
|
event.eventId?.let { eventId ->
|
||||||
// TODO if related to a poll, then add the event id into the list of encryptedRelatedEvents in the summary
|
val existingRelatedPoll = getPollSummaryWithEventId(realm, relatedEventId)
|
||||||
|
existingRelatedPoll?.encryptedRelatedEventIds?.add(eventId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getPollSummaryWithEventId(realm: Realm, eventId: String): PollResponseAggregatedSummaryEntity? {
|
||||||
|
return realm.where(PollResponseAggregatedSummaryEntity::class.java)
|
||||||
|
.containsValue(PollResponseAggregatedSummaryEntityFields.SOURCE_EVENTS.`$`, eventId)
|
||||||
|
.findFirst()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ class PollItemViewStateFactory @Inject constructor(
|
|||||||
pollContent: MessagePollContent,
|
pollContent: MessagePollContent,
|
||||||
informationData: MessageInformationData,
|
informationData: MessageInformationData,
|
||||||
): PollViewState {
|
): PollViewState {
|
||||||
// TODO check for decryption failure error in informationData
|
// TODO add new field in ViewState to reflect decryption error of related events
|
||||||
val pollCreationInfo = pollContent.getBestPollCreationInfo()
|
val pollCreationInfo = pollContent.getBestPollCreationInfo()
|
||||||
|
|
||||||
val question = pollCreationInfo?.question?.getBestQuestion().orEmpty()
|
val question = pollCreationInfo?.question?.getBestQuestion().orEmpty()
|
||||||
|
Loading…
Reference in New Issue
Block a user