[Recipient hiding] Filter which outgoing message types should unhide

This commit is contained in:
Marissa Le Coz 2023-08-24 16:29:43 -04:00 committed by GitHub
parent 320d97da17
commit bc6432f0bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -949,11 +949,41 @@ extension MessageSender {
return .value(())
}
/// Sending a reply to a hidden recipient unhides them. But how we
/// define "reply" is not inclusive of all outgoing messages. We unhide
/// when the message indicates the user's intent to resume association
/// with the hidden recipient.
///
/// It is important to be conservative about which messages unhide a
/// recipient. It is far better to not unhide when should than to
/// unhide when we should not.
private func shouldMessageSendUnhideRecipient(_ message: TSOutgoingMessage) -> Bool {
if message.hasRenderableContent() {
return true
}
if message is OWSOutgoingReactionMessage {
return true
}
if
let message = message as? OWSOutgoingCallMessage,
/// OWSOutgoingCallMessages include not only calling
/// someone (ie, an "offer message"), but also sending
/// hangup messages, busy messages, and other kinds of
/// call-related "messages" that do not indicate the
/// sender's intent to resume association with a recipient.
message.offerMessage != nil
{
return true
}
return false
}
private func handleMessageSentLocally(_ message: TSOutgoingMessage) -> Promise<Void> {
databaseStorage.write { tx in
if
FeatureFlags.recipientHiding,
let thread = message.thread(tx: tx) as? TSContactThread,
self.shouldMessageSendUnhideRecipient(message),
let localAddress = tsAccountManager.localAddress(with: tx),
!localAddress.isEqualToAddress(thread.contactAddress)
{