Signal-iOS/Signal/src/ViewControllers/DebugUI/DebugUISyncMessages.swift
2023-06-01 11:47:43 -07:00

52 lines
1.6 KiB
Swift

//
// Copyright 2023 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
//
import SignalCoreKit
import SignalServiceKit
import SignalUI
#if USE_DEBUG_UI
class DebugUISyncMessages: DebugUIPage, Dependencies {
let name = "Sync Messages"
func section(thread: TSThread?) -> OWSTableSection? {
return OWSTableSection(title: name, items: [
OWSTableItem(title: "Send Contacts Sync Message",
actionBlock: { DebugUISyncMessages.sendContactsSyncMessage() }),
OWSTableItem(title: "Send Blocklist Sync Message",
actionBlock: { DebugUISyncMessages.sendBlockListSyncMessage() }),
OWSTableItem(title: "Send Configuration Sync Message",
actionBlock: { DebugUISyncMessages.sendConfigurationSyncMessage() }),
OWSTableItem(title: "Send Verification Sync Message",
actionBlock: { DebugUISyncMessages.sendVerificationSyncMessage() })
])
}
// MARK: -
private static func sendContactsSyncMessage() {
SSKEnvironment.shared.syncManager.syncAllContacts()
.catch(on: DispatchQueue.global()) { error in
Logger.info("Error: \(error)")
}
}
private static func sendBlockListSyncMessage() {
BlockingManager.shared.syncBlockList(completion: { })
}
private static func sendConfigurationSyncMessage() {
SSKEnvironment.shared.syncManager.sendConfigurationSyncMessage()
}
private static func sendVerificationSyncMessage() {
OWSIdentityManager.shared.tryToSyncQueuedVerificationStates()
}
}
#endif