mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.2 KiB
Objective-C
51 lines
1.2 KiB
Objective-C
//
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
|
//
|
|
|
|
#import "ProtoUtils.h"
|
|
#import "ProfileManagerProtocol.h"
|
|
#import "SSKEnvironment.h"
|
|
#import "TSThread.h"
|
|
#import <SignalCoreKit/Cryptography.h>
|
|
#import <SessionMessagingKit/SessionMessagingKit-Swift.h>
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
@implementation ProtoUtils
|
|
|
|
#pragma mark - Dependencies
|
|
|
|
+ (id<ProfileManagerProtocol>)profileManager {
|
|
return SSKEnvironment.shared.profileManager;
|
|
}
|
|
|
|
+ (OWSAES256Key *)localProfileKey
|
|
{
|
|
return self.profileManager.localProfileKey;
|
|
}
|
|
|
|
#pragma mark -
|
|
|
|
+ (BOOL)shouldMessageHaveLocalProfileKey:(TSThread *)thread recipientId:(NSString *_Nullable)recipientId
|
|
{
|
|
return YES;
|
|
}
|
|
|
|
+ (void)addLocalProfileKeyIfNecessary:(TSThread *)thread
|
|
recipientId:(NSString *_Nullable)recipientId
|
|
dataMessageBuilder:(SNProtoDataMessageBuilder *)dataMessageBuilder
|
|
{
|
|
if ([self shouldMessageHaveLocalProfileKey:thread recipientId:recipientId]) {
|
|
[dataMessageBuilder setProfileKey:self.localProfileKey.keyData];
|
|
}
|
|
}
|
|
|
|
+ (void)addLocalProfileKeyToDataMessageBuilder:(SNProtoDataMessageBuilder *)dataMessageBuilder
|
|
{
|
|
[dataMessageBuilder setProfileKey:self.localProfileKey.keyData];
|
|
}
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|