From bc0b43599f158b928fa910a96e5e6e960ce5c2fd Mon Sep 17 00:00:00 2001 From: Max Radermacher Date: Tue, 5 Mar 2024 12:50:56 -0600 Subject: [PATCH] =?UTF-8?q?Clean=20up=20=E2=80=9CInternal=E2=80=9D=20view?= =?UTF-8?q?=20for=20a=20single=20thread?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConversationInternalViewController.swift | 79 +++++++++++++------ .../src/Contacts/RecipientDatabaseTable.swift | 2 +- 2 files changed, 55 insertions(+), 26 deletions(-) diff --git a/Signal/src/ViewControllers/ThreadSettings/ConversationInternalViewController.swift b/Signal/src/ViewControllers/ThreadSettings/ConversationInternalViewController.swift index 8434fb82d9..0e8ce11800 100644 --- a/Signal/src/ViewControllers/ThreadSettings/ConversationInternalViewController.swift +++ b/Signal/src/ViewControllers/ThreadSettings/ConversationInternalViewController.swift @@ -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) diff --git a/SignalServiceKit/src/Contacts/RecipientDatabaseTable.swift b/SignalServiceKit/src/Contacts/RecipientDatabaseTable.swift index f8685769f6..f4c8013687 100644 --- a/SignalServiceKit/src/Contacts/RecipientDatabaseTable.swift +++ b/SignalServiceKit/src/Contacts/RecipientDatabaseTable.swift @@ -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) })