|
|
@ -149,6 +149,19 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
NSString *localNumber = [TSAccountManager localNumber];
|
|
|
|
NSString *localNumber = [TSAccountManager localNumber];
|
|
|
|
OWSAssert(localNumber.length > 0);
|
|
|
|
OWSAssert(localNumber.length > 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Many OWSProfileManager methods aren't safe to call from inside a database
|
|
|
|
|
|
|
|
// transaction, so do this work now.
|
|
|
|
|
|
|
|
OWSProfileManager *profileManager = OWSProfileManager.sharedManager;
|
|
|
|
|
|
|
|
BOOL hasLocalProfile = [profileManager hasLocalProfile];
|
|
|
|
|
|
|
|
BOOL isThreadInProfileWhitelist = [profileManager isThreadInProfileWhitelist:thread];
|
|
|
|
|
|
|
|
BOOL hasUnwhitelistedMember = NO;
|
|
|
|
|
|
|
|
for (NSString *recipientId in thread.recipientIdentifiers) {
|
|
|
|
|
|
|
|
if (![profileManager isUserInProfileWhitelist:recipientId]) {
|
|
|
|
|
|
|
|
hasUnwhitelistedMember = YES;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ThreadDynamicInteractions *result = [ThreadDynamicInteractions new];
|
|
|
|
ThreadDynamicInteractions *result = [ThreadDynamicInteractions new];
|
|
|
|
|
|
|
|
|
|
|
|
[dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
|
|
|
[dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
|
|
@ -407,25 +420,15 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
shouldHaveBlockOffer = NO;
|
|
|
|
shouldHaveBlockOffer = NO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (![OWSProfileManager.sharedManager hasLocalProfile] ||
|
|
|
|
if (!hasLocalProfile || isThreadInProfileWhitelist) {
|
|
|
|
[OWSProfileManager.sharedManager isThreadInProfileWhitelist:thread]) {
|
|
|
|
|
|
|
|
// Don't show offer if thread is local user hasn't configured their profile.
|
|
|
|
// Don't show offer if thread is local user hasn't configured their profile.
|
|
|
|
// Don't show offer if thread is already in profile whitelist.
|
|
|
|
// Don't show offer if thread is already in profile whitelist.
|
|
|
|
shouldHaveAddToProfileWhitelistOffer = NO;
|
|
|
|
shouldHaveAddToProfileWhitelistOffer = NO;
|
|
|
|
} else if (thread.isGroupThread) {
|
|
|
|
} else if (thread.isGroupThread && !hasUnwhitelistedMember) {
|
|
|
|
BOOL hasUnwhitelistedMember = NO;
|
|
|
|
|
|
|
|
for (NSString *recipientId in thread.recipientIdentifiers) {
|
|
|
|
|
|
|
|
if (![OWSProfileManager.sharedManager isUserInProfileWhitelist:recipientId]) {
|
|
|
|
|
|
|
|
hasUnwhitelistedMember = YES;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hasUnwhitelistedMember) {
|
|
|
|
|
|
|
|
// Don't show offer in group thread if all members are already individually
|
|
|
|
// Don't show offer in group thread if all members are already individually
|
|
|
|
// whitelisted.
|
|
|
|
// whitelisted.
|
|
|
|
shouldHaveAddToProfileWhitelistOffer = NO;
|
|
|
|
shouldHaveAddToProfileWhitelistOffer = NO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOL shouldHaveContactOffers
|
|
|
|
BOOL shouldHaveContactOffers
|
|
|
|
= (shouldHaveBlockOffer || shouldHaveAddToContactsOffer || shouldHaveAddToProfileWhitelistOffer);
|
|
|
|
= (shouldHaveBlockOffer || shouldHaveAddToContactsOffer || shouldHaveAddToProfileWhitelistOffer);
|
|
|
|