From 81e8c0a23d62d4ef01b79386a09ec835c8b08e1f Mon Sep 17 00:00:00 2001 From: areebahmeddd Date: Tue, 4 Aug 2026 00:40:55 +0530 Subject: [PATCH] ensure valid creator and key presence when loading groups from disk --- bitchat/Services/Groups/GroupStore.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bitchat/Services/Groups/GroupStore.swift b/bitchat/Services/Groups/GroupStore.swift index 7e570ede..0fd59a1c 100644 --- a/bitchat/Services/Groups/GroupStore.swift +++ b/bitchat/Services/Groups/GroupStore.swift @@ -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? {