Compare commits

...

2 Commits

Author SHA1 Message Date
Michael Kirk
2737845c25 assert only sending sync messages when appropriate
// FREEBIE
2017-06-21 21:08:20 -04:00
Michael Kirk
388f75ef04 no need to send sync messages when only 1 device
// FREEBIE
2017-06-21 19:11:01 -04:00

View File

@ -594,6 +594,19 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
{
TSThread *thread = message.thread;
#ifdef DEBUG
// Assert that we're only sending sync messages when necessary
if ([message isKindOfClass:[OWSOutgoingSyncMessage class]]) {
__block BOOL hasSecondaryDevices = NO;
[self.storageManager.dbConnection readWithBlock:^(YapDatabaseReadTransaction *_Nonnull transaction) {
hasSecondaryDevices = [OWSDevice hasSecondaryDevicesWithTransaction:transaction];
}];
if (!hasSecondaryDevices) {
OWSFail(@"Sending sync message when we have no devices to sync to.");
}
}
#endif
dispatch_async([OWSDispatch sendingQueue], ^{
if ([thread isKindOfClass:[TSGroupThread class]]) {
TSGroupThread *gThread = (TSGroupThread *)thread;
@ -1089,10 +1102,16 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
- (void)handleMessageSentLocally:(TSOutgoingMessage *)message
{
if (message.shouldSyncTranscript) {
// TODO: I suspect we shouldn't optimistically set hasSyncedTranscript.
// We could set this in a success handler for [sendSyncTranscriptForMessage:].
[message updateWithHasSyncedTranscript:YES];
[self sendSyncTranscriptForMessage:message];
__block BOOL hasSecondaryDevices = NO;
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *_Nonnull transaction) {
hasSecondaryDevices = [OWSDevice hasSecondaryDevicesWithTransaction:transaction];
}];
if (hasSecondaryDevices) {
// TODO: I suspect we shouldn't optimistically set hasSyncedTranscript.
// We could set this in a success handler for [sendSyncTranscriptForMessage:].
[message updateWithHasSyncedTranscript:YES];
[self sendSyncTranscriptForMessage:message];
}
}
[OWSDisappearingMessagesJob setExpirationForMessage:message];