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
- (void)saveWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
- (BOOL)shouldBeSaved
{
// override superclass with no-op.
//
// 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 NO;
}
- (NSString *)debugDescription

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

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

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

@ -36,11 +36,9 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
- (void)saveWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
- (BOOL)shouldBeSaved
{
// override superclass with no-op.
//
// There's no need to save this message, since it's not displayed to the user.
return NO;
}
- (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 "OWSSignalServiceProtos.pb.h"
@ -8,11 +9,9 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSEndSessionMessage
- (void)saveWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
- (BOOL)shouldBeSaved
{
// override superclass with no-op.
//
// There's no need to save this message, since it's not displayed to the user.
return NO;
}
- (OWSSignalServiceProtosDataMessageBuilder *)dataMessageBuilder

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

@ -198,8 +198,20 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
return self;
}
- (BOOL)shouldBeSaved
{
return YES;
}
- (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)) {
DDLogDebug(@"%@ Skipping save for group meta message.", self.logTag);
return;

@ -281,7 +281,7 @@ NSUInteger const OWSSendMessageOperationMaxRetries = 4;
- (void)tryWithRemainingRetries:(NSUInteger)remainingRetries
{
// 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);
NSError *error = OWSErrorWithCodeDescription(
OWSErrorCodeMessageDeletedBeforeSent, @"Message was deleted before it could be sent.");

@ -171,13 +171,9 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - TSYapDatabaseObject overrides
- (void)saveWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
- (BOOL)shouldBeSaved
{
// override superclass with no-op.
//
// 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 NO;
}
- (NSString *)debugDescription

@ -65,10 +65,9 @@ NS_ASSUME_NONNULL_BEGIN
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;
return NO;
}
@end

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

Loading…
Cancel
Save