Reorder signature for clarity
This commit is contained in:
parent
7e2a5e55f7
commit
c43479420a
|
@ -88,12 +88,12 @@ internal class EventRelationsAggregationProcessor @Inject constructor(
|
||||||
EventType.REACTION -> {
|
EventType.REACTION -> {
|
||||||
// we got a reaction!!
|
// we got a reaction!!
|
||||||
Timber.v("###REACTION in room $roomId , reaction eventID ${event.eventId}")
|
Timber.v("###REACTION in room $roomId , reaction eventID ${event.eventId}")
|
||||||
handleReaction(event, roomId, realm, isLocalEcho)
|
handleReaction(realm, event, roomId, isLocalEcho)
|
||||||
}
|
}
|
||||||
EventType.MESSAGE -> {
|
EventType.MESSAGE -> {
|
||||||
if (event.unsignedData?.relations?.annotations != null) {
|
if (event.unsignedData?.relations?.annotations != null) {
|
||||||
Timber.v("###REACTION Agreggation in room $roomId for event ${event.eventId}")
|
Timber.v("###REACTION Aggregation in room $roomId for event ${event.eventId}")
|
||||||
handleInitialAggregatedRelations(event, roomId, event.unsignedData.relations.annotations, realm)
|
handleInitialAggregatedRelations(realm, event, roomId, event.unsignedData.relations.annotations)
|
||||||
|
|
||||||
EventAnnotationsSummaryEntity.where(realm, roomId, event.eventId ?: "").findFirst()
|
EventAnnotationsSummaryEntity.where(realm, roomId, event.eventId ?: "").findFirst()
|
||||||
?.let {
|
?.let {
|
||||||
|
@ -164,7 +164,7 @@ internal class EventRelationsAggregationProcessor @Inject constructor(
|
||||||
if (event.getClearType() == EventType.REACTION) {
|
if (event.getClearType() == EventType.REACTION) {
|
||||||
// we got a reaction!!
|
// we got a reaction!!
|
||||||
Timber.v("###REACTION e2e in room $roomId , reaction eventID ${event.eventId}")
|
Timber.v("###REACTION e2e in room $roomId , reaction eventID ${event.eventId}")
|
||||||
handleReaction(event, roomId, realm, isLocalEcho)
|
handleReaction(realm, event, roomId, isLocalEcho)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,11 +180,11 @@ internal class EventRelationsAggregationProcessor @Inject constructor(
|
||||||
// was this event a m.replace
|
// was this event a m.replace
|
||||||
val contentModel = ContentMapper.map(eventToPrune.content)?.toModel<MessageContent>()
|
val contentModel = ContentMapper.map(eventToPrune.content)?.toModel<MessageContent>()
|
||||||
if (RelationType.REPLACE == contentModel?.relatesTo?.type && contentModel.relatesTo?.eventId != null) {
|
if (RelationType.REPLACE == contentModel?.relatesTo?.type && contentModel.relatesTo?.eventId != null) {
|
||||||
handleRedactionOfReplace(eventToPrune, contentModel.relatesTo!!.eventId!!, realm)
|
handleRedactionOfReplace(realm, eventToPrune, contentModel.relatesTo!!.eventId!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EventType.REACTION -> {
|
EventType.REACTION -> {
|
||||||
handleReactionRedact(eventToPrune, realm)
|
handleReactionRedact(realm, eventToPrune)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -361,7 +361,10 @@ internal class EventRelationsAggregationProcessor @Inject constructor(
|
||||||
existingPollSummary.aggregatedContent = ContentMapper.map(sumModel.toContent())
|
existingPollSummary.aggregatedContent = ContentMapper.map(sumModel.toContent())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleInitialAggregatedRelations(event: Event, roomId: String, aggregation: AggregatedAnnotation, realm: Realm) {
|
private fun handleInitialAggregatedRelations(realm: Realm,
|
||||||
|
event: Event,
|
||||||
|
roomId: String,
|
||||||
|
aggregation: AggregatedAnnotation) {
|
||||||
if (SHOULD_HANDLE_SERVER_AGREGGATION) {
|
if (SHOULD_HANDLE_SERVER_AGREGGATION) {
|
||||||
aggregation.chunk?.forEach {
|
aggregation.chunk?.forEach {
|
||||||
if (it.type == EventType.REACTION) {
|
if (it.type == EventType.REACTION) {
|
||||||
|
@ -383,7 +386,10 @@ internal class EventRelationsAggregationProcessor @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleReaction(event: Event, roomId: String, realm: Realm, isLocalEcho: Boolean) {
|
private fun handleReaction(realm: Realm,
|
||||||
|
event: Event,
|
||||||
|
roomId: String,
|
||||||
|
isLocalEcho: Boolean) {
|
||||||
val content = event.content.toModel<ReactionContent>()
|
val content = event.content.toModel<ReactionContent>()
|
||||||
if (content == null) {
|
if (content == null) {
|
||||||
Timber.e("Malformed reaction content ${event.content}")
|
Timber.e("Malformed reaction content ${event.content}")
|
||||||
|
@ -448,7 +454,9 @@ internal class EventRelationsAggregationProcessor @Inject constructor(
|
||||||
/**
|
/**
|
||||||
* Called when an event is deleted
|
* Called when an event is deleted
|
||||||
*/
|
*/
|
||||||
private fun handleRedactionOfReplace(redacted: EventEntity, relatedEventId: String, realm: Realm) {
|
private fun handleRedactionOfReplace(realm: Realm,
|
||||||
|
redacted: EventEntity,
|
||||||
|
relatedEventId: String) {
|
||||||
Timber.d("Handle redaction of m.replace")
|
Timber.d("Handle redaction of m.replace")
|
||||||
val eventSummary = EventAnnotationsSummaryEntity.where(realm, redacted.roomId, relatedEventId).findFirst()
|
val eventSummary = EventAnnotationsSummaryEntity.where(realm, redacted.roomId, relatedEventId).findFirst()
|
||||||
if (eventSummary == null) {
|
if (eventSummary == null) {
|
||||||
|
@ -464,7 +472,8 @@ internal class EventRelationsAggregationProcessor @Inject constructor(
|
||||||
sourceToDiscard.deleteFromRealm()
|
sourceToDiscard.deleteFromRealm()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleReactionRedact(eventToPrune: EventEntity, realm: Realm) {
|
private fun handleReactionRedact(realm: Realm,
|
||||||
|
eventToPrune: EventEntity) {
|
||||||
Timber.v("REDACTION of reaction ${eventToPrune.eventId}")
|
Timber.v("REDACTION of reaction ${eventToPrune.eventId}")
|
||||||
// delete a reaction, need to update the annotation summary if any
|
// delete a reaction, need to update the annotation summary if any
|
||||||
val reactionContent: ReactionContent = EventMapper.map(eventToPrune).content.toModel() ?: return
|
val reactionContent: ReactionContent = EventMapper.map(eventToPrune).content.toModel() ?: return
|
||||||
|
|
Loading…
Reference in New Issue