From db2ec165de6067d01d849f5ed7b59001cfcd7673 Mon Sep 17 00:00:00 2001 From: Max Radermacher Date: Mon, 20 Apr 2026 11:52:11 -0500 Subject: [PATCH] Remove shouldLeaveIfGroup/shouldLeave parameters --- .../MessageRequestDecliner.swift | 1 - .../Archiving/BackupArchive+Shims.swift | 2 +- .../Contacts/OWSSyncManager.swift | 6 +++--- SignalServiceKit/Groups/GroupManager.swift | 21 ------------------- .../Messages/BlockingManager.swift | 14 +++---------- .../StorageServiceProto+Sync.swift | 2 +- .../tests/Contacts/BlockingManagerTests.swift | 2 -- .../tests/Stories/StoryManagerTest.swift | 1 - SignalUI/Utils/BlockListUIUtils.swift | 1 - 9 files changed, 8 insertions(+), 42 deletions(-) diff --git a/Signal/ConversationView/MessageRequestDecliner.swift b/Signal/ConversationView/MessageRequestDecliner.swift index e9c1bf7557..785b5534be 100644 --- a/Signal/ConversationView/MessageRequestDecliner.swift +++ b/Signal/ConversationView/MessageRequestDecliner.swift @@ -32,7 +32,6 @@ enum MessageRequestDecliner { blockingManager.addBlockedThread( thread, blockMode: .local, - shouldLeaveIfGroup: false, transaction: tx, ) } diff --git a/SignalServiceKit/Backups/Archiving/BackupArchive+Shims.swift b/SignalServiceKit/Backups/Archiving/BackupArchive+Shims.swift index 30186b9360..3dbb94756d 100644 --- a/SignalServiceKit/Backups/Archiving/BackupArchive+Shims.swift +++ b/SignalServiceKit/Backups/Archiving/BackupArchive+Shims.swift @@ -79,7 +79,7 @@ public class _MessageBackup_BlockingManagerWrapper: _MessageBackup_BlockingManag } public func addBlockedGroupId(_ groupId: Data, tx: DBWriteTransaction) { - blockingManager.addBlockedGroupId(groupId, blockMode: .restoreFromBackup, shouldLeave: false, transaction: tx) + blockingManager.addBlockedGroupId(groupId, blockMode: .restoreFromBackup, transaction: tx) } } diff --git a/SignalServiceKit/Contacts/OWSSyncManager.swift b/SignalServiceKit/Contacts/OWSSyncManager.swift index 9866ea3630..322831cb32 100644 --- a/SignalServiceKit/Contacts/OWSSyncManager.swift +++ b/SignalServiceKit/Contacts/OWSSyncManager.swift @@ -348,18 +348,18 @@ extension OWSSyncManager: SyncManagerProtocol, SyncManagerProtocolSwift { tx: transaction, ) case .block: - SSKEnvironment.shared.blockingManagerRef.addBlockedThread(thread, blockMode: .remote, shouldLeaveIfGroup: false, transaction: transaction) + SSKEnvironment.shared.blockingManagerRef.addBlockedThread(thread, blockMode: .remote, transaction: transaction) case .blockAndDelete: DependenciesBridge.shared.threadSoftDeleteManager.softDelete( threads: [thread], sendDeleteForMeSyncMessage: false, tx: transaction, ) - SSKEnvironment.shared.blockingManagerRef.addBlockedThread(thread, blockMode: .remote, shouldLeaveIfGroup: false, transaction: transaction) + SSKEnvironment.shared.blockingManagerRef.addBlockedThread(thread, blockMode: .remote, transaction: transaction) case .spam: TSInfoMessage(thread: thread, messageType: .reportedSpam).anyInsert(transaction: transaction) case .blockAndSpam: - SSKEnvironment.shared.blockingManagerRef.addBlockedThread(thread, blockMode: .remote, shouldLeaveIfGroup: false, transaction: transaction) + SSKEnvironment.shared.blockingManagerRef.addBlockedThread(thread, blockMode: .remote, transaction: transaction) TSInfoMessage(thread: thread, messageType: .reportedSpam).anyInsert(transaction: transaction) case .unknown, .none: owsFailDebug("unexpected message request response type") diff --git a/SignalServiceKit/Groups/GroupManager.swift b/SignalServiceKit/Groups/GroupManager.swift index 99ff1bb3bd..2ea8c34298 100644 --- a/SignalServiceKit/Groups/GroupManager.swift +++ b/SignalServiceKit/Groups/GroupManager.swift @@ -415,27 +415,6 @@ public class GroupManager: NSObject { ) } - public static func leaveGroupOrDeclineInviteAsyncWithoutUI(groupThread: TSGroupThread, tx: DBWriteTransaction) { - guard groupThread.groupModel.groupMembership.isLocalUserMemberOfAnyKind else { - owsFailDebug("unexpectedly trying to leave group for which we're not a member.") - return - } - - tx.addSyncCompletion { - Task { - let databaseStorage = SSKEnvironment.shared.databaseStorageRef - let leavePromise = await databaseStorage.awaitableWrite { tx in - return self.localLeaveGroupOrDeclineInvite(groupThread: groupThread, tx: tx) - } - do { - _ = try await leavePromise.awaitable() - } catch { - owsFailDebug("Couldn't leave group: \(error)") - } - } - } - } - // MARK: - Remove From Group / Revoke Invite public static func removeFromGroupOrRevokeInviteV2( diff --git a/SignalServiceKit/Messages/BlockingManager.swift b/SignalServiceKit/Messages/BlockingManager.swift index 45a509beb8..1c37122b76 100644 --- a/SignalServiceKit/Messages/BlockingManager.swift +++ b/SignalServiceKit/Messages/BlockingManager.swift @@ -225,7 +225,7 @@ public class BlockingManager { didUpdate(wasLocallyInitiated: wasLocallyInitiated, tx: tx) } - public func addBlockedGroupId(_ groupId: Data, blockMode: BlockMode, shouldLeave: Bool, transaction: DBWriteTransaction) { + public func addBlockedGroupId(_ groupId: Data, blockMode: BlockMode, transaction: DBWriteTransaction) { guard GroupManager.isValidGroupIdOfAnyKind(groupId) else { owsFailDebug("Can't block invalid groupId: \(groupId.toHex())") return @@ -247,14 +247,6 @@ public class BlockingManager { } if let groupThread { - // Quit the group if we're a member. - if shouldLeave, groupThread.groupModel.groupMembership.isLocalUserMemberOfAnyKind { - GroupManager.leaveGroupOrDeclineInviteAsyncWithoutUI( - groupThread: groupThread, - tx: transaction, - ) - } - switch blockMode { case .restoreFromBackup: // If we're restoring from a Backup, avoid the side effect of @@ -329,11 +321,11 @@ public class BlockingManager { } } - public func addBlockedThread(_ thread: TSThread, blockMode: BlockMode, shouldLeaveIfGroup: Bool, transaction: DBWriteTransaction) { + public func addBlockedThread(_ thread: TSThread, blockMode: BlockMode, transaction: DBWriteTransaction) { if let contactThread = thread as? TSContactThread { addBlockedAddress(contactThread.contactAddress, blockMode: blockMode, transaction: transaction) } else if let groupThread = thread as? TSGroupThread { - addBlockedGroupId(groupThread.groupId, blockMode: blockMode, shouldLeave: shouldLeaveIfGroup, transaction: transaction) + addBlockedGroupId(groupThread.groupId, blockMode: blockMode, transaction: transaction) } else { owsFailDebug("Invalid thread: \(type(of: thread))") } diff --git a/SignalServiceKit/StorageService/StorageServiceProto+Sync.swift b/SignalServiceKit/StorageService/StorageServiceProto+Sync.swift index ba5fb3271f..ee18dbeca3 100644 --- a/SignalServiceKit/StorageService/StorageServiceProto+Sync.swift +++ b/SignalServiceKit/StorageService/StorageServiceProto+Sync.swift @@ -1078,7 +1078,7 @@ class StorageServiceGroupV2RecordUpdater: StorageServiceRecordUpdater { // If our local blocked state differs from the service state, use the service's value. if record.blocked != localIsBlocked { if record.blocked { - blockingManager.addBlockedGroupId(groupId.serialize(), blockMode: .remote, shouldLeave: false, transaction: transaction) + blockingManager.addBlockedGroupId(groupId.serialize(), blockMode: .remote, transaction: transaction) } else { blockingManager.removeBlockedGroup(groupId: groupId.serialize(), wasLocallyInitiated: false, transaction: transaction) } diff --git a/SignalServiceKit/tests/Contacts/BlockingManagerTests.swift b/SignalServiceKit/tests/Contacts/BlockingManagerTests.swift index dce0de6a73..8e8e586018 100644 --- a/SignalServiceKit/tests/Contacts/BlockingManagerTests.swift +++ b/SignalServiceKit/tests/Contacts/BlockingManagerTests.swift @@ -128,7 +128,6 @@ class BlockingManagerTests: SSKBaseTest { blockingManager.addBlockedGroupId( try noLongerBlockedGroupParams.getPublicParams().getGroupIdentifier().serialize(), blockMode: .local, - shouldLeave: false, transaction: tx, ) @@ -148,7 +147,6 @@ class BlockingManagerTests: SSKBaseTest { blockingManager.addBlockedGroupId( try stillBlockedGroupParams.getPublicParams().getGroupIdentifier().serialize(), blockMode: .local, - shouldLeave: false, transaction: tx, ) _ = otherBlockingManager.blockedAddresses(transaction: tx) diff --git a/SignalServiceKit/tests/Stories/StoryManagerTest.swift b/SignalServiceKit/tests/Stories/StoryManagerTest.swift index 1ee945f931..ea5f5f6bf4 100644 --- a/SignalServiceKit/tests/Stories/StoryManagerTest.swift +++ b/SignalServiceKit/tests/Stories/StoryManagerTest.swift @@ -151,7 +151,6 @@ class StoryManagerTest: SSKBaseTest { SSKEnvironment.shared.blockingManagerRef.addBlockedGroupId( groupId, blockMode: .local, - shouldLeave: false, transaction: $0, ) diff --git a/SignalUI/Utils/BlockListUIUtils.swift b/SignalUI/Utils/BlockListUIUtils.swift index 5e153c5ac1..4d83424eab 100644 --- a/SignalUI/Utils/BlockListUIUtils.swift +++ b/SignalUI/Utils/BlockListUIUtils.swift @@ -197,7 +197,6 @@ public class BlockListUIUtils { SSKEnvironment.shared.blockingManagerRef.addBlockedGroupId( groupThread.groupId, blockMode: .local, - shouldLeave: true, transaction: tx, ) })