Rename and format and remove duplicate EventType.REDACTION

This commit is contained in:
Benoit Marty
2019-06-26 14:35:00 +02:00
committed by Benoit Marty
parent d1642c928a
commit ae7e617fdd
3 changed files with 24 additions and 20 deletions

View File

@ -36,12 +36,15 @@ internal class BingRuleWatcher(monarchy: Monarchy,
override val query = Monarchy.Query<EventEntity> {
EventEntity.types(it, listOf(
EventType.REDACTION, EventType.MESSAGE, EventType.REDACTION, EventType.ENCRYPTED)
EventType.MESSAGE,
EventType.REDACTION,
EventType.ENCRYPTED)
)
}
override fun processChanges(inserted: List<EventEntity>, updated: List<EventEntity>, deleted: List<EventEntity>) {
// TODO Use const for "global"
val rules = defaultPushRuleService.getPushRules("global")
inserted.map { it.asDomain() }
.filter { it.senderId != sessionParams.credentials.userId }

View File

@ -33,18 +33,19 @@ internal class DefaultProcessEventForPushTask(
private fun fulfilledBingRule(event: Event, rules: List<PushRule>): PushRule? {
val conditionResolver = DefaultConditionResolver(event)
rules.filter { it.enabled }.forEach { rule ->
val isFullfilled = rule.conditions?.map {
it.asExecutableCondition()?.isSatisfied(conditionResolver) ?: false
}?.fold(true/*A rule with no conditions always matches*/, { acc, next ->
//All conditions must hold true for an event in order to apply the action for the event.
acc && next
}) ?: false
rules.filter { it.enabled }
.forEach { rule ->
val isFullfilled = rule.conditions?.map {
it.asExecutableCondition()?.isSatisfied(conditionResolver) ?: false
}?.fold(true/*A rule with no conditions always matches*/, { acc, next ->
//All conditions must hold true for an event in order to apply the action for the event.
acc && next
}) ?: false
if (isFullfilled) {
return rule
}
}
if (isFullfilled) {
return rule
}
}
return null
}