Ensure the event is decrypted before applying push rules
This commit is contained in:
parent
ccf971afc4
commit
75559fb21a
@ -45,10 +45,7 @@ class EventMatchCondition(
|
|||||||
if (decryptedRawJson != null) {
|
if (decryptedRawJson != null) {
|
||||||
rawJson
|
rawJson
|
||||||
.toMutableMap()
|
.toMutableMap()
|
||||||
.apply {
|
.apply { putAll(decryptedRawJson) }
|
||||||
set("type", decryptedRawJson["type"])
|
|
||||||
set("content", decryptedRawJson["content"])
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
rawJson
|
rawJson
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,7 @@ internal class EventDecryptor @Inject constructor(
|
|||||||
* @param timeline the id of the timeline where the event is decrypted. It is used to prevent replay attack.
|
* @param timeline the id of the timeline where the event is decrypted. It is used to prevent replay attack.
|
||||||
*/
|
*/
|
||||||
suspend fun decryptEventAndSaveResult(event: Event, timeline: String) {
|
suspend fun decryptEventAndSaveResult(event: Event, timeline: String) {
|
||||||
|
if (event.type == EventType.ENCRYPTED && event.mxDecryptionResult != null) return
|
||||||
tryOrNull(message = "Unable to decrypt the event") {
|
tryOrNull(message = "Unable to decrypt the event") {
|
||||||
decryptEvent(event, timeline)
|
decryptEvent(event, timeline)
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import org.matrix.android.sdk.api.session.events.model.isInvitation
|
|||||||
import org.matrix.android.sdk.api.session.pushrules.PushEvents
|
import org.matrix.android.sdk.api.session.pushrules.PushEvents
|
||||||
import org.matrix.android.sdk.api.session.pushrules.rest.PushRule
|
import org.matrix.android.sdk.api.session.pushrules.rest.PushRule
|
||||||
import org.matrix.android.sdk.api.session.sync.model.RoomsSyncResponse
|
import org.matrix.android.sdk.api.session.sync.model.RoomsSyncResponse
|
||||||
|
import org.matrix.android.sdk.internal.crypto.EventDecryptor
|
||||||
import org.matrix.android.sdk.internal.di.UserId
|
import org.matrix.android.sdk.internal.di.UserId
|
||||||
import org.matrix.android.sdk.internal.task.Task
|
import org.matrix.android.sdk.internal.task.Task
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
@ -36,7 +37,8 @@ internal interface ProcessEventForPushTask : Task<ProcessEventForPushTask.Params
|
|||||||
internal class DefaultProcessEventForPushTask @Inject constructor(
|
internal class DefaultProcessEventForPushTask @Inject constructor(
|
||||||
private val defaultPushRuleService: DefaultPushRuleService,
|
private val defaultPushRuleService: DefaultPushRuleService,
|
||||||
private val pushRuleFinder: PushRuleFinder,
|
private val pushRuleFinder: PushRuleFinder,
|
||||||
@UserId private val userId: String
|
@UserId private val userId: String,
|
||||||
|
private val eventDecryptor: EventDecryptor,
|
||||||
) : ProcessEventForPushTask {
|
) : ProcessEventForPushTask {
|
||||||
|
|
||||||
override suspend fun execute(params: ProcessEventForPushTask.Params) {
|
override suspend fun execute(params: ProcessEventForPushTask.Params) {
|
||||||
@ -73,6 +75,7 @@ internal class DefaultProcessEventForPushTask @Inject constructor(
|
|||||||
" to check for push rules with ${params.rules.size} rules"
|
" to check for push rules with ${params.rules.size} rules"
|
||||||
)
|
)
|
||||||
val matchedEvents = allEvents.mapNotNull { event ->
|
val matchedEvents = allEvents.mapNotNull { event ->
|
||||||
|
eventDecryptor.decryptEventAndSaveResult(event, "")
|
||||||
pushRuleFinder.fulfilledBingRule(event, params.rules)?.let {
|
pushRuleFinder.fulfilledBingRule(event, params.rules)?.let {
|
||||||
Timber.v("[PushRules] Rule $it match for event ${event.eventId}")
|
Timber.v("[PushRules] Rule $it match for event ${event.eventId}")
|
||||||
event to it
|
event to it
|
||||||
|
Loading…
x
Reference in New Issue
Block a user