Rework outgoing message state.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-04-12 11:15:15 -04:00
parent bf18b1f286
commit 1404d0d7eb
7 changed files with 10 additions and 38 deletions

View File

@ -25,8 +25,7 @@
messageBody:nil
attachmentIds:@[]
expiresInSeconds:0
expireStartedAt:0
groupMetaMessage:TSGroupMessageNone];
expireStartedAt:0];
if (!self) {
return self;

View File

@ -47,8 +47,7 @@ NSString *const TSIncomingMessageWasReadOnThisDeviceNotification = @"TSIncomingM
messageBody:body
attachmentIds:attachmentIds
expiresInSeconds:expiresInSeconds
expireStartedAt:0
groupMetaMessage:TSGroupMessageNone];
expireStartedAt:0];
if (!self) {
return self;

View File

@ -23,8 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
messageBody:nil
attachmentIds:@[]
expiresInSeconds:0
expireStartedAt:0
groupMetaMessage:TSGroupMessageNone];
expireStartedAt:0];
if (!self) {
return self;

View File

@ -24,7 +24,6 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
@property (nonatomic, readonly) NSMutableArray<NSString *> *attachmentIds;
@property (nullable, nonatomic) NSString *body;
@property (atomic, readonly) TSGroupMetaMessage groupMetaMessage;
@property (nonatomic) uint32_t expiresInSeconds;
@property (nonatomic) uint64_t expireStartedAt;
@property (nonatomic, readonly) uint64_t expiresAt;
@ -58,15 +57,7 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
messageBody:(nullable NSString *)body
attachmentIds:(NSArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds
expireStartedAt:(uint64_t)expireStartedAt;
- (instancetype)initWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
messageBody:(nullable NSString *)body
attachmentIds:(NSArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds
expireStartedAt:(uint64_t)expireStartedAt
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage NS_DESIGNATED_INITIALIZER;
expireStartedAt:(uint64_t)expireStartedAt NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;

View File

@ -36,8 +36,6 @@ static const NSUInteger OWSMessageSchemaVersion = 3;
*/
@property (nonatomic, readonly) NSUInteger schemaVersion;
@property (atomic) TSGroupMetaMessage groupMetaMessage;
@end
#pragma mark -
@ -93,23 +91,6 @@ static const NSUInteger OWSMessageSchemaVersion = 3;
attachmentIds:(NSArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds
expireStartedAt:(uint64_t)expireStartedAt
{
return [self initWithTimestamp:timestamp
inThread:thread
messageBody:body
attachmentIds:attachmentIds
expiresInSeconds:expiresInSeconds
expireStartedAt:expireStartedAt
groupMetaMessage:TSGroupMessageNone];
}
- (instancetype)initWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
messageBody:(nullable NSString *)body
attachmentIds:(NSArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds
expireStartedAt:(uint64_t)expireStartedAt
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
{
self = [super initWithTimestamp:timestamp inThread:thread];
@ -125,7 +106,6 @@ static const NSUInteger OWSMessageSchemaVersion = 3;
_expireStartedAt = expireStartedAt;
[self updateExpiresAt];
_receivedAtDate = [NSDate date];
_groupMetaMessage = groupMetaMessage;
return self;
}

View File

@ -77,6 +77,8 @@ typedef NS_ENUM(NSInteger, TSOutgoingMessageState) {
// A map of attachment id-to-filename.
@property (nonatomic, readonly) NSMutableDictionary<NSString *, NSString *> *attachmentFilenameMap;
@property (atomic, readonly) TSGroupMetaMessage groupMetaMessage;
/**
* Whether the message should be serialized as a modern aka Content, or the old style legacy message.
* Sync and Call messsages must be sent as Content, but other old style DataMessage payloads should be

View File

@ -29,6 +29,8 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
// same recipient.
@property (atomic) NSArray<NSString *> *sentRecipients;
@property (atomic) TSGroupMetaMessage groupMetaMessage;
@end
#pragma mark -
@ -148,8 +150,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
messageBody:body
attachmentIds:attachmentIds
expiresInSeconds:expiresInSeconds
expireStartedAt:expireStartedAt
groupMetaMessage:groupMetaMessage];
expireStartedAt:expireStartedAt];
if (!self) {
return self;
}
@ -157,6 +158,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
_messageState = TSOutgoingMessageStateAttemptingOut;
_sentRecipients = [NSArray new];
_hasSyncedTranscript = NO;
_groupMetaMessage = groupMetaMessage;
_attachmentFilenameMap = [NSMutableDictionary new];