From b18e7cde34f290edcc6c0b998ee95c3cd9a51077 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 14 Jun 2017 14:54:39 -0400 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20show=20offers=20in=20conversati?= =?UTF-8?q?on=20with=20self.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit // FREEBIE --- Signal/src/util/ThreadUtil.m | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Signal/src/util/ThreadUtil.m b/Signal/src/util/ThreadUtil.m index 8ac4b6d21..2f93b079e 100644 --- a/Signal/src/util/ThreadUtil.m +++ b/Signal/src/util/ThreadUtil.m @@ -108,6 +108,9 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert(blockingManager); OWSAssert(maxRangeSize > 0); + NSString *localNumber = [TSAccountManager localNumber]; + OWSAssert(localNumber.length > 0); + ThreadDynamicInteractions *result = [ThreadDynamicInteractions new]; [storageManager.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { @@ -279,19 +282,26 @@ NS_ASSUME_NONNULL_BEGIN } else { NSString *recipientId = ((TSContactThread *)thread).contactIdentifier; - if ([[blockingManager blockedPhoneNumbers] containsObject:recipientId]) { - // Only create "add to contacts" offers for users which are not already blocked. + if ([recipientId isEqualToString:localNumber]) { + // Don't add self to contacts. shouldHaveAddToContactsOffer = NO; - // Only create block offers for users which are not already blocked. + // Don't bother to block self. shouldHaveBlockOffer = NO; - } + } else { + if ([[blockingManager blockedPhoneNumbers] containsObject:recipientId]) { + // Only create "add to contacts" offers for users which are not already blocked. + shouldHaveAddToContactsOffer = NO; + // Only create block offers for users which are not already blocked. + shouldHaveBlockOffer = NO; + } - SignalAccount *signalAccount = contactsManager.signalAccountMap[recipientId]; - if (signalAccount) { - // Only create "add to contacts" offers for non-contacts. - shouldHaveAddToContactsOffer = NO; - // Only create block offers for non-contacts. - shouldHaveBlockOffer = NO; + SignalAccount *signalAccount = contactsManager.signalAccountMap[recipientId]; + if (signalAccount) { + // Only create "add to contacts" offers for non-contacts. + shouldHaveAddToContactsOffer = NO; + // Only create block offers for non-contacts. + shouldHaveBlockOffer = NO; + } } }