Merge branch 'dev' of https://github.com/loki-project/loki-messenger-ios into sync-open-group

This commit is contained in:
Ryan ZHAO 2020-02-28 14:05:36 +11:00
commit b990420c6f
18 changed files with 73 additions and 70 deletions

View File

@ -4230,7 +4230,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 46;
CURRENT_PROJECT_VERSION = 48;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = SUQ8J2PCT7;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
@ -4244,7 +4244,7 @@
INFOPLIST_FILE = SignalShareExtension/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 1.0.4;
MARKETING_VERSION = 1.0.5;
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.share-extension";
PRODUCT_NAME = "$(TARGET_NAME)";
@ -4292,7 +4292,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 46;
CURRENT_PROJECT_VERSION = 48;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = SUQ8J2PCT7;
ENABLE_NS_ASSERTIONS = NO;
@ -4311,7 +4311,7 @@
INFOPLIST_FILE = SignalShareExtension/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 1.0.4;
MARKETING_VERSION = 1.0.5;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.share-extension";
PRODUCT_NAME = "$(TARGET_NAME)";
@ -4346,7 +4346,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 46;
CURRENT_PROJECT_VERSION = 48;
DEBUG_INFORMATION_FORMAT = dwarf;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = SUQ8J2PCT7;
@ -4365,7 +4365,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.0.4;
MARKETING_VERSION = 1.0.5;
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.utilities";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
@ -4415,7 +4415,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 46;
CURRENT_PROJECT_VERSION = 48;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = SUQ8J2PCT7;
@ -4439,7 +4439,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.0.4;
MARKETING_VERSION = 1.0.5;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.utilities";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
@ -4624,7 +4624,7 @@
CODE_SIGN_ENTITLEMENTS = Signal/Signal.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 46;
CURRENT_PROJECT_VERSION = 48;
DEVELOPMENT_TEAM = SUQ8J2PCT7;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@ -4659,7 +4659,7 @@
"$(SRCROOT)",
);
LLVM_LTO = NO;
MARKETING_VERSION = 1.0.4;
MARKETING_VERSION = 1.0.5;
OTHER_LDFLAGS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger";
PRODUCT_NAME = Session;
@ -4691,7 +4691,7 @@
CODE_SIGN_ENTITLEMENTS = Signal/Signal.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 46;
CURRENT_PROJECT_VERSION = 48;
DEVELOPMENT_TEAM = SUQ8J2PCT7;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@ -4726,7 +4726,7 @@
"$(SRCROOT)",
);
LLVM_LTO = NO;
MARKETING_VERSION = 1.0.4;
MARKETING_VERSION = 1.0.5;
OTHER_LDFLAGS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger";
PRODUCT_NAME = Session;

View File

@ -173,9 +173,8 @@ final class NewClosedGroupVC : UIViewController, UITableViewDataSource, UITableV
storage.dbReadConnection.readWrite { transaction in
masterHexEncodedPublicKey = storage.getMasterHexEncodedPublicKey(for: userHexEncodedPublicKey, in: transaction) ?? userHexEncodedPublicKey
}
let members = [String](selectedContacts) + [ masterHexEncodedPublicKey ]
let members = selectedContacts + [ masterHexEncodedPublicKey ]
let admins = [ masterHexEncodedPublicKey ]
let groupID = LKGroupUtilities.getEncodedClosedGroupIDAsData(Randomness.generateRandomBytes(kGroupIdLength)!.toHexString())
let group = TSGroupModel(title: name, memberIds: members, image: nil, groupId: groupID, groupType: .closedGroup, adminIds: admins)
let thread = TSGroupThread.getOrCreateThread(with: group)

View File

@ -3081,7 +3081,11 @@ typedef enum : NSUInteger {
- (void)sendMediaNavDidCancel:(SendMediaNavigationController *)sendMediaNavigationController
{
[self dismissViewControllerAnimated:YES completion:nil];
[self dismissViewControllerAnimated:YES completion:^{
if (!self.isFirstResponder) {
[self becomeFirstResponder];
}
}];
}
- (void)sendMediaNav:(SendMediaNavigationController *)sendMediaNavigationController
@ -3096,15 +3100,16 @@ typedef enum : NSUInteger {
// the new message scroll into view.
[self scrollToBottomAnimated:NO];
[self dismissViewControllerAnimated:YES
completion:^{
// OWSAssertDebug(self.isFirstResponder);
if (@available(iOS 10, *)) {
// do nothing
} else {
[self reloadInputViews];
}
}];
[self dismissViewControllerAnimated:YES completion:^{
if (!self.isFirstResponder) {
[self becomeFirstResponder];
}
if (@available(iOS 10, *)) {
// do nothing
} else {
[self reloadInputViews];
}
}];
}
- (nullable NSString *)sendMediaNavInitialMessageText:(SendMediaNavigationController *)sendMediaNavigationController

View File

@ -331,9 +331,8 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
NSMutableArray<AnyPromise *> *promises = @[].mutableCopy;
[TSGroupThread enumerateCollectionObjectsUsingBlock:^(id obj, BOOL *stop) {
if (![obj isKindOfClass:[TSGroupThread class]]) {
if (![obj isKindOfClass:[TSContactThread class]]) {
OWSLogWarn(@"Ignoring non group thread in thread collection: %@", obj);
if (![obj isKindOfClass:[TSContactThread class]]) { // FIXME: Isn't this redundant?
OWSLogWarn(@"Ignoring non-group thread in thread collection: %@.", obj);
}
return;
}
@ -356,11 +355,11 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
AnyPromise *promise = [AnyPromise promiseWithResolverBlock:^(PMKResolver resolve) {
[self.messageSender sendMessage:syncGroupsMessage
success:^{
OWSLogInfo(@"Successfully sent groups sync message.");
OWSLogInfo(@"Successfully sent group sync message.");
resolve(@(1));
}
failure:^(NSError *error) {
OWSLogError(@"Failed to send groups sync message with error: %@.", error);
OWSLogError(@"Failed to send group sync message due to error: %@.", error);
resolve(error);
}];
}];

View File

@ -39,7 +39,7 @@ extern NSString *const TSGroupThread_NotificationKey_UniqueId;
- (BOOL)isLocalUserInGroup;
- (BOOL)isLocalUserInGroupWithTransaction:(YapDatabaseReadTransaction *)transaction;
- (BOOL)isUserInGroup:(NSString *)hexEncodedPublicKey transaction:(YapDatabaseReadWriteTransaction *)transaction;
- (BOOL)isUserAdminForGroup:(NSString *)hexEncodedPublicKey transaction:(YapDatabaseReadWriteTransaction *)transaction;
- (BOOL)isUserAdminInGroup:(NSString *)hexEncodedPublicKey transaction:(YapDatabaseReadWriteTransaction *)transaction;
// all group threads containing recipient as a member
+ (NSArray<TSGroupThread *> *)groupThreadsWithRecipientId:(NSString *)recipientId

View File

@ -211,7 +211,7 @@ NSString *const TSGroupThread_NotificationKey_UniqueId = @"TSGroupThread_Notific
return [linkedDeviceHexEncodedPublicKeys intersectsSet:[NSSet setWithArray:self.groupModel.groupMemberIds]];
}
- (BOOL)isUserAdminForGroup:(NSString *)hexEncodedPublicKey transaction:(YapDatabaseReadWriteTransaction *)transaction
- (BOOL)isUserAdminInGroup:(NSString *)hexEncodedPublicKey transaction:(YapDatabaseReadWriteTransaction *)transaction
{
if (hexEncodedPublicKey == nil) { return NO; }
NSSet<NSString *> *linkedDeviceHexEncodedPublicKeys = [LKDatabaseUtilities getLinkedDeviceHexEncodedPublicKeysFor:hexEncodedPublicKey in:transaction];
@ -241,13 +241,13 @@ NSString *const TSGroupThread_NotificationKey_UniqueId = @"TSGroupThread_Notific
- (void)leaveGroupWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
{
NSMutableSet<NSString *> *newGroupMemberIds = [NSMutableSet setWithArray:self.groupModel.groupMemberIds];
NSMutableSet<NSString *> *newGroupMemberIDs = [NSMutableSet setWithArray:self.groupModel.groupMemberIds];
NSString *userHexEncodedPublicKey = TSAccountManager.localNumber;
if (userHexEncodedPublicKey != nil) {
NSSet<NSString *> *linkedDeviceHexEncodedPublicKeys = [LKDatabaseUtilities getLinkedDeviceHexEncodedPublicKeysFor:userHexEncodedPublicKey in:transaction];
[newGroupMemberIds minusSet:linkedDeviceHexEncodedPublicKeys];
[newGroupMemberIDs minusSet:linkedDeviceHexEncodedPublicKeys];
}
self.groupModel.groupMemberIds = newGroupMemberIds.allObjects;
self.groupModel.groupMemberIds = newGroupMemberIDs.allObjects;
[self saveWithTransaction:transaction];
}

View File

@ -73,9 +73,11 @@ NS_ASSUME_NONNULL_BEGIN
[self writeUInt32:groupDataLength];
[self writeData:groupData];
// if (avatarPng) {
// [self writeData:avatarPng];
// }
/*
if (avatarPng) {
[self writeData:avatarPng];
}
*/
}
@end

View File

@ -32,6 +32,7 @@ public extension LokiAPI {
// MARK: Internal API
internal static func getRandomSnode() -> Promise<LokiAPITarget> {
// All of this has to happen on DispatchQueue.global() due to the way OWSMessageManager works
if randomSnodePool.isEmpty {
let target = seedNodePool.randomElement()!
let url = URL(string: "\(target)/json_rpc")!
@ -49,7 +50,7 @@ public extension LokiAPI {
]
])
print("[Loki] Invoking get_n_service_nodes on \(target).")
return TSNetworkManager.shared().perform(request).map(on: DispatchQueue.global()) { intermediate in
return TSNetworkManager.shared().perform(request, withCompletionQueue: DispatchQueue.global()).map(on: DispatchQueue.global()) { intermediate in
let rawResponse = intermediate.responseObject
guard let json = rawResponse as? JSON, let intermediate = json["result"] as? JSON, let rawTargets = intermediate["service_node_states"] as? [JSON] else { throw LokiAPIError.randomSnodePoolUpdatingFailed }
randomSnodePool = try Set(rawTargets.flatMap { rawTarget in
@ -61,7 +62,7 @@ public extension LokiAPI {
})
// randomElement() uses the system's default random generator, which is cryptographically secure
return randomSnodePool.randomElement()!
}.recover { error -> Promise<LokiAPITarget> in
}.recover(on: DispatchQueue.global()) { error -> Promise<LokiAPITarget> in
print("[Loki] Failed to contact seed node at: \(target).")
throw error
}.retryingIfNeeded(maxRetryCount: 16) // The seed nodes have historically been unreliable

View File

@ -142,7 +142,7 @@ public final class LokiAPI : NSObject {
destinations.append(contentsOf: slaveDestinations)
seal.fulfill(destinations)
}
if let transaction = transaction {
if let transaction = transaction, transaction.connection.pendingTransactionCount != 0 {
getDestinationsInternal(in: transaction)
} else {
storage.dbReadConnection.read { transaction in

View File

@ -57,7 +57,7 @@ public class LokiDotNetAPI : NSObject {
func setAuthTokenInternal(in transaction: YapDatabaseReadWriteTransaction) {
transaction.setObject(newValue, forKey: server, inCollection: authTokenCollection)
}
if let transaction = transaction {
if let transaction = transaction, transaction.connection.pendingTransactionCount != 0 {
setAuthTokenInternal(in: transaction)
} else {
storage.dbReadWriteConnection.readWrite { transaction in

View File

@ -76,9 +76,16 @@ public final class LokiFileServerAPI : LokiDotNetAPI {
}
})
}.map(on: DispatchQueue.global()) { deviceLinks -> Set<DeviceLink> in
storage.dbReadWriteConnection.readWrite { transaction in
func setDeviceLinks(in transaction: YapDatabaseReadWriteTransaction) {
storage.setDeviceLinks(deviceLinks, in: transaction)
}
if let transaction = transaction, transaction.connection.pendingTransactionCount != 0 {
setDeviceLinks(in: transaction)
} else {
storage.dbReadWriteConnection.readWrite { transaction in
setDeviceLinks(in: transaction)
}
}
return deviceLinks
}
}

View File

@ -44,6 +44,7 @@ internal class LokiFileServerProxy : LokiHTTPClient {
}
internal func performLokiFileServerNSURLRequest(_ request: NSURLRequest, withCompletionQueue queue: DispatchQueue = DispatchQueue.main) -> LokiAPI.RawResponsePromise {
// All of this has to happen on DispatchQueue.global() due to the way OWSMessageManager works
var headers = getCanonicalHeaders(for: request)
return Promise<LokiAPI.RawResponse> { [server = self.server, keyPair = self.keyPair, httpSession = self.httpSession] seal in
DispatchQueue.global().async {
@ -116,9 +117,9 @@ internal class LokiFileServerProxy : LokiHTTPClient {
let uncheckedJSON = try? JSONSerialization.jsonObject(with: uncheckedJSONAsData, options: .allowFragments) as? JSON
guard let json = uncheckedJSON else { throw HTTPError.networkError(code: -1, response: nil, underlyingError: Error.proxyResponseParsingFailed) }
return json
}.done { rawResponse in
}.done(on: DispatchQueue.global()) { rawResponse in
seal.fulfill(rawResponse)
}.catch { error in
}.catch(on: DispatchQueue.global()) { error in
print("[Loki] File server proxy request failed with error: \(error.localizedDescription).")
seal.reject(HTTPError.from(error: error) ?? error)
}

View File

@ -10,6 +10,7 @@ internal class LokiHTTPClient {
securityPolicy.validatesDomainName = false
result.securityPolicy = securityPolicy
result.responseSerializer = AFHTTPResponseSerializer()
result.completionQueue = DispatchQueue.global() // All of this has to happen on DispatchQueue.global() due to the way OWSMessageManager works
return result
}()

View File

@ -21,12 +21,8 @@
let protoAsData = data[index..<(index+sizeAsInt)]
guard let proto = try? SSKProtoGroupDetails.parseData(protoAsData) else { break }
index += sizeAsInt
var groupModel = TSGroupModel.init(title: proto.name,
memberIds: proto.members,
image: nil,
groupId: proto.id,
groupType: GroupType.closedGroup,
adminIds: proto.admins)
var groupModel = TSGroupModel(title: proto.name, memberIds: proto.members, image: nil,
groupId: proto.id, groupType: GroupType.closedGroup, adminIds: proto.admins)
result.append(groupModel)
}
return result

View File

@ -70,7 +70,7 @@ NS_ASSUME_NONNULL_BEGIN
SSKProtoSyncMessageGroups *_Nullable groupsProto = [groupsBuilder buildAndReturnError:&error];
if (error || !groupsProto) {
OWSFailDebug(@"could not build protobuf: %@", error);
OWSFailDebug(@"Couldn't build protobuf due to error: %@.", error);
return nil;
}

View File

@ -1077,7 +1077,7 @@ NS_ASSUME_NONNULL_BEGIN
[self.identityManager throws_processIncomingSyncMessage:syncMessage.verified transaction:transaction];
} else if (syncMessage.contacts != nil) {
if (wasSentByMasterDevice && syncMessage.contacts.data.length > 0) {
OWSLogInfo(@"[Loki] Received contact sync message.");
[LKLogger print:@"[Loki] Received contact sync message."];
NSData *data = syncMessage.contacts.data;
ContactParser *parser = [[ContactParser alloc] initWithData:data];
NSArray<NSString *> *hexEncodedPublicKeys = [parser parseHexEncodedPublicKeys];
@ -1088,7 +1088,8 @@ NS_ASSUME_NONNULL_BEGIN
switch (friendRequestStatus) {
case LKThreadFriendRequestStatusNone: {
OWSMessageSender *messageSender = SSKEnvironment.shared.messageSender;
LKFriendRequestMessage *automatedFriendRequestMessage = [messageSender getMultiDeviceFriendRequestMessageForHexEncodedPublicKey:hexEncodedPublicKey inThread:thread transaction:transaction];
LKFriendRequestMessage *automatedFriendRequestMessage = [messageSender getMultiDeviceFriendRequestMessageForHexEncodedPublicKey:hexEncodedPublicKey transaction:transaction];
[automatedFriendRequestMessage saveWithTransaction:transaction];
[self.messageSenderJobQueue addMessage:automatedFriendRequestMessage transaction:transaction];
break;
}
@ -1105,7 +1106,7 @@ NS_ASSUME_NONNULL_BEGIN
}
} else if (syncMessage.groups != nil) {
if (wasSentByMasterDevice && syncMessage.groups.data.length > 0) {
OWSLogInfo(@"[Loki] Received group sync message.");
[LKLogger print:@"[Loki] Received group sync message."];
NSData *data = syncMessage.groups.data;
GroupParser *parser = [[GroupParser alloc] initWithData:data];
NSArray<TSGroupModel *> *groupModels = [parser parseGroupModels];
@ -1428,7 +1429,7 @@ NS_ASSUME_NONNULL_BEGIN
}).catchOn(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(NSError *error) {
dispatch_semaphore_signal(semaphore);
}) retainUntilComplete];
dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, 4 * NSEC_PER_SEC));
dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, 10 * NSEC_PER_SEC));
}
if (groupId.length > 0) {
@ -1461,7 +1462,7 @@ NS_ASSUME_NONNULL_BEGIN
switch (dataMessage.group.type) {
case SSKProtoGroupContextTypeUpdate: {
if (oldGroupThread && ![oldGroupThread isUserAdminForGroup:hexEncodedPublicKey transaction:transaction]) {
if (oldGroupThread && ![oldGroupThread isUserAdminInGroup:hexEncodedPublicKey transaction:transaction]) {
[LKLogger print:[NSString stringWithFormat:@"[Loki] Received a group update from a non-admin user for %@; ignoring.", [LKGroupUtilities getEncodedGroupID:groupId]]];
return nil;
}

View File

@ -100,8 +100,8 @@ NS_SWIFT_NAME(MessageSender)
failure:(void (^)(NSError *error))failureHandler;
- (OWSMessageSend *)getSessionRestoreMessageForHexEncodedPublicKey:(NSString *)hexEncodedPublicKey;
- (LKFriendRequestMessage *)getMultiDeviceFriendRequestMessageForHexEncodedPublicKey:(NSString *)hexEncodedPublicKey inThread:(TSContactThread *)thread transaction:(YapDatabaseReadWriteTransaction *)transaction;
- (OWSMessageSend *)getMultiDeviceFriendRequestMessageForHexEncodedPublicKey:(NSString *)hexEncodedPublicKey;
- (LKFriendRequestMessage *)getMultiDeviceFriendRequestMessageForHexEncodedPublicKey:(NSString *)hexEncodedPublicKey transaction:(YapDatabaseReadWriteTransaction *)transaction;
- (void)sendMessage:(OWSMessageSend *)messageSend;
@end

View File

@ -937,9 +937,9 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
return [[OWSMessageSend alloc] initWithMessage:message thread:thread recipient:recipient senderCertificate:senderCertificate udAccess:theirUDAccess localNumber:userHexEncodedPublicKey success:^{ } failure:^(NSError *error) { }];
}
- (LKFriendRequestMessage *)getMultiDeviceFriendRequestMessageForHexEncodedPublicKey:(NSString *)hexEncodedPublicKey inThread:(TSContactThread *)thread transaction:(YapDatabaseReadWriteTransaction *)transaction
- (LKFriendRequestMessage *)getMultiDeviceFriendRequestMessageForHexEncodedPublicKey:(NSString *)hexEncodedPublicKey transaction:(YapDatabaseReadWriteTransaction *)transaction
{
thread = [TSContactThread getOrCreateThreadWithContactId:hexEncodedPublicKey transaction:transaction];
TSContactThread *thread = [TSContactThread getOrCreateThreadWithContactId:hexEncodedPublicKey transaction:transaction];
// Force hide slave device thread
NSString *masterHexEncodedPublicKey = [LKDatabaseUtilities getMasterHexEncodedPublicKeyFor:hexEncodedPublicKey in:transaction];
thread.isForceHidden = masterHexEncodedPublicKey != nil && ![masterHexEncodedPublicKey isEqualToString:hexEncodedPublicKey];
@ -950,26 +950,17 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
LKFriendRequestMessage *message = [[LKFriendRequestMessage alloc] initOutgoingMessageWithTimestamp:NSDate.ows_millisecondTimeStamp inThread:thread messageBody:@"Please accept to enable messages to be synced across devices" attachmentIds:[NSMutableArray new]
expiresInSeconds:0 expireStartedAt:0 isVoiceMessage:NO groupMetaMessage:TSGroupMetaMessageUnspecified quotedMessage:nil contactShare:nil linkPreview:nil];
message.skipSave = YES;
[message saveWithTransaction:transaction];
return message;
}
- (OWSMessageSend *)getMultiDeviceFriendRequestMessageForHexEncodedPublicKey:(NSString *)hexEncodedPublicKey
{
__block TSContactThread *thread;
__block LKFriendRequestMessage *message;
[OWSPrimaryStorage.sharedManager.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
thread = [TSContactThread getOrCreateThreadWithContactId:hexEncodedPublicKey transaction:transaction];
// Force hide slave device thread
NSString *masterHexEncodedPublicKey = [LKDatabaseUtilities getMasterHexEncodedPublicKeyFor:hexEncodedPublicKey in:transaction];
thread.isForceHidden = masterHexEncodedPublicKey != nil && ![masterHexEncodedPublicKey isEqualToString:hexEncodedPublicKey];
if (thread.friendRequestStatus == LKThreadFriendRequestStatusNone || thread.friendRequestStatus == LKThreadFriendRequestStatusRequestExpired) {
[thread saveFriendRequestStatus:LKThreadFriendRequestStatusRequestSent withTransaction:transaction];
}
[thread saveWithTransaction:transaction];
message = [self getMultiDeviceFriendRequestMessageForHexEncodedPublicKey:hexEncodedPublicKey transaction:transaction];
}];
LKFriendRequestMessage *message = [[LKFriendRequestMessage alloc] initOutgoingMessageWithTimestamp:NSDate.ows_millisecondTimeStamp inThread:thread messageBody:@"Please accept to enable messages to be synced across devices" attachmentIds:[NSMutableArray new]
expiresInSeconds:0 expireStartedAt:0 isVoiceMessage:NO groupMetaMessage:TSGroupMetaMessageUnspecified quotedMessage:nil contactShare:nil linkPreview:nil];
message.skipSave = YES;
SignalRecipient *recipient = [[SignalRecipient alloc] initWithUniqueId:hexEncodedPublicKey];
NSString *userHexEncodedPublicKey = OWSIdentityManager.sharedManager.identityKeyPair.hexEncodedPublicKey;
SMKSenderCertificate *senderCertificate = [self.udManager getSenderCertificate];