2017-08-28 22:06:30 +02:00
|
|
|
//
|
2018-03-20 18:02:10 +01:00
|
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
2017-08-28 22:06:30 +02:00
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
2017-11-28 00:17:46 +01:00
|
|
|
import SignalServiceKit
|
2017-12-01 16:48:18 +01:00
|
|
|
import SignalMessaging
|
2017-08-28 22:06:30 +02:00
|
|
|
|
|
|
|
class DebugUIProfile: DebugUIPage {
|
|
|
|
|
|
|
|
// MARK: Dependencies
|
|
|
|
|
|
|
|
var messageSender: MessageSender {
|
2018-09-17 15:27:58 +02:00
|
|
|
return SSKEnvironment.shared.messageSender
|
2017-08-28 22:06:30 +02:00
|
|
|
}
|
|
|
|
var profileManager: OWSProfileManager {
|
|
|
|
return OWSProfileManager.shared()
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: Overrides
|
|
|
|
|
|
|
|
override func name() -> String {
|
|
|
|
return "Profile"
|
|
|
|
}
|
|
|
|
|
|
|
|
override func section(thread aThread: TSThread?) -> OWSTableSection? {
|
2018-03-20 18:02:10 +01:00
|
|
|
let profileManager = self.profileManager
|
2017-08-28 22:06:30 +02:00
|
|
|
let sectionItems = [
|
|
|
|
OWSTableItem(title: "Clear Profile Whitelist") {
|
2018-03-20 18:02:10 +01:00
|
|
|
profileManager.clearProfileWhitelist()
|
2017-08-28 22:06:30 +02:00
|
|
|
},
|
|
|
|
OWSTableItem(title: "Log Profile Whitelist") {
|
2018-03-20 18:02:10 +01:00
|
|
|
profileManager.logProfileWhitelist()
|
2017-08-28 22:06:30 +02:00
|
|
|
},
|
2017-09-07 21:33:12 +02:00
|
|
|
OWSTableItem(title: "Log User Profiles") {
|
2018-03-20 18:02:10 +01:00
|
|
|
profileManager.logUserProfiles()
|
2017-09-07 21:33:12 +02:00
|
|
|
},
|
2018-12-03 14:56:31 +01:00
|
|
|
OWSTableItem(title: "Log Profile Key") {
|
|
|
|
let localProfileKey = profileManager.localProfileKey()
|
|
|
|
Logger.info("localProfileKey: \(localProfileKey.keyData.hexadecimalString)")
|
|
|
|
profileManager.logUserProfiles()
|
|
|
|
},
|
2017-08-28 22:06:30 +02:00
|
|
|
OWSTableItem(title: "Regenerate Profile/ProfileKey") {
|
2018-03-20 18:02:10 +01:00
|
|
|
profileManager.regenerateLocalProfile()
|
2017-08-28 22:06:30 +02:00
|
|
|
},
|
2018-03-20 18:02:10 +01:00
|
|
|
OWSTableItem(title: "Send Profile Key Message") { [weak self] in
|
|
|
|
guard let strongSelf = self else { return }
|
|
|
|
|
2018-10-03 23:41:43 +02:00
|
|
|
// MJK TODO - should be safe to remove this senderTimestamp
|
2018-09-20 22:10:35 +02:00
|
|
|
let message = OWSProfileKeyMessage(timestamp: NSDate.ows_millisecondTimeStamp(), in: aThread)
|
2018-10-13 21:21:46 +02:00
|
|
|
strongSelf.messageSender.sendPromise(message: message).done {
|
2017-08-28 22:06:30 +02:00
|
|
|
Logger.info("Successfully sent profile key message to thread: \(String(describing: aThread))")
|
2018-10-13 21:21:46 +02:00
|
|
|
}.catch { _ in
|
|
|
|
owsFailDebug("Failed to send profile key message to thread: \(String(describing: aThread))")
|
|
|
|
}.retainUntilComplete()
|
2017-08-28 22:06:30 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
return OWSTableSection(title: "Profile", items: sectionItems)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|