Merge branch 'friend-request-refactor' of github.com:loki-project/loki-messenger-ios into friend-request-refactor

pull/175/head
nielsandriesse 5 years ago
commit 845de99561

@ -173,10 +173,7 @@ public final class SyncMessagesProtocol : NSObject {
switch friendRequestStatus { switch friendRequestStatus {
case .none, .requestExpired: case .none, .requestExpired:
let messageSender = SSKEnvironment.shared.messageSender let messageSender = SSKEnvironment.shared.messageSender
// TODO: Does the function below need to handle multi device?? // We need to send the FR message to all of the users device as the contact sync message excludes slave devices
// We need to send a FR message here directly to the user. Multi device doesn't come into play.
// TODO: Say A1 has a conversation with B1 and B2. A2 is now linked to A1. We'd want A2 to establish
// sessions with both B1 and B2, right?
let autoGeneratedFRMessage = MultiDeviceProtocol.getAutoGeneratedMultiDeviceFRMessage(for: hexEncodedPublicKey, in: transaction) let autoGeneratedFRMessage = MultiDeviceProtocol.getAutoGeneratedMultiDeviceFRMessage(for: hexEncodedPublicKey, in: transaction)
thread.isForceHidden = true thread.isForceHidden = true
thread.save(with: transaction) thread.save(with: transaction)

@ -213,7 +213,7 @@ public class LokiP2PAPI : NSObject {
var friendThreadIDs: [String] = [] var friendThreadIDs: [String] = []
storage.dbReadConnection.read { transaction in storage.dbReadConnection.read { transaction in
TSContactThread.enumerateCollectionObjects(with: transaction) { object, _ in TSContactThread.enumerateCollectionObjects(with: transaction) { object, _ in
guard let thread = object as? TSContactThread, let uniqueID = thread.uniqueId, thread.contactIdentifier() == ourHexEncodedPubKey else { return } guard let thread = object as? TSContactThread, let uniqueID = thread.uniqueId, thread.contactIdentifier() != ourHexEncodedPubKey else { return }
let status = storage.getFriendRequestStatus(for: thread.contactIdentifier(), transaction: transaction) let status = storage.getFriendRequestStatus(for: thread.contactIdentifier(), transaction: transaction)
guard status == .friends else { return } guard status == .friends else { return }
friendThreadIDs.append(uniqueID) friendThreadIDs.append(uniqueID)

@ -1220,7 +1220,6 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
if (isSuccess) { return; } // Succeed as soon as the first promise succeeds if (isSuccess) { return; } // Succeed as soon as the first promise succeeds
[NSNotificationCenter.defaultCenter postNotificationName:NSNotification.messageSent object:[[NSNumber alloc] initWithUnsignedLongLong:signalMessage.timestamp]]; [NSNotificationCenter.defaultCenter postNotificationName:NSNotification.messageSent object:[[NSNumber alloc] initWithUnsignedLongLong:signalMessage.timestamp]];
isSuccess = YES; isSuccess = YES;
if (signalMessage.isFriendRequest) { if (signalMessage.isFriendRequest) {
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { [self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
if (!message.skipSave) { if (!message.skipSave) {

Loading…
Cancel
Save