Fix calling; be explicit about which messages should be saved.

pull/1/head
Matthew Chen 8 years ago
parent 20355521fc
commit 2f84e0c426

@ -67,13 +67,9 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - TSYapDatabaseObject overrides #pragma mark - TSYapDatabaseObject overrides
- (void)saveWithTransaction:(YapDatabaseReadWriteTransaction *)transaction - (BOOL)shouldBeSaved
{ {
// override superclass with no-op. return NO;
//
// There's no need to save this message, since it's not displayed to the user.
//
// Should we find a need to save this in the future, we need to exclude any non-serializable properties.
} }
- (NSString *)debugDescription - (NSString *)debugDescription

@ -11,11 +11,9 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSOutgoingSyncMessage @implementation OWSOutgoingSyncMessage
- (void)saveWithTransaction:(YapDatabaseReadWriteTransaction *)transaction - (BOOL)shouldBeSaved
{ {
// override superclass with no-op. return NO;
//
// There's no need to save this message, since it's not displayed to the user.
} }
- (BOOL)shouldSyncTranscript - (BOOL)shouldSyncTranscript

@ -31,11 +31,9 @@ NS_ASSUME_NONNULL_BEGIN
return self; return self;
} }
- (void)saveWithTransaction:(YapDatabaseReadWriteTransaction *)transaction - (BOOL)shouldBeSaved
{ {
// override superclass with no-op. return NO;
//
// There's no need to save this message, since it's not displayed to the user.
} }
- (BOOL)shouldSyncTranscript - (BOOL)shouldSyncTranscript

@ -17,11 +17,9 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSDisappearingMessagesConfigurationMessage @implementation OWSDisappearingMessagesConfigurationMessage
- (void)saveWithTransaction:(YapDatabaseReadWriteTransaction *)transaction - (BOOL)shouldBeSaved
{ {
// override superclass with no-op. return NO;
//
// There's no need to save this message, since it's not displayed to the user.
} }
- (instancetype)initWithConfiguration:(OWSDisappearingMessagesConfiguration *)configuration thread:(TSThread *)thread - (instancetype)initWithConfiguration:(OWSDisappearingMessagesConfiguration *)configuration thread:(TSThread *)thread

@ -36,11 +36,9 @@ NS_ASSUME_NONNULL_BEGIN
return self; return self;
} }
- (void)saveWithTransaction:(YapDatabaseReadWriteTransaction *)transaction - (BOOL)shouldBeSaved
{ {
// override superclass with no-op. return NO;
//
// There's no need to save this message, since it's not displayed to the user.
} }
- (NSData *)buildPlainTextData:(SignalRecipient *)recipient - (NSData *)buildPlainTextData:(SignalRecipient *)recipient

@ -1,5 +1,6 @@
// Created by Michael Kirk on 11/3/16. //
// Copyright © 2016 Open Whisper Systems. All rights reserved. // Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSEndSessionMessage.h" #import "OWSEndSessionMessage.h"
#import "OWSSignalServiceProtos.pb.h" #import "OWSSignalServiceProtos.pb.h"
@ -8,11 +9,9 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSEndSessionMessage @implementation OWSEndSessionMessage
- (void)saveWithTransaction:(YapDatabaseReadWriteTransaction *)transaction - (BOOL)shouldBeSaved
{ {
// override superclass with no-op. return NO;
//
// There's no need to save this message, since it's not displayed to the user.
} }
- (OWSSignalServiceProtosDataMessageBuilder *)dataMessageBuilder - (OWSSignalServiceProtosDataMessageBuilder *)dataMessageBuilder

@ -148,6 +148,8 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
- (OWSSignalServiceProtosAttachmentPointer *)buildAttachmentProtoForAttachmentId:(NSString *)attachmentId - (OWSSignalServiceProtosAttachmentPointer *)buildAttachmentProtoForAttachmentId:(NSString *)attachmentId
filename:(nullable NSString *)filename; filename:(nullable NSString *)filename;
- (BOOL)shouldBeSaved;
#pragma mark - Update With... Methods #pragma mark - Update With... Methods
- (void)updateWithMessageState:(TSOutgoingMessageState)messageState; - (void)updateWithMessageState:(TSOutgoingMessageState)messageState;

@ -198,8 +198,20 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
return self; return self;
} }
- (BOOL)shouldBeSaved
{
return YES;
}
- (void)saveWithTransaction:(YapDatabaseReadWriteTransaction *)transaction - (void)saveWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
{ {
if (!self.shouldBeSaved) {
// There's no need to save this message, since it's not displayed to the user.
//
// Should we find a need to save this in the future, we need to exclude any non-serializable properties.
return;
}
if (!(self.groupMetaMessage == TSGroupMessageDeliver || self.groupMetaMessage == TSGroupMessageNone)) { if (!(self.groupMetaMessage == TSGroupMessageDeliver || self.groupMetaMessage == TSGroupMessageNone)) {
DDLogDebug(@"%@ Skipping save for group meta message.", self.logTag); DDLogDebug(@"%@ Skipping save for group meta message.", self.logTag);
return; return;

@ -281,7 +281,7 @@ NSUInteger const OWSSendMessageOperationMaxRetries = 4;
- (void)tryWithRemainingRetries:(NSUInteger)remainingRetries - (void)tryWithRemainingRetries:(NSUInteger)remainingRetries
{ {
// If the message has been deleted, abort send. // If the message has been deleted, abort send.
if (![TSOutgoingMessage fetchObjectWithUniqueID:self.message.uniqueId]) { if (self.message.shouldBeSaved && ![TSOutgoingMessage fetchObjectWithUniqueID:self.message.uniqueId]) {
DDLogInfo(@"%@ aborting message send; message deleted.", self.logTag); DDLogInfo(@"%@ aborting message send; message deleted.", self.logTag);
NSError *error = OWSErrorWithCodeDescription( NSError *error = OWSErrorWithCodeDescription(
OWSErrorCodeMessageDeletedBeforeSent, @"Message was deleted before it could be sent."); OWSErrorCodeMessageDeletedBeforeSent, @"Message was deleted before it could be sent.");

@ -171,13 +171,9 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - TSYapDatabaseObject overrides #pragma mark - TSYapDatabaseObject overrides
- (void)saveWithTransaction:(YapDatabaseReadWriteTransaction *)transaction - (BOOL)shouldBeSaved
{ {
// override superclass with no-op. return NO;
//
// There's no need to save this message, since it's not displayed to the user.
//
// Should we find a need to save this in the future, we need to exclude any non-serializable properties.
} }
- (NSString *)debugDescription - (NSString *)debugDescription

@ -65,10 +65,9 @@ NS_ASSUME_NONNULL_BEGIN
return NO; return NO;
} }
- (void)saveWithTransaction:(YapDatabaseReadWriteTransaction *)transaction - (BOOL)shouldBeSaved
{ {
// No-op as we don't want to actually display this as an outgoing message in our thread. return NO;
return;
} }
@end @end

@ -12,11 +12,9 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSProfileKeyMessage @implementation OWSProfileKeyMessage
- (void)saveWithTransaction:(YapDatabaseReadWriteTransaction *)transaction - (BOOL)shouldBeSaved
{ {
// override superclass with no-op. return NO;
//
// There's no need to save this message, since it's not displayed to the user.
} }
- (BOOL)shouldSyncTranscript - (BOOL)shouldSyncTranscript

Loading…
Cancel
Save