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
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C
		
	
		
		
			
		
	
	
			51 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C
		
	
| 
								 
											5 years ago
										 
									 | 
							
								//
							 | 
						||
| 
								 | 
							
								//  Copyright (c) 2018 Open Whisper Systems. All rights reserved.
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											5 years ago
										 
									 | 
							
								#import <SessionUtilitiesKit/TSYapDatabaseObject.h>
							 | 
						||
| 
								 
											5 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								NS_ASSUME_NONNULL_BEGIN
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// SignalRecipient serves two purposes:
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								// a) It serves as a cache of "known" Signal accounts.  When the service indicates
							 | 
						||
| 
								 | 
							
								//    that an account exists, we make sure that an instance of SignalRecipient exists
							 | 
						||
| 
								 | 
							
								//    for that recipient id (using mark as registered) and has at least one device.
							 | 
						||
| 
								 | 
							
								//    When the service indicates that an account does not exist, we remove any devices
							 | 
						||
| 
								 | 
							
								//    from that SignalRecipient - but do not remove it from the database.
							 | 
						||
| 
								 | 
							
								//    Note that SignalRecipients without any devices are not considered registered.
							 | 
						||
| 
								 | 
							
								//// b) We hang the "known device list" for known signal accounts on this entity.
							 | 
						||
| 
								 | 
							
								@interface SignalRecipient : TSYapDatabaseObject
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								@property (nonatomic, readonly) NSOrderedSet *devices;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (instancetype)init NS_UNAVAILABLE;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								+ (nullable instancetype)registeredRecipientForRecipientId:(NSString *)recipientId
							 | 
						||
| 
								 | 
							
								                                           mustHaveDevices:(BOOL)mustHaveDevices
							 | 
						||
| 
								 | 
							
								                                               transaction:(YapDatabaseReadTransaction *)transaction;
							 | 
						||
| 
								 | 
							
								+ (instancetype)getOrBuildUnsavedRecipientForRecipientId:(NSString *)recipientId
							 | 
						||
| 
								 | 
							
								                                             transaction:(YapDatabaseReadTransaction *)transaction;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (void)updateRegisteredRecipientWithDevicesToAdd:(nullable NSArray *)devicesToAdd
							 | 
						||
| 
								 | 
							
								                                  devicesToRemove:(nullable NSArray *)devicesToRemove
							 | 
						||
| 
								 | 
							
								                                      transaction:(YapDatabaseReadWriteTransaction *)transaction;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (NSString *)recipientId;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (NSComparisonResult)compare:(SignalRecipient *)other;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								+ (BOOL)isRegisteredRecipient:(NSString *)recipientId transaction:(YapDatabaseReadTransaction *)transaction;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								+ (SignalRecipient *)markRecipientAsRegisteredAndGet:(NSString *)recipientId
							 | 
						||
| 
								 | 
							
								                                         transaction:(YapDatabaseReadWriteTransaction *)transaction;
							 | 
						||
| 
								 | 
							
								+ (void)markRecipientAsRegistered:(NSString *)recipientId
							 | 
						||
| 
								 | 
							
								                         deviceId:(UInt32)deviceId
							 | 
						||
| 
								 | 
							
								                      transaction:(YapDatabaseReadWriteTransaction *)transaction;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								+ (void)markRecipientAsUnregistered:(NSString *)recipientId transaction:(YapDatabaseReadWriteTransaction *)transaction;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								@end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								NS_ASSUME_NONNULL_END
							 |