session-ios/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.h
Michael Kirk 550e7ba63b Create disappearing message update info messages before messages they affect
Since we're no longer sorting by timestamp we have to ensure we save the update
info message before we save any affected message, e.g. in the case of implicit
updates.
2018-09-26 09:52:33 -06:00

53 lines
1.8 KiB
Objective-C

//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
NS_ASSUME_NONNULL_BEGIN
@class OWSPrimaryStorage;
@class TSMessage;
@class TSThread;
@class YapDatabaseReadWriteTransaction;
@protocol ContactsManagerProtocol;
@interface OWSDisappearingMessagesJob : NSObject
+ (instancetype)sharedJob;
- (instancetype)init NS_UNAVAILABLE;
- (void)startAnyExpirationForMessage:(TSMessage *)message
expirationStartedAt:(uint64_t)expirationStartedAt
transaction:(YapDatabaseReadWriteTransaction *_Nonnull)transaction;
/**
* Synchronize our disappearing messages settings with that of the given message. Useful so we can
* become eventually consistent with remote senders.
*
* @param duration
* Can be 0, indicating a non-expiring message, or greater, indicating an expiring message. We match the expiration
* timer of the message, including disabling expiring messages if the message is not an expiring message.
*
* @param remoteRecipientId
* nil for outgoing messages, otherwise the recipientId of the sender
*
* @param createdInExistingGroup
* YES when being added to a group which already has DM enabled, otherwise NO
*/
- (void)becomeConsistentWithDisappearingDuration:(uint32_t)duration
thread:(TSThread *)thread
createdByRemoteRecipientId:(nullable NSString *)remoteRecipientId
createdInExistingGroup:(BOOL)createdInExistingGroup
transaction:(YapDatabaseReadWriteTransaction *)transaction;
// Clean up any messages that expired since last launch immediately
// and continue cleaning in the background.
- (void)startIfNecessary;
- (void)cleanupMessagesWhichFailedToStartExpiringWithTransaction:(YapDatabaseReadWriteTransaction *)transaction;
@end
NS_ASSUME_NONNULL_END