Clean up “Internal” view for a single thread

This commit is contained in:
Max Radermacher 2024-03-05 12:50:56 -06:00 committed by GitHub
parent e066676772
commit bc0b43599f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 55 additions and 26 deletions

View File

@ -35,45 +35,74 @@ public class ConversationInternalViewController: OWSTableViewController2 {
let infoSection = OWSTableSection()
self.databaseStorage.read { transaction in
let section = infoSection
let isThreadInProfileWhitelist = Self.profileManager.isThread(inProfileWhitelist: thread,
transaction: transaction)
section.add(.label(withText: String(format: "Whitelisted: %@",
isThreadInProfileWhitelist ? "Yes" : "No")))
let isThreadInProfileWhitelist = Self.profileManager.isThread(
inProfileWhitelist: thread, transaction: transaction
)
section.add(.copyableItem(
label: "Whitelisted",
value: isThreadInProfileWhitelist ? "Yes" : "No"
))
if let contactThread = thread as? TSContactThread {
let address = contactThread.contactAddress
section.add(.copyableItem(label: "ServiceId",
value: address.serviceIdString,
accessibilityIdentifier: "serviceId"))
let recipientDatabaseTable = DependenciesBridge.shared.recipientDatabaseTable
let signalRecipient = recipientDatabaseTable.fetchRecipient(address: address, tx: transaction.asV2Read)
section.add(.copyableItem(label: "Phone Number",
value: address.phoneNumber,
accessibilityIdentifier: "phoneNumber"))
section.add(.copyableItem(
label: "ACI",
value: signalRecipient?.aci?.serviceIdString
))
let profileKey = profileManager.profileKeyData(for: address, transaction: transaction)
section.add(.copyableItem(label: "Profile Key",
value: profileKey?.hexadecimalString,
accessibilityIdentifier: "profile_key"))
section.add(.copyableItem(
label: "Phone Number",
value: signalRecipient?.phoneNumber?.stringValue
))
section.add(.copyableItem(
label: "PNI",
value: signalRecipient?.pni?.serviceIdString
))
section.add(.copyableItem(
label: "Discoverable Phone Number?",
value: signalRecipient?.phoneNumber?.isDiscoverable == true ? "Yes" : "No"
))
let userProfile = profileManager.getUserProfile(for: address, transaction: transaction)
section.add(.copyableItem(
label: "Sharing Phone Number?",
value: userProfile.isPhoneNumberSharedOrDefault ? "Yes" : "No"
))
section.add(.copyableItem(
label: "Profile Key",
value: userProfile?.profileKey?.keyData.hexadecimalString
))
let identityManager = DependenciesBridge.shared.identityManager
let identityKey = identityManager.recipientIdentity(for: address, tx: transaction.asV2Read)?.identityKey
section.add(.copyableItem(label: "Identity Key",
value: identityKey?.hexadecimalString,
accessibilityIdentifier: "identity_key"))
section.add(.copyableItem(
label: "Identity Key",
value: identityKey?.hexadecimalString
))
let arePaymentsEnabled = paymentsHelper.arePaymentsEnabled(for: address,
transaction: transaction)
section.add(.label(withText: String(format: "Payments Enabled: %@",
arePaymentsEnabled ? "Yes" : "No")))
let arePaymentsEnabled = paymentsHelper.arePaymentsEnabled(for: address, transaction: transaction)
section.add(.copyableItem(
label: "Payments",
value: arePaymentsEnabled ? "Yes" : "No"
))
} else {
owsFailDebug("Invalid thread.")
// Nothing extra to show for groups.
}
section.add(.copyableItem(label: "thread.uniqueId",
value: thread.uniqueId,
accessibilityIdentifier: "thread.uniqueId"))
section.add(.copyableItem(
label: "DB Unique ID",
value: thread.uniqueId
))
}
contents.add(infoSection)

View File

@ -44,7 +44,7 @@ extension RecipientDatabaseTable {
return nil
}
func fetchRecipient(address: SignalServiceAddress, tx: DBReadTransaction) -> SignalRecipient? {
public func fetchRecipient(address: SignalServiceAddress, tx: DBReadTransaction) -> SignalRecipient? {
return (
address.serviceId.flatMap({ fetchRecipient(serviceId: $0, transaction: tx) })
?? address.phoneNumber.flatMap({ fetchRecipient(phoneNumber: $0, transaction: tx) })