fix sending logic for prekey bundle message

This commit is contained in:
Ryan ZHAO 2020-08-20 16:57:18 +10:00
parent d420d6dd4d
commit 113ad28d5a

View file

@ -1450,13 +1450,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
OWSPrimaryStorage *storage = self.primaryStorage;
SignalRecipient *recipient = messageSend.recipient;
OWSAssertDebug(recipientID.length > 0);
__block BOOL hasSession;
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
hasSession = [storage containsSession:recipientID deviceId:[deviceId intValue] protocolContext:transaction];
} error:nil];
if (hasSession) { return YES; }
// Discard "typing indicator" messages if there is no existing session with the user.
BOOL canSafelyBeDiscarded = messageSend.message.isOnline;
if (canSafelyBeDiscarded) {
@ -1467,6 +1461,12 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
__block NSException *exception;
if (!bundle) {
__block BOOL hasSession;
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
hasSession = [storage containsSession:recipientID deviceId:[deviceId intValue] protocolContext:transaction];
} error:nil];
if (hasSession) { return YES; }
TSOutgoingMessage *message = messageSend.message;
// Loki: Remove this when we have shared sender keys
// ========