Remove shouldLeaveIfGroup/shouldLeave parameters
This commit is contained in:
parent
d474e2a505
commit
db2ec165de
@ -32,7 +32,6 @@ enum MessageRequestDecliner {
|
||||
blockingManager.addBlockedThread(
|
||||
thread,
|
||||
blockMode: .local,
|
||||
shouldLeaveIfGroup: false,
|
||||
transaction: tx,
|
||||
)
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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")
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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))")
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -151,7 +151,6 @@ class StoryManagerTest: SSKBaseTest {
|
||||
SSKEnvironment.shared.blockingManagerRef.addBlockedGroupId(
|
||||
groupId,
|
||||
blockMode: .local,
|
||||
shouldLeave: false,
|
||||
transaction: $0,
|
||||
)
|
||||
|
||||
|
||||
@ -197,7 +197,6 @@ public class BlockListUIUtils {
|
||||
SSKEnvironment.shared.blockingManagerRef.addBlockedGroupId(
|
||||
groupThread.groupId,
|
||||
blockMode: .local,
|
||||
shouldLeave: true,
|
||||
transaction: tx,
|
||||
)
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user