ensure valid creator and key presence when loading groups from disk

This commit is contained in:
areebahmeddd 2026-08-04 00:40:55 +05:30
parent fab2abe5d2
commit 81e8c0a23d
No known key found for this signature in database
GPG Key ID: 3246A173263AD93A

View File

@ -190,8 +190,11 @@ final class GroupStore: ObservableObject {
let stored = try? JSONDecoder().decode([BitchatGroup].self, from: data) else {
return
}
// Only groups whose key survived in the keychain are usable.
groups = stored.filter { key(forGroupID: $0.groupID) != nil }
// Only groups whose key survived in the keychain are usable. Disk bypasses
// `upsert`, so re-check the creator invariant to avoid unmatchable creators.
groups = stored.filter {
!$0.creatorFingerprint.isEmpty && $0.creator != nil && key(forGroupID: $0.groupID) != nil
}
}
private static func defaultFileURL() -> URL? {