From 2adb8c2e1bf1ea3ee924bf1dd11253d56edc5c32 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Mon, 21 Aug 2023 10:44:32 +0300 Subject: [PATCH 1/4] Fix power level events force unwrap crash --- MatrixSDK/Space/MXSpace.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MatrixSDK/Space/MXSpace.swift b/MatrixSDK/Space/MXSpace.swift index 6c1533c436..c60312cde9 100644 --- a/MatrixSDK/Space/MXSpace.swift +++ b/MatrixSDK/Space/MXSpace.swift @@ -346,7 +346,11 @@ public class MXSpace: NSObject { /// /// - Returns: the mimnimum power level required to add a room to this space public func minimumPowerLevelForAddingRoom(with powerLevels: MXRoomPowerLevels) -> Int { - return powerLevels.events["m.space.child"] as? Int ?? powerLevels.stateDefault + guard let events = powerLevels.events else { + return powerLevels.stateDefault + } + + return events["m.space.child"] as? Int ?? powerLevels.stateDefault } // MARK: - Private From 42a57e0d4a1ff40a0906fd4b1f2151e69cccbda6 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Tue, 22 Aug 2023 13:21:15 +0300 Subject: [PATCH 2/4] Prevent keyed archiver encoding crashes when writing read receipts to the file store --- MatrixSDK/Data/Store/MXFileStore/MXFileStore.m | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/MatrixSDK/Data/Store/MXFileStore/MXFileStore.m b/MatrixSDK/Data/Store/MXFileStore/MXFileStore.m index e2bfc932f1..5207df6c6a 100644 --- a/MatrixSDK/Data/Store/MXFileStore/MXFileStore.m +++ b/MatrixSDK/Data/Store/MXFileStore/MXFileStore.m @@ -2209,7 +2209,23 @@ - (void)saveReceipts // Store new data [self checkFolderExistenceForRoom:roomId forBackup:NO]; - [NSKeyedArchiver archiveRootObject:receiptsStore toFile:file]; + + NSError *error = nil; + NSData *result = [NSKeyedArchiver archivedDataWithRootObject:receiptsStore requiringSecureCoding:false error:&error]; + + if (error != nil) + { + MXLogErrorDetails(@"Failed archiving receipts store", error); + continue; + } + + [result writeToURL:[NSURL fileURLWithPath:file] options: NSDataWritingAtomic error: &error]; + + if (error != nil) + { + MXLogErrorDetails(@"Failed writing receipts store to file", error); + continue; + } } } } From b4d682f88ca0ed5a59617869be7ff850a2942e97 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Tue, 22 Aug 2023 14:41:45 +0300 Subject: [PATCH 3/4] Fixes #7636 - Sound stopped working on push notifications --- MatrixSDK/Background/MXBackgroundPushRulesManager.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/MatrixSDK/Background/MXBackgroundPushRulesManager.swift b/MatrixSDK/Background/MXBackgroundPushRulesManager.swift index da793d2eef..8c3d3bffc0 100644 --- a/MatrixSDK/Background/MXBackgroundPushRulesManager.swift +++ b/MatrixSDK/Background/MXBackgroundPushRulesManager.swift @@ -42,7 +42,9 @@ import Foundation } } - flatRules = tmpRules + // vector-im/element-ios/issues/7636 + // Intentionally disable new backend push rules as they're not handle properly and break notification sounds + flatRules = tmpRules.filter { $0.ruleId != ".m.rule.is_user_mention" && $0.ruleId != ".m.rule.is_room_mention" } } } private var flatRules: [MXPushRule] = [] @@ -129,7 +131,9 @@ import Foundation var conditionsOk: Bool = true var runEquivalent: Bool = false - guard let kind = MXPushRuleKind(identifier: rule.kind) else { continue } + guard let kind = MXPushRuleKind(identifier: rule.kind) else { + continue + } switch kind { case .override, .underride: From ff18f2f162c2f28ff8b02b2e951d80cc32bce38c Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Wed, 23 Aug 2023 16:02:19 +0300 Subject: [PATCH 4/4] Add changelogs --- changelog.d/1810.bugfix | 1 + changelog.d/7636.bugfix | 1 + changelog.d/pr-1809.bugfix | 1 + 3 files changed, 3 insertions(+) create mode 100644 changelog.d/1810.bugfix create mode 100644 changelog.d/7636.bugfix create mode 100644 changelog.d/pr-1809.bugfix diff --git a/changelog.d/1810.bugfix b/changelog.d/1810.bugfix new file mode 100644 index 0000000000..a81a4fd724 --- /dev/null +++ b/changelog.d/1810.bugfix @@ -0,0 +1 @@ +Prevent keyed archiver encoding crashes when writing read receipts to the file store \ No newline at end of file diff --git a/changelog.d/7636.bugfix b/changelog.d/7636.bugfix new file mode 100644 index 0000000000..b338f87889 --- /dev/null +++ b/changelog.d/7636.bugfix @@ -0,0 +1 @@ +Fix incoming push notifications not triggering sounds \ No newline at end of file diff --git a/changelog.d/pr-1809.bugfix b/changelog.d/pr-1809.bugfix new file mode 100644 index 0000000000..2991fed95c --- /dev/null +++ b/changelog.d/pr-1809.bugfix @@ -0,0 +1 @@ +Fixes power level events force unwrap crash \ No newline at end of file