mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Fix multi device contact syncing
This commit is contained in:
parent
24d70341ed
commit
4b595575f6
3 changed files with 11 additions and 6 deletions
|
@ -127,6 +127,10 @@ public final class FriendRequestProtocol : NSObject {
|
|||
}
|
||||
}
|
||||
}
|
||||
// Send a contact sync message
|
||||
let masterHexEncodedPublicKey = storage.getMasterHexEncodedPublicKey(for: hexEncodedPublicKey, in: transaction) ?? hexEncodedPublicKey
|
||||
let syncManager = SSKEnvironment.shared.syncManager
|
||||
syncManager.syncContact(masterHexEncodedPublicKey, transaction: transaction)
|
||||
}
|
||||
|
||||
@objc(sendFriendRequestAcceptanceMessageToHexEncodedPublicKey:using:)
|
||||
|
@ -231,6 +235,10 @@ public final class FriendRequestProtocol : NSObject {
|
|||
guard friendRequestStatus != .none else { return }
|
||||
// Become friends
|
||||
storage.setFriendRequestStatus(.friends, for: hexEncodedPublicKey, transaction: transaction)
|
||||
// Send a contact sync message
|
||||
let masterHexEncodedPublicKey = storage.getMasterHexEncodedPublicKey(for: hexEncodedPublicKey, in: transaction) ?? hexEncodedPublicKey
|
||||
let syncManager = SSKEnvironment.shared.syncManager
|
||||
syncManager.syncContact(masterHexEncodedPublicKey, transaction: transaction)
|
||||
}
|
||||
|
||||
@objc(handleFriendRequestMessageIfNeededFromEnvelope:using:)
|
||||
|
|
|
@ -184,9 +184,6 @@ public final class SessionManagementProtocol : NSObject {
|
|||
let thread = TSContactThread.getWithContactId(hexEncodedPublicKey, transaction: transaction), // TODO: Should this be getOrCreate?
|
||||
thread.isContactFriend {
|
||||
receiving_startSessionReset(in: thread, using: transaction)
|
||||
// Notify our other devices that we've started a session reset
|
||||
let syncManager = SSKEnvironment.shared.syncManager
|
||||
syncManager.syncContact(hexEncodedPublicKey, transaction: transaction)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -155,9 +155,9 @@ public final class SyncMessagesProtocol : NSObject {
|
|||
public static func handleContactSyncMessageIfNeeded(_ syncMessage: SSKProtoSyncMessage, wrappedIn envelope: SSKProtoEnvelope, using transaction: YapDatabaseReadWriteTransaction) {
|
||||
// The envelope source is set during UD decryption
|
||||
let hexEncodedPublicKey = envelope.source!
|
||||
guard let masterHexEncodedPublicKey = storage.getMasterHexEncodedPublicKey(for: getUserHexEncodedPublicKey(), in: transaction) else { return }
|
||||
let wasSentByMasterDevice = (masterHexEncodedPublicKey == hexEncodedPublicKey)
|
||||
guard wasSentByMasterDevice, let contacts = syncMessage.contacts, let contactsAsData = contacts.data, contactsAsData.count > 0 else { return }
|
||||
let linkedDevices = LokiDatabaseUtilities.getLinkedDeviceHexEncodedPublicKeys(for: hexEncodedPublicKey, in: transaction)
|
||||
let wasSentByLinkedDevice = linkedDevices.contains(hexEncodedPublicKey)
|
||||
guard wasSentByLinkedDevice, let contacts = syncMessage.contacts, let contactsAsData = contacts.data, contactsAsData.count > 0 else { return }
|
||||
print("[Loki] Contact sync message received.")
|
||||
handleContactSyncMessageData(contactsAsData, using: transaction)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue