mirror of https://github.com/oxen-io/session-ios
parent
b5fdc05b91
commit
83e2fbe28c
@ -0,0 +1,39 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "OWSSignalServiceProtos.pb.h"
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@class TSThread;
|
||||||
|
|
||||||
|
@interface PBGeneratedMessageBuilder (OWS)
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
@interface OWSSignalServiceProtosDataMessageBuilder (OWS)
|
||||||
|
|
||||||
|
- (void)addLocalProfileKeyIfNecessary:(TSThread *)thread recipientId:(NSString *)recipientId;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
@interface OWSSignalServiceProtosCallMessageBuilder (OWS)
|
||||||
|
|
||||||
|
- (void)addLocalProfileKeyIfNecessary:(TSThread *)thread recipientId:(NSString *)recipientId;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
@interface OWSSignalServiceProtosSyncMessageBuilder (OWS)
|
||||||
|
|
||||||
|
- (void)addLocalProfileKey;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
@ -0,0 +1,88 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "ProfileManagerProtocol.h"
|
||||||
|
#import "ProtoBuf+OWS.h"
|
||||||
|
#import "SignalRecipient.h"
|
||||||
|
#import "TSThread.h"
|
||||||
|
#import "TextSecureKitEnv.h"
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@implementation PBGeneratedMessageBuilder (OWS)
|
||||||
|
|
||||||
|
- (BOOL)shouldMessageHaveLocalProfileKey:(TSThread *)thread recipientId:(NSString *)recipientId
|
||||||
|
// recipient:(SignalRecipient *)recipient
|
||||||
|
{
|
||||||
|
OWSAssert(thread);
|
||||||
|
OWSAssert(recipientId.length > 0);
|
||||||
|
|
||||||
|
id<ProfileManagerProtocol> profileManager = [TextSecureKitEnv sharedEnv].profileManager;
|
||||||
|
|
||||||
|
// For 1:1 threads, we want to include the profile key IFF the
|
||||||
|
// contact is in the whitelist.
|
||||||
|
//
|
||||||
|
// For Group threads, we want to include the profile key IFF the
|
||||||
|
// recipient OR the group is in the whitelist.
|
||||||
|
if ([profileManager isUserInProfileWhitelist:recipientId]) {
|
||||||
|
return YES;
|
||||||
|
} else if ([profileManager isThreadInProfileWhitelist:thread]) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSData *)localProfileKey
|
||||||
|
{
|
||||||
|
id<ProfileManagerProtocol> profileManager = [TextSecureKitEnv sharedEnv].profileManager;
|
||||||
|
return profileManager.localProfileKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
@implementation OWSSignalServiceProtosDataMessageBuilder (OWS)
|
||||||
|
|
||||||
|
- (void)addLocalProfileKeyIfNecessary:(TSThread *)thread recipientId:(NSString *)recipientId
|
||||||
|
{
|
||||||
|
OWSAssert(thread);
|
||||||
|
OWSAssert(recipientId.length > 0);
|
||||||
|
|
||||||
|
if ([self shouldMessageHaveLocalProfileKey:thread recipientId:recipientId]) {
|
||||||
|
[self setProfileKey:self.localProfileKey];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
@implementation OWSSignalServiceProtosCallMessageBuilder (OWS)
|
||||||
|
|
||||||
|
- (void)addLocalProfileKeyIfNecessary:(TSThread *)thread recipientId:(NSString *)recipientId
|
||||||
|
{
|
||||||
|
OWSAssert(thread);
|
||||||
|
OWSAssert(recipientId.length > 0);
|
||||||
|
|
||||||
|
if ([self shouldMessageHaveLocalProfileKey:thread recipientId:recipientId]) {
|
||||||
|
[self setProfileKey:self.localProfileKey];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
@implementation OWSSignalServiceProtosSyncMessageBuilder (OWS)
|
||||||
|
|
||||||
|
- (void)addLocalProfileKey
|
||||||
|
{
|
||||||
|
[self setProfileKey:self.localProfileKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
Loading…
Reference in New Issue