Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🟢 Apply (polls) push rules client side for encrypted rooms #1714

Merged
merged 6 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions MatrixSDK/Background/MXBackgroundPushRulesManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ import Foundation
.roomMemberCount: memberCountConditionChecker,
.senderNotificationPermission: permissionConditionChecker
]

let eventDictionary = event.jsonDictionary()
// getting the unencrypted event if present or fallback
let eventDictionary = (event.clear ?? event).jsonDictionary()
let equivalentCondition = MXPushRuleCondition()

for rule in flatRules.filter({ $0.enabled }) {
Expand Down
16 changes: 11 additions & 5 deletions MatrixSDK/Background/MXBackgroundSyncService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,9 @@ public enum MXBackgroundSyncServiceError: Error {
}()

pushRulesManager = MXBackgroundPushRulesManager(withCredentials: credentials)
if let accountData = syncResponseStoreManager.syncResponseStore.accountData {
pushRulesManager.handleAccountData(accountData)
} else if let accountData = store.userAccountData ?? nil {
pushRulesManager.handleAccountData(accountData)
}
MXLog.debug("[MXBackgroundSyncService] init complete")
super.init()
syncPushRuleManagerWithAccountData()
}

/// Fetch event with given event and room identifiers. It performs a sync if the event not found in session store.
Expand Down Expand Up @@ -500,5 +496,15 @@ public enum MXBackgroundSyncServiceError: Error {
MXLog.debug("[MXBackgroundSyncService] updateBackgroundServiceStoresIfNeeded: Reset MXBackgroundCryptoStore")
crypto.reset()
}

syncPushRuleManagerWithAccountData()
}

private func syncPushRuleManagerWithAccountData() {
if let accountData = syncResponseStoreManager.syncResponseStore.accountData {
pushRulesManager.handleAccountData(accountData)
} else if let accountData = store.userAccountData ?? nil {
pushRulesManager.handleAccountData(accountData)
}
alfogrillo marked this conversation as resolved.
Show resolved Hide resolved
}
}
1 change: 1 addition & 0 deletions changelog.d/pr-1714.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Push Rules: Apply push rules client side for encrypted rooms, including mentions and keywords.