Removing encrypted related id when receiving decrypted event

This commit is contained in:
Maxime NATUREL 2022-12-21 16:34:54 +01:00 committed by Maxime NATUREL
parent 3b9faa5f31
commit a29d4399a5

View file

@ -45,6 +45,7 @@ import org.matrix.android.sdk.internal.session.room.relation.poll.FetchPollRespo
import org.matrix.android.sdk.internal.task.TaskExecutor
import javax.inject.Inject
// TODO update unit tests
internal class DefaultPollAggregationProcessor @Inject constructor(
private val taskExecutor: TaskExecutor,
private val fetchPollResponseEventsTask: FetchPollResponseEventsTask,
@ -155,7 +156,7 @@ internal class DefaultPollAggregationProcessor @Inject constructor(
)
aggregatedPollSummaryEntity.aggregatedContent = ContentMapper.map(newSumModel.toContent())
// TODO check also if eventId is part of UTD list of eventIds, if so remove it
event.eventId?.let { removeEncryptedRelatedEventIdIfNeeded(aggregatedPollSummaryEntity, it) }
return true
}
@ -182,12 +183,12 @@ internal class DefaultPollAggregationProcessor @Inject constructor(
aggregatedPollSummaryEntity.sourceEvents.add(event.eventId)
}
event.eventId?.let { removeEncryptedRelatedEventIdIfNeeded(aggregatedPollSummaryEntity, it) }
if (!isLocalEcho) {
ensurePollIsFullyAggregated(roomId, pollEventId)
}
// TODO check also if eventId is part of UTD list of eventIds, if so remove it
return true
}
@ -230,4 +231,10 @@ internal class DefaultPollAggregationProcessor @Inject constructor(
fetchPollResponseEventsTask.execute(params)
}
}
private fun removeEncryptedRelatedEventIdIfNeeded(aggregatedPollSummaryEntity: PollResponseAggregatedSummaryEntity, eventId: String) {
if(aggregatedPollSummaryEntity.encryptedRelatedEventIds.contains(eventId)) {
aggregatedPollSummaryEntity.encryptedRelatedEventIds.remove(eventId)
}
}
}