diff --git a/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift b/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift index aa0c666b8..6109865c0 100644 --- a/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift +++ b/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift @@ -43,6 +43,8 @@ public final class ClosedGroupsProtocol : NSObject { thread.save(with: transaction) let sessionRequestMessage = SessionRequestMessage(thread: thread) let messageSenderJobQueue = SSKEnvironment.shared.messageSenderJobQueue + // This has to happen sync to ensure that session requests get sent before AFRs do (it's + // asssumed that the master device first syncs closed groups first and contacts after that). messageSenderJobQueue.add(message: sessionRequestMessage, transaction: transaction) } } diff --git a/SignalServiceKit/src/Loki/Protocol/Sync Messages/SyncMessagesProtocol.swift b/SignalServiceKit/src/Loki/Protocol/Sync Messages/SyncMessagesProtocol.swift index d1995d13d..e9b338d6b 100644 --- a/SignalServiceKit/src/Loki/Protocol/Sync Messages/SyncMessagesProtocol.swift +++ b/SignalServiceKit/src/Loki/Protocol/Sync Messages/SyncMessagesProtocol.swift @@ -175,7 +175,10 @@ public final class SyncMessagesProtocol : NSObject { case .none, .requestExpired: // We need to send the FR message to all of the user's devices as the contact sync message excludes slave devices let autoGeneratedFRMessage = MultiDeviceProtocol.getAutoGeneratedMultiDeviceFRMessage(for: hexEncodedPublicKey, in: transaction) - // This takes into account multi device + // Use the message sender job queue for this to ensure that these messages get sent + // AFTER session requests (it's asssumed that the master device first syncs closed + // groups first and contacts after that). + // This takes into account multi device. let messageSenderJobQueue = SSKEnvironment.shared.messageSenderJobQueue messageSenderJobQueue.add(message: autoGeneratedFRMessage, transaction: transaction) case .requestReceived: