Refine profile logic.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 09e65a674b
commit e01fbc247e

@ -340,6 +340,8 @@ NS_ASSUME_NONNULL_BEGIN
shouldHaveAddToContactsOffer = NO;
// Only create block offers for users which are not already blocked.
shouldHaveBlockOffer = NO;
// Don't create profile whitelist offers for users which are not already blocked.
shouldHaveAddToProfileWhitelistOffer = NO;
}
SignalAccount *signalAccount = contactsManager.signalAccountMap[recipientId];
@ -374,6 +376,19 @@ NS_ASSUME_NONNULL_BEGIN
// 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.
shouldHaveAddToProfileWhitelistOffer = NO;
} else if (thread.isGroupThread) {
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
// whitelisted.
hasUnwhitelistedMember = YES;
}
}
// We use these offset to control the ordering of the offers and indicators.

@ -702,6 +702,9 @@ NS_ASSUME_NONNULL_BEGIN
// user, we can infer that that user belongs in our profile whitelist.
id<ProfileManagerProtocol> profileManager = [TextSecureKitEnv sharedEnv].profileManager;
[profileManager addUserToProfileWhitelist:destination];
// TODO: Can we also infer when groups are added to the whitelist
// from sent messages to groups?
}
if ([self isDataMessageGroupAvatarUpdate:syncMessage.sent.message]) {

@ -0,0 +1,17 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "TSRequest.h"
NS_ASSUME_NONNULL_BEGIN
@interface TSProfileAvatarUploadFormRequest : TSRequest
- (nullable instancetype)init;
- (instancetype)init NS_UNAVAILABLE;
@end
NS_ASSUME_NONNULL_END

@ -0,0 +1,23 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "TSProfileAvatarUploadFormRequest.h"
#import "TSConstants.h"
NS_ASSUME_NONNULL_BEGIN
@implementation TSProfileAvatarUploadFormRequest
- (nullable instancetype)init
{
self = [super initWithURL:[NSURL URLWithString:textSecureProfileAvatarFormAPI]];
self.HTTPMethod = @"GET";
return self;
}
@end
NS_ASSUME_NONNULL_END
Loading…
Cancel
Save