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 messageBody:nil
attachmentIds:@[] attachmentIds:@[]
expiresInSeconds:0 expiresInSeconds:0
expireStartedAt:0 expireStartedAt:0];
groupMetaMessage:TSGroupMessageNone];
if (!self) { if (!self) {
return self; return self;

View File

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

View File

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

View File

@ -24,7 +24,6 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
@property (nonatomic, readonly) NSMutableArray<NSString *> *attachmentIds; @property (nonatomic, readonly) NSMutableArray<NSString *> *attachmentIds;
@property (nullable, nonatomic) NSString *body; @property (nullable, nonatomic) NSString *body;
@property (atomic, readonly) TSGroupMetaMessage groupMetaMessage;
@property (nonatomic) uint32_t expiresInSeconds; @property (nonatomic) uint32_t expiresInSeconds;
@property (nonatomic) uint64_t expireStartedAt; @property (nonatomic) uint64_t expireStartedAt;
@property (nonatomic, readonly) uint64_t expiresAt; @property (nonatomic, readonly) uint64_t expiresAt;
@ -58,15 +57,7 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
messageBody:(nullable NSString *)body messageBody:(nullable NSString *)body
attachmentIds:(NSArray<NSString *> *)attachmentIds attachmentIds:(NSArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds expiresInSeconds:(uint32_t)expiresInSeconds
expireStartedAt:(uint64_t)expireStartedAt; expireStartedAt:(uint64_t)expireStartedAt NS_DESIGNATED_INITIALIZER;
- (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;
- (nullable instancetype)initWithCoder:(NSCoder *)coder 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 (nonatomic, readonly) NSUInteger schemaVersion;
@property (atomic) TSGroupMetaMessage groupMetaMessage;
@end @end
#pragma mark - #pragma mark -
@ -93,23 +91,6 @@ static const NSUInteger OWSMessageSchemaVersion = 3;
attachmentIds:(NSArray<NSString *> *)attachmentIds attachmentIds:(NSArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds expiresInSeconds:(uint32_t)expiresInSeconds
expireStartedAt:(uint64_t)expireStartedAt 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]; self = [super initWithTimestamp:timestamp inThread:thread];
@ -125,7 +106,6 @@ static const NSUInteger OWSMessageSchemaVersion = 3;
_expireStartedAt = expireStartedAt; _expireStartedAt = expireStartedAt;
[self updateExpiresAt]; [self updateExpiresAt];
_receivedAtDate = [NSDate date]; _receivedAtDate = [NSDate date];
_groupMetaMessage = groupMetaMessage;
return self; return self;
} }

View File

@ -77,6 +77,8 @@ typedef NS_ENUM(NSInteger, TSOutgoingMessageState) {
// A map of attachment id-to-filename. // A map of attachment id-to-filename.
@property (nonatomic, readonly) NSMutableDictionary<NSString *, NSString *> *attachmentFilenameMap; @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. * 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 * 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. // same recipient.
@property (atomic) NSArray<NSString *> *sentRecipients; @property (atomic) NSArray<NSString *> *sentRecipients;
@property (atomic) TSGroupMetaMessage groupMetaMessage;
@end @end
#pragma mark - #pragma mark -
@ -148,8 +150,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
messageBody:body messageBody:body
attachmentIds:attachmentIds attachmentIds:attachmentIds
expiresInSeconds:expiresInSeconds expiresInSeconds:expiresInSeconds
expireStartedAt:expireStartedAt expireStartedAt:expireStartedAt];
groupMetaMessage:groupMetaMessage];
if (!self) { if (!self) {
return self; return self;
} }
@ -157,6 +158,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
_messageState = TSOutgoingMessageStateAttemptingOut; _messageState = TSOutgoingMessageStateAttemptingOut;
_sentRecipients = [NSArray new]; _sentRecipients = [NSArray new];
_hasSyncedTranscript = NO; _hasSyncedTranscript = NO;
_groupMetaMessage = groupMetaMessage;
_attachmentFilenameMap = [NSMutableDictionary new]; _attachmentFilenameMap = [NSMutableDictionary new];