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.
		
		
		
		
		
			
		
			
	
	
		
			60 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Matlab
		
	
		
		
			
		
	
	
			60 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Matlab
		
	
| 
											5 years ago
										 | // | ||
|  | //  Copyright (c) 2018 Open Whisper Systems. All rights reserved. | ||
|  | // | ||
|  | 
 | ||
|  | #import "ProtoUtils.h" | ||
|  | #import "ProfileManagerProtocol.h" | ||
|  | #import "SSKEnvironment.h" | ||
|  | #import "TSThread.h" | ||
| 
											5 years ago
										 | #import <SignalCoreKit/Cryptography.h> | ||
| 
											5 years ago
										 | #import <SessionMessagingKit/SessionMessagingKit-Swift.h> | ||
| 
											5 years ago
										 | 
 | ||
|  | 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 | ||
|  | { | ||
| 
											5 years ago
										 |     return YES; | ||
| 
											5 years ago
										 | } | ||
|  | 
 | ||
|  | + (void)addLocalProfileKeyIfNecessary:(TSThread *)thread | ||
|  |                           recipientId:(NSString *_Nullable)recipientId | ||
| 
											5 years ago
										 |                    dataMessageBuilder:(SNProtoDataMessageBuilder *)dataMessageBuilder | ||
| 
											5 years ago
										 | { | ||
|  |     if ([self shouldMessageHaveLocalProfileKey:thread recipientId:recipientId]) { | ||
|  |         [dataMessageBuilder setProfileKey:self.localProfileKey.keyData]; | ||
|  |     } | ||
|  | } | ||
|  | 
 | ||
| 
											5 years ago
										 | + (void)addLocalProfileKeyToDataMessageBuilder:(SNProtoDataMessageBuilder *)dataMessageBuilder | ||
| 
											5 years ago
										 | { | ||
|  |     [dataMessageBuilder setProfileKey:self.localProfileKey.keyData]; | ||
|  | } | ||
|  | 
 | ||
|  | + (void)addLocalProfileKeyIfNecessary:(TSThread *)thread | ||
|  |                           recipientId:(NSString *)recipientId | ||
| 
											5 years ago
										 |                    callMessageBuilder:(SNProtoCallMessageBuilder *)callMessageBuilder | ||
| 
											5 years ago
										 | { | ||
|  |     if ([self shouldMessageHaveLocalProfileKey:thread recipientId:recipientId]) { | ||
|  |         [callMessageBuilder setProfileKey:self.localProfileKey.keyData]; | ||
|  |     } | ||
|  | } | ||
|  | 
 | ||
|  | @end | ||
|  | 
 | ||
|  | NS_ASSUME_NONNULL_END |