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) {
|
||||
rawJson
|
||||
.toMutableMap()
|
||||
.apply {
|
||||
set("type", decryptedRawJson["type"])
|
||||
set("content", decryptedRawJson["content"])
|
||||
}
|
||||
.apply { putAll(decryptedRawJson) }
|
||||
} else {
|
||||
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.
|
||||
*/
|
||||
suspend fun decryptEventAndSaveResult(event: Event, timeline: String) {
|
||||
if (event.type == EventType.ENCRYPTED && event.mxDecryptionResult != null) return
|
||||
tryOrNull(message = "Unable to decrypt the event") {
|
||||
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.rest.PushRule
|
||||
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.task.Task
|
||||
import timber.log.Timber
|
||||
|
@ -36,7 +37,8 @@ internal interface ProcessEventForPushTask : Task<ProcessEventForPushTask.Params
|
|||
internal class DefaultProcessEventForPushTask @Inject constructor(
|
||||
private val defaultPushRuleService: DefaultPushRuleService,
|
||||
private val pushRuleFinder: PushRuleFinder,
|
||||
@UserId private val userId: String
|
||||
@UserId private val userId: String,
|
||||
private val eventDecryptor: EventDecryptor,
|
||||
) : ProcessEventForPushTask {
|
||||
|
||||
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"
|
||||
)
|
||||
val matchedEvents = allEvents.mapNotNull { event ->
|
||||
eventDecryptor.decryptEventAndSaveResult(event, "")
|
||||
pushRuleFinder.fulfilledBingRule(event, params.rules)?.let {
|
||||
Timber.v("[PushRules] Rule $it match for event ${event.eventId}")
|
||||
event to it
|
||||
|
|
Loading…
Reference in New Issue