mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Timestamp audit step1: change signature
There is no change in functionality in this commit. Apart from clarifying what the timestamp means (it's the timestamp of the *sender*), this intentionally breaks all the call sites, so I could have a sane way to thoroughly audit wherever we're passing in timestamps, to see where we're depending on them to affect sort order. For the sake of a cleaner diff of meaningful changes, instead of "fixing" everything in this commit, I've just added comments and renamed signatures.
This commit is contained in:
parent
6c5fbc6de5
commit
eef1368ad3
71 changed files with 1089 additions and 972 deletions
2
Pods
2
Pods
|
@ -1 +1 @@
|
|||
Subproject commit 6b9d4a9add8fc5801e652145c7d7441b9d9c3de1
|
||||
Subproject commit 2a6302d1cf33633b229749b89e5f00fa0c4c6163
|
|
@ -30,7 +30,8 @@ public class SessionResetJob: NSObject {
|
|||
self.primaryStorage.deleteAllSessions(forContact: self.recipientId, protocolContext: transaction)
|
||||
|
||||
DispatchQueue.main.async {
|
||||
let endSessionMessage = EndSessionMessage(timestamp: NSDate.ows_millisecondTimeStamp(), in: self.thread)
|
||||
// MJK TODO - should be safe to remove this senderTimestamp
|
||||
let endSessionMessage = EndSessionMessage(senderTimestamp: NSDate.ows_millisecondTimeStamp(), in: self.thread)
|
||||
|
||||
self.messageSender.enqueue(endSessionMessage, success: {
|
||||
dbConnection.asyncReadWrite { (transaction) in
|
||||
|
@ -40,7 +41,8 @@ public class SessionResetJob: NSObject {
|
|||
self.primaryStorage.archiveAllSessions(forContact: self.recipientId, protocolContext: transaction)
|
||||
}
|
||||
Logger.info("successfully sent EndSessionMessage.")
|
||||
let message = TSInfoMessage(timestamp: NSDate.ows_millisecondTimeStamp(),
|
||||
// MJK TODO - should be safe to remove this senderTimestamp
|
||||
let message = TSInfoMessage(senderTimestamp: NSDate.ows_millisecondTimeStamp(),
|
||||
in: self.thread,
|
||||
messageType: TSInfoMessageType.typeSessionDidEnd)
|
||||
message.save()
|
||||
|
|
|
@ -64,7 +64,6 @@
|
|||
#import <SignalServiceKit/NSDate+OWS.h>
|
||||
#import <SignalServiceKit/NSTimer+OWS.h>
|
||||
#import <SignalServiceKit/OWSAddToContactsOfferMessage.h>
|
||||
#import <SignalServiceKit/OWSAddToProfileWhitelistOfferMessage.h>
|
||||
#import <SignalServiceKit/OWSAttachmentsProcessor.h>
|
||||
#import <SignalServiceKit/OWSBlockingManager.h>
|
||||
#import <SignalServiceKit/OWSDisappearingMessagesConfiguration.h>
|
||||
|
@ -2368,10 +2367,10 @@ typedef enum : NSUInteger {
|
|||
}
|
||||
|
||||
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||
quotedInteraction = [ThreadUtil findInteractionInThreadByTimestamp:quotedReply.timestamp
|
||||
authorId:quotedReply.authorId
|
||||
threadUniqueId:self.thread.uniqueId
|
||||
transaction:transaction];
|
||||
quotedInteraction = [ThreadUtil findInteractionInThreadBySenderTimestamp:quotedReply.timestamp
|
||||
authorId:quotedReply.authorId
|
||||
threadUniqueId:self.thread.uniqueId
|
||||
transaction:transaction];
|
||||
if (!quotedInteraction) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -3435,38 +3435,39 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
if ([thread isKindOfClass:[TSContactThread class]]) {
|
||||
TSContactThread *contactThread = (TSContactThread *)thread;
|
||||
|
||||
[result addObject:[[TSCall alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
withCallNumber:@"+19174054215"
|
||||
callType:RPRecentCallTypeIncoming
|
||||
inThread:contactThread]];
|
||||
[result addObject:[[TSCall alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
withCallNumber:@"+19174054215"
|
||||
callType:RPRecentCallTypeOutgoing
|
||||
inThread:contactThread]];
|
||||
[result addObject:[[TSCall alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
withCallNumber:@"+19174054215"
|
||||
callType:RPRecentCallTypeIncomingMissed
|
||||
inThread:contactThread]];
|
||||
[result addObject:[[TSCall alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
withCallNumber:@"+19174054215"
|
||||
callType:RPRecentCallTypeIncomingMissedBecauseOfChangedIdentity
|
||||
inThread:contactThread]];
|
||||
[result addObject:[[TSCall alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
withCallNumber:@"+19174054215"
|
||||
callType:RPRecentCallTypeOutgoingIncomplete
|
||||
inThread:contactThread]];
|
||||
[result addObject:[[TSCall alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
withCallNumber:@"+19174054215"
|
||||
callType:RPRecentCallTypeIncomingIncomplete
|
||||
inThread:contactThread]];
|
||||
[result addObject:[[TSCall alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
withCallNumber:@"+19174054215"
|
||||
callType:RPRecentCallTypeIncomingDeclined
|
||||
inThread:contactThread]];
|
||||
[result addObject:[[TSCall alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
withCallNumber:@"+19174054215"
|
||||
callType:RPRecentCallTypeOutgoingMissed
|
||||
inThread:contactThread]];
|
||||
[result addObject:[[TSCall alloc] initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
withCallNumber:@"+19174054215"
|
||||
callType:RPRecentCallTypeIncoming
|
||||
inThread:contactThread]];
|
||||
[result addObject:[[TSCall alloc] initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
withCallNumber:@"+19174054215"
|
||||
callType:RPRecentCallTypeOutgoing
|
||||
inThread:contactThread]];
|
||||
[result addObject:[[TSCall alloc] initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
withCallNumber:@"+19174054215"
|
||||
callType:RPRecentCallTypeIncomingMissed
|
||||
inThread:contactThread]];
|
||||
[result
|
||||
addObject:[[TSCall alloc] initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
withCallNumber:@"+19174054215"
|
||||
callType:RPRecentCallTypeIncomingMissedBecauseOfChangedIdentity
|
||||
inThread:contactThread]];
|
||||
[result addObject:[[TSCall alloc] initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
withCallNumber:@"+19174054215"
|
||||
callType:RPRecentCallTypeOutgoingIncomplete
|
||||
inThread:contactThread]];
|
||||
[result addObject:[[TSCall alloc] initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
withCallNumber:@"+19174054215"
|
||||
callType:RPRecentCallTypeIncomingIncomplete
|
||||
inThread:contactThread]];
|
||||
[result addObject:[[TSCall alloc] initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
withCallNumber:@"+19174054215"
|
||||
callType:RPRecentCallTypeIncomingDeclined
|
||||
inThread:contactThread]];
|
||||
[result addObject:[[TSCall alloc] initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
withCallNumber:@"+19174054215"
|
||||
callType:RPRecentCallTypeOutgoingMissed
|
||||
inThread:contactThread]];
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -3475,12 +3476,13 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
[[OWSDisappearingMessagesConfiguration alloc] initWithThreadId:thread.uniqueId
|
||||
enabled:YES
|
||||
durationSeconds:(uint32_t)[durationSeconds intValue]];
|
||||
// MJK - should be safe to remove this senderTimestamp
|
||||
[result addObject:[[OWSDisappearingConfigurationUpdateInfoMessage alloc]
|
||||
initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
configuration:disappearingMessagesConfiguration
|
||||
createdByRemoteName:@"Alice"
|
||||
createdInExistingGroup:NO]];
|
||||
initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
configuration:disappearingMessagesConfiguration
|
||||
createdByRemoteName:@"Alice"
|
||||
createdInExistingGroup:NO]];
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -3489,12 +3491,13 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
[[OWSDisappearingMessagesConfiguration alloc] initWithThreadId:thread.uniqueId
|
||||
enabled:YES
|
||||
durationSeconds:(uint32_t)[durationSeconds intValue]];
|
||||
// MJK - should be safe to remove this senderTimestamp
|
||||
[result addObject:[[OWSDisappearingConfigurationUpdateInfoMessage alloc]
|
||||
initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
configuration:disappearingMessagesConfiguration
|
||||
createdByRemoteName:nil
|
||||
createdInExistingGroup:YES]];
|
||||
initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
configuration:disappearingMessagesConfiguration
|
||||
createdByRemoteName:nil
|
||||
createdInExistingGroup:YES]];
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -3503,72 +3506,89 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
[[OWSDisappearingMessagesConfiguration alloc] initWithThreadId:thread.uniqueId
|
||||
enabled:YES
|
||||
durationSeconds:(uint32_t)[durationSeconds intValue]];
|
||||
// MJK TODO - remove senderTimestamp
|
||||
[result addObject:[[OWSDisappearingConfigurationUpdateInfoMessage alloc]
|
||||
initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
configuration:disappearingMessagesConfiguration
|
||||
createdByRemoteName:@"Alice"
|
||||
createdInExistingGroup:NO]];
|
||||
initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
configuration:disappearingMessagesConfiguration
|
||||
createdByRemoteName:@"Alice"
|
||||
createdInExistingGroup:NO]];
|
||||
}
|
||||
{
|
||||
OWSDisappearingMessagesConfiguration *disappearingMessagesConfiguration =
|
||||
[[OWSDisappearingMessagesConfiguration alloc] initWithThreadId:thread.uniqueId
|
||||
enabled:NO
|
||||
durationSeconds:0];
|
||||
// MJK TODO - remove senderTimestamp
|
||||
[result addObject:[[OWSDisappearingConfigurationUpdateInfoMessage alloc]
|
||||
initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
configuration:disappearingMessagesConfiguration
|
||||
createdByRemoteName:@"Alice"
|
||||
createdInExistingGroup:NO]];
|
||||
initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
configuration:disappearingMessagesConfiguration
|
||||
createdByRemoteName:@"Alice"
|
||||
createdInExistingGroup:NO]];
|
||||
}
|
||||
|
||||
[result addObject:[TSInfoMessage userNotRegisteredMessageInThread:thread recipientId:@"+19174054215"]];
|
||||
|
||||
[result addObject:[[TSInfoMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageType:TSInfoMessageTypeSessionDidEnd]];
|
||||
// MJK - should be safe to remove this senderTimestamp
|
||||
[result addObject:[[TSInfoMessage alloc] initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageType:TSInfoMessageTypeSessionDidEnd]];
|
||||
// TODO: customMessage?
|
||||
[result addObject:[[TSInfoMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageType:TSInfoMessageTypeGroupUpdate]];
|
||||
// MJK - should be safe to remove this senderTimestamp
|
||||
[result addObject:[[TSInfoMessage alloc] initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageType:TSInfoMessageTypeGroupUpdate]];
|
||||
// TODO: customMessage?
|
||||
[result addObject:[[TSInfoMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageType:TSInfoMessageTypeGroupQuit]];
|
||||
// MJK - should be safe to remove this senderTimestamp
|
||||
[result addObject:[[TSInfoMessage alloc] initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageType:TSInfoMessageTypeGroupQuit]];
|
||||
|
||||
[result addObject:[[OWSVerificationStateChangeMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
recipientId:@"+19174054215"
|
||||
verificationState:OWSVerificationStateDefault
|
||||
isLocalChange:YES]];
|
||||
[result addObject:[[OWSVerificationStateChangeMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
recipientId:@"+19174054215"
|
||||
verificationState:OWSVerificationStateVerified
|
||||
isLocalChange:YES]];
|
||||
[result
|
||||
addObject:[[OWSVerificationStateChangeMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
recipientId:@"+19174054215"
|
||||
verificationState:OWSVerificationStateNoLongerVerified
|
||||
isLocalChange:YES]];
|
||||
[result addObject:[[OWSVerificationStateChangeMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
recipientId:@"+19174054215"
|
||||
verificationState:OWSVerificationStateDefault
|
||||
isLocalChange:NO]];
|
||||
[result addObject:[[OWSVerificationStateChangeMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
recipientId:@"+19174054215"
|
||||
verificationState:OWSVerificationStateVerified
|
||||
isLocalChange:NO]];
|
||||
[result
|
||||
addObject:[[OWSVerificationStateChangeMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
recipientId:@"+19174054215"
|
||||
verificationState:OWSVerificationStateNoLongerVerified
|
||||
isLocalChange:NO]];
|
||||
// MJK - should be safe to remove this senderTimestamp
|
||||
[result addObject:[[OWSVerificationStateChangeMessage alloc]
|
||||
initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
recipientId:@"+19174054215"
|
||||
verificationState:OWSVerificationStateDefault
|
||||
isLocalChange:YES]];
|
||||
|
||||
// MJK - should be safe to remove this senderTimestamp
|
||||
[result addObject:[[OWSVerificationStateChangeMessage alloc]
|
||||
initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
recipientId:@"+19174054215"
|
||||
verificationState:OWSVerificationStateVerified
|
||||
isLocalChange:YES]];
|
||||
// MJK - should be safe to remove this senderTimestamp
|
||||
[result addObject:[[OWSVerificationStateChangeMessage alloc]
|
||||
initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
recipientId:@"+19174054215"
|
||||
verificationState:OWSVerificationStateNoLongerVerified
|
||||
isLocalChange:YES]];
|
||||
|
||||
// MJK - should be safe to remove this senderTimestamp
|
||||
[result addObject:[[OWSVerificationStateChangeMessage alloc]
|
||||
initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
recipientId:@"+19174054215"
|
||||
verificationState:OWSVerificationStateDefault
|
||||
isLocalChange:NO]];
|
||||
// MJK - should be safe to remove this senderTimestamp
|
||||
[result addObject:[[OWSVerificationStateChangeMessage alloc]
|
||||
initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
recipientId:@"+19174054215"
|
||||
verificationState:OWSVerificationStateVerified
|
||||
isLocalChange:NO]];
|
||||
// MJK - should be safe to remove this senderTimestamp
|
||||
[result addObject:[[OWSVerificationStateChangeMessage alloc]
|
||||
initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
recipientId:@"+19174054215"
|
||||
verificationState:OWSVerificationStateNoLongerVerified
|
||||
isLocalChange:NO]];
|
||||
|
||||
[result addObject:[TSErrorMessage missingSessionWithEnvelope:[self createEnvelopeForThread:thread]
|
||||
withTransaction:transaction]];
|
||||
|
@ -3585,10 +3605,11 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
withTransaction:transaction];
|
||||
OWSAssertDebug(blockingSNChangeMessage);
|
||||
[result addObject:blockingSNChangeMessage];
|
||||
[result addObject:[[TSErrorMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
failedMessageType:TSErrorMessageNonBlockingIdentityChange
|
||||
recipientId:@"+19174054215"]];
|
||||
// MJK TODO - should be safe to remove this senderTimestamp
|
||||
[result addObject:[[TSErrorMessage alloc] initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
failedMessageType:TSErrorMessageNonBlockingIdentityChange
|
||||
recipientId:@"+19174054215"]];
|
||||
}];
|
||||
|
||||
return result;
|
||||
|
@ -3750,16 +3771,17 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
NSString *randomText = [[self randomText] stringByAppendingFormat:@" (sequence: %lu)", (unsigned long)i + 1];
|
||||
switch (arc4random_uniform(isTextOnly ? 2 : 4)) {
|
||||
case 0: {
|
||||
// MJK - should be safe to remove this senderTimestamp
|
||||
TSIncomingMessage *message =
|
||||
[[TSIncomingMessage alloc] initIncomingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
authorId:@"+19174054215"
|
||||
sourceDeviceId:0
|
||||
messageBody:randomText
|
||||
attachmentIds:@[]
|
||||
expiresInSeconds:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
[[TSIncomingMessage alloc] initIncomingMessageWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
authorId:@"+19174054215"
|
||||
sourceDeviceId:0
|
||||
messageBody:randomText
|
||||
attachmentIds:@[]
|
||||
expiresInSeconds:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
[message markAsReadNowWithSendReadReceipt:NO transaction:transaction];
|
||||
break;
|
||||
}
|
||||
|
@ -3787,18 +3809,19 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
attachmentType:TSAttachmentTypeDefault];
|
||||
pointer.state = TSAttachmentPointerStateFailed;
|
||||
[pointer saveWithTransaction:transaction];
|
||||
// MJK - should be safe to remove this senderTimestamp
|
||||
TSIncomingMessage *message =
|
||||
[[TSIncomingMessage alloc] initIncomingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
authorId:@"+19174054215"
|
||||
sourceDeviceId:0
|
||||
messageBody:nil
|
||||
attachmentIds:@[
|
||||
pointer.uniqueId,
|
||||
]
|
||||
expiresInSeconds:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
[[TSIncomingMessage alloc] initIncomingMessageWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
authorId:@"+19174054215"
|
||||
sourceDeviceId:0
|
||||
messageBody:nil
|
||||
attachmentIds:@[
|
||||
pointer.uniqueId,
|
||||
]
|
||||
expiresInSeconds:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
[message markAsReadNowWithSendReadReceipt:NO transaction:transaction];
|
||||
break;
|
||||
}
|
||||
|
@ -4185,17 +4208,18 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
OWSDisappearingMessagesConfiguration *configuration =
|
||||
[OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:thread.uniqueId
|
||||
transaction:initialTransaction];
|
||||
// MJK TODO - remove senderTimestamp
|
||||
TSOutgoingMessage *message = [[TSOutgoingMessage alloc]
|
||||
initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:text
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:(configuration.isEnabled ? configuration.durationSeconds
|
||||
: 0)expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
initOutgoingMessageWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:text
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:(configuration.isEnabled ? configuration.durationSeconds
|
||||
: 0)expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
OWSLogError(@"resurrectNewOutgoingMessages2 timestamp: %llu.", message.timestamp);
|
||||
[messages addObject:message];
|
||||
}
|
||||
|
@ -4252,30 +4276,32 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
for (NSNumber *timestamp in timestamps) {
|
||||
NSString *randomText = [self randomText];
|
||||
{
|
||||
// Legit usage of SenderTimestamp to backdate incoming sent messages for Debug
|
||||
TSIncomingMessage *message =
|
||||
[[TSIncomingMessage alloc] initIncomingMessageWithTimestamp:timestamp.unsignedLongLongValue
|
||||
inThread:thread
|
||||
authorId:recipientId
|
||||
sourceDeviceId:0
|
||||
messageBody:randomText
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
[[TSIncomingMessage alloc] initIncomingMessageWithSenderTimestamp:timestamp.unsignedLongLongValue
|
||||
inThread:thread
|
||||
authorId:recipientId
|
||||
sourceDeviceId:0
|
||||
messageBody:randomText
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
[message markAsReadNowWithSendReadReceipt:NO transaction:transaction];
|
||||
}
|
||||
{
|
||||
// MJK TODO - this might be the one place we actually use senderTimestamp
|
||||
TSOutgoingMessage *message =
|
||||
[[TSOutgoingMessage alloc] initOutgoingMessageWithTimestamp:timestamp.unsignedLongLongValue
|
||||
inThread:thread
|
||||
messageBody:randomText
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
[[TSOutgoingMessage alloc] initOutgoingMessageWithSenderTimestamp:timestamp.unsignedLongLongValue
|
||||
inThread:thread
|
||||
messageBody:randomText
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
[message saveWithTransaction:transaction];
|
||||
[message updateWithFakeMessageState:TSOutgoingMessageStateSent transaction:transaction];
|
||||
[message updateWithSentRecipient:recipientId transaction:transaction];
|
||||
|
@ -4291,17 +4317,19 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
+ (void)createDisappearingMessagesWhichFailedToStartInThread:(TSThread *)thread
|
||||
{
|
||||
uint64_t now = [NSDate ows_millisecondTimeStamp];
|
||||
|
||||
// MJK TODO - should be safe to remove this senderTimestamp
|
||||
TSIncomingMessage *message = [[TSIncomingMessage alloc]
|
||||
initIncomingMessageWithTimestamp:now
|
||||
inThread:thread
|
||||
authorId:thread.recipientIdentifiers.firstObject
|
||||
sourceDeviceId:0
|
||||
messageBody:[NSString
|
||||
stringWithFormat:@"Should disappear 60s after %lu", (unsigned long)now]
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:60
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
initIncomingMessageWithSenderTimestamp:now
|
||||
inThread:thread
|
||||
authorId:thread.recipientIdentifiers.firstObject
|
||||
sourceDeviceId:0
|
||||
messageBody:[NSString stringWithFormat:@"Should disappear 60s after %lu",
|
||||
(unsigned long)now]
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:60
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
// private setter to avoid starting expire machinery.
|
||||
message.read = YES;
|
||||
[message save];
|
||||
|
@ -4524,17 +4552,18 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
[attachmentIds addObject:attachmentId];
|
||||
}
|
||||
|
||||
// MJK TODO - remove senderTimestamp
|
||||
TSOutgoingMessage *message =
|
||||
[[TSOutgoingMessage alloc] initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:messageBody
|
||||
attachmentIds:attachmentIds
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:isVoiceMessage
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:contactShare];
|
||||
[[TSOutgoingMessage alloc] initOutgoingMessageWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:messageBody
|
||||
attachmentIds:attachmentIds
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:isVoiceMessage
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:contactShare];
|
||||
|
||||
if (attachmentId.length > 0 && filename.length > 0) {
|
||||
message.attachmentFilenameMap[attachmentId] = filename;
|
||||
|
@ -4613,16 +4642,17 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
// uint64_t millisAgo = (uint64_t)(((double)arc4random() / ((double)0xffffffff)) * yearsMillis);
|
||||
// uint64_t timestamp = [NSDate ows_millisecondTimeStamp] - millisAgo;
|
||||
|
||||
// MJK TODO - should be safe to remove this senderTimestamp
|
||||
TSIncomingMessage *message =
|
||||
[[TSIncomingMessage alloc] initIncomingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
authorId:@"+19174054215"
|
||||
sourceDeviceId:0
|
||||
messageBody:messageBody
|
||||
attachmentIds:attachmentIds
|
||||
expiresInSeconds:0
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:nil];
|
||||
[[TSIncomingMessage alloc] initIncomingMessageWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
authorId:@"+19174054215"
|
||||
sourceDeviceId:0
|
||||
messageBody:messageBody
|
||||
attachmentIds:attachmentIds
|
||||
expiresInSeconds:0
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:nil];
|
||||
[message markAsReadNowWithSendReadReceipt:NO transaction:transaction];
|
||||
return message;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,8 @@ class DebugUIProfile: DebugUIPage {
|
|||
OWSTableItem(title: "Send Profile Key Message") { [weak self] in
|
||||
guard let strongSelf = self else { return }
|
||||
|
||||
let message = OWSProfileKeyMessage(timestamp: NSDate.ows_millisecondTimeStamp(), in: aThread)
|
||||
// MJK TODO - should be safe to remove this senderTimestamp
|
||||
let message = OWSProfileKeyMessage(senderTimestamp: NSDate.ows_millisecondTimeStamp(), in: aThread)
|
||||
strongSelf.messageSender.sendPromise(message: message).then {
|
||||
Logger.info("Successfully sent profile key message to thread: \(String(describing: aThread))")
|
||||
}.catch { _ in
|
||||
|
|
|
@ -190,7 +190,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
for (int i = 0; i < 3; i++) {
|
||||
[DebugUIStress
|
||||
sendStressMessage:thread
|
||||
timestamp:timestamp
|
||||
senderTimestamp:timestamp
|
||||
block:^(SignalRecipient *recipient) {
|
||||
SSKProtoContentBuilder *contentBuilder =
|
||||
[SSKProtoContentBuilder new];
|
||||
|
@ -214,7 +214,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
uint64_t timestamp = [NSDate ows_millisecondTimeStamp];
|
||||
[DebugUIStress
|
||||
sendStressMessage:thread
|
||||
timestamp:timestamp
|
||||
senderTimestamp:timestamp
|
||||
block:^(SignalRecipient *recipient) {
|
||||
SSKProtoContentBuilder *contentBuilder =
|
||||
[SSKProtoContentBuilder new];
|
||||
|
@ -235,7 +235,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
timestamp += kHourInMs;
|
||||
[DebugUIStress
|
||||
sendStressMessage:thread
|
||||
timestamp:timestamp
|
||||
senderTimestamp:timestamp
|
||||
block:^(SignalRecipient *recipient) {
|
||||
SSKProtoContentBuilder *contentBuilder =
|
||||
[SSKProtoContentBuilder new];
|
||||
|
@ -256,7 +256,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
timestamp -= kHourInMs;
|
||||
[DebugUIStress
|
||||
sendStressMessage:thread
|
||||
timestamp:timestamp
|
||||
senderTimestamp:timestamp
|
||||
block:^(SignalRecipient *recipient) {
|
||||
SSKProtoContentBuilder *contentBuilder =
|
||||
[SSKProtoContentBuilder new];
|
||||
|
@ -284,7 +284,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
[DebugUIStress sendStressMessage:thread
|
||||
timestamp:timestamp
|
||||
senderTimestamp:timestamp
|
||||
block:^(SignalRecipient *recipient) {
|
||||
return data;
|
||||
}];
|
||||
|
@ -493,13 +493,15 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[self sendStressMessage:message];
|
||||
}
|
||||
|
||||
+ (void)sendStressMessage:(TSThread *)thread timestamp:(uint64_t)timestamp block:(DynamicOutgoingMessageBlock)block
|
||||
+ (void)sendStressMessage:(TSThread *)thread
|
||||
senderTimestamp:(uint64_t)timestamp
|
||||
block:(DynamicOutgoingMessageBlock)block
|
||||
{
|
||||
OWSAssertDebug(thread);
|
||||
OWSAssertDebug(block);
|
||||
|
||||
OWSDynamicOutgoingMessage *message =
|
||||
[[OWSDynamicOutgoingMessage alloc] initWithPlainTextDataBlock:block timestamp:timestamp thread:thread];
|
||||
[[OWSDynamicOutgoingMessage alloc] initWithPlainTextDataBlock:block senderTimestamp:timestamp thread:thread];
|
||||
|
||||
[self sendStressMessage:message];
|
||||
}
|
||||
|
|
|
@ -462,9 +462,11 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
|
|||
|
||||
// Add an error message to the new group indicating
|
||||
// that group creation didn't succeed.
|
||||
TSErrorMessage *errorMessage = [[TSErrorMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
failedMessageType:TSErrorMessageGroupCreationFailed];
|
||||
// MJK TODO should be safe to remove senderTimestamp and just save immediately
|
||||
TSErrorMessage *errorMessage =
|
||||
[[TSErrorMessage alloc] initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
failedMessageType:TSErrorMessageGroupCreationFailed];
|
||||
[errorMessage save];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
|
|
@ -904,14 +904,16 @@ const CGFloat kIconViewLength = 24;
|
|||
}
|
||||
|
||||
if (self.disappearingMessagesConfiguration.dictionaryValueDidChange) {
|
||||
// TODO - put these two saves in a single transaction
|
||||
[self.disappearingMessagesConfiguration save];
|
||||
// MJK TODO - should be safe to remove this senderTimestamp
|
||||
OWSDisappearingConfigurationUpdateInfoMessage *infoMessage =
|
||||
[[OWSDisappearingConfigurationUpdateInfoMessage alloc]
|
||||
initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:self.thread
|
||||
configuration:self.disappearingMessagesConfiguration
|
||||
createdByRemoteName:nil
|
||||
createdInExistingGroup:NO];
|
||||
initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:self.thread
|
||||
configuration:self.disappearingMessagesConfiguration
|
||||
createdByRemoteName:nil
|
||||
createdInExistingGroup:NO];
|
||||
[infoMessage save];
|
||||
|
||||
[OWSNotifyRemoteOfUpdatedDisappearingConfigurationJob
|
||||
|
|
|
@ -372,7 +372,8 @@ private class SignalCallData: NSObject {
|
|||
let callData = SignalCallData(call: call)
|
||||
self.callData = callData
|
||||
|
||||
let callRecord = TSCall(timestamp: NSDate.ows_millisecondTimeStamp(), withCallNumber: call.remotePhoneNumber, callType: RPRecentCallTypeOutgoingIncomplete, in: call.thread)
|
||||
// MJK TODO remove this timestamp param
|
||||
let callRecord = TSCall(senderTimestamp: NSDate.ows_millisecondTimeStamp(), withCallNumber: call.remotePhoneNumber, callType: RPRecentCallTypeOutgoingIncomplete, in: call.thread)
|
||||
callRecord.save()
|
||||
call.callRecord = callRecord
|
||||
|
||||
|
@ -527,7 +528,8 @@ private class SignalCallData: NSObject {
|
|||
callRecord.updateCallType(RPRecentCallTypeIncomingMissed)
|
||||
}
|
||||
} else {
|
||||
call.callRecord = TSCall(timestamp: NSDate.ows_millisecondTimeStamp(),
|
||||
// MJK TODO remove this timestamp param
|
||||
call.callRecord = TSCall(senderTimestamp: NSDate.ows_millisecondTimeStamp(),
|
||||
withCallNumber: call.thread.contactIdentifier(),
|
||||
callType: RPRecentCallTypeIncomingMissed,
|
||||
in: call.thread)
|
||||
|
@ -613,7 +615,8 @@ private class SignalCallData: NSObject {
|
|||
self.notificationsAdapter.presentMissedCallBecauseOfNoLongerVerifiedIdentity(call: newCall, callerName: callerName)
|
||||
}
|
||||
|
||||
let callRecord = TSCall(timestamp: NSDate.ows_millisecondTimeStamp(),
|
||||
// MJK TODO remove this timestamp param
|
||||
let callRecord = TSCall(senderTimestamp: NSDate.ows_millisecondTimeStamp(),
|
||||
withCallNumber: thread.contactIdentifier(),
|
||||
callType: RPRecentCallTypeIncomingMissedBecauseOfChangedIdentity,
|
||||
in: thread)
|
||||
|
@ -1035,7 +1038,8 @@ private class SignalCallData: NSObject {
|
|||
|
||||
Logger.info("\(call.identifiersForLogs).")
|
||||
|
||||
let callRecord = TSCall(timestamp: NSDate.ows_millisecondTimeStamp(), withCallNumber: call.remotePhoneNumber, callType: RPRecentCallTypeIncomingIncomplete, in: call.thread)
|
||||
// MJK TODO remove this timestamp param
|
||||
let callRecord = TSCall(senderTimestamp: NSDate.ows_millisecondTimeStamp(), withCallNumber: call.remotePhoneNumber, callType: RPRecentCallTypeIncomingIncomplete, in: call.thread)
|
||||
callRecord.save()
|
||||
call.callRecord = callRecord
|
||||
|
||||
|
@ -1124,7 +1128,8 @@ private class SignalCallData: NSObject {
|
|||
owsFailDebug("Not expecting callrecord to already be set")
|
||||
callRecord.updateCallType(RPRecentCallTypeIncomingDeclined)
|
||||
} else {
|
||||
let callRecord = TSCall(timestamp: NSDate.ows_millisecondTimeStamp(), withCallNumber: call.remotePhoneNumber, callType: RPRecentCallTypeIncomingDeclined, in: call.thread)
|
||||
// MJK TODO remove this timestamp param
|
||||
let callRecord = TSCall(senderTimestamp: NSDate.ows_millisecondTimeStamp(), withCallNumber: call.remotePhoneNumber, callType: RPRecentCallTypeIncomingDeclined, in: call.thread)
|
||||
callRecord.save()
|
||||
call.callRecord = callRecord
|
||||
}
|
||||
|
|
|
@ -18,16 +18,17 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
// it's redundant with the interaction's TSContactThread
|
||||
@property (nonatomic, readonly) NSString *recipientId;
|
||||
|
||||
- (instancetype)initInteractionWithTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread NS_UNAVAILABLE;
|
||||
- (instancetype)initInteractionWithSenderTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (instancetype)initContactOffersWithTimestamp:(uint64_t)timestamp
|
||||
thread:(TSThread *)thread
|
||||
hasBlockOffer:(BOOL)hasBlockOffer
|
||||
hasAddToContactsOffer:(BOOL)hasAddToContactsOffer
|
||||
hasAddToProfileWhitelistOffer:(BOOL)hasAddToProfileWhitelistOffer
|
||||
recipientId:(NSString *)recipientId NS_DESIGNATED_INITIALIZER;
|
||||
// MJK TODO Remove this timestamp param?
|
||||
- (instancetype)initContactOffersWithSenderTimestamp:(uint64_t)timestamp
|
||||
thread:(TSThread *)thread
|
||||
hasBlockOffer:(BOOL)hasBlockOffer
|
||||
hasAddToContactsOffer:(BOOL)hasAddToContactsOffer
|
||||
hasAddToProfileWhitelistOffer:(BOOL)hasAddToProfileWhitelistOffer
|
||||
recipientId:(NSString *)recipientId NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (void)updateHasBlockOffer:(BOOL)hasBlockOffer
|
||||
hasAddToContactsOffer:(BOOL)hasAddToContactsOffer
|
||||
|
|
|
@ -21,14 +21,14 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
return [super initWithCoder:coder];
|
||||
}
|
||||
|
||||
- (instancetype)initContactOffersWithTimestamp:(uint64_t)timestamp
|
||||
thread:(TSThread *)thread
|
||||
hasBlockOffer:(BOOL)hasBlockOffer
|
||||
hasAddToContactsOffer:(BOOL)hasAddToContactsOffer
|
||||
hasAddToProfileWhitelistOffer:(BOOL)hasAddToProfileWhitelistOffer
|
||||
recipientId:(NSString *)recipientId
|
||||
- (instancetype)initContactOffersWithSenderTimestamp:(uint64_t)timestamp
|
||||
thread:(TSThread *)thread
|
||||
hasBlockOffer:(BOOL)hasBlockOffer
|
||||
hasAddToContactsOffer:(BOOL)hasAddToContactsOffer
|
||||
hasAddToProfileWhitelistOffer:(BOOL)hasAddToProfileWhitelistOffer
|
||||
recipientId:(NSString *)recipientId
|
||||
{
|
||||
self = [super initInteractionWithTimestamp:timestamp inThread:thread];
|
||||
self = [super initInteractionWithSenderTimestamp:timestamp inThread:thread];
|
||||
|
||||
if (!self) {
|
||||
return self;
|
||||
|
|
|
@ -22,16 +22,16 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@property (nonatomic, readonly) TSQuotedMessageContentSource bodySource;
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
authorId:(NSString *)authorId
|
||||
body:(nullable NSString *)body
|
||||
bodySource:(TSQuotedMessageContentSource)bodySource
|
||||
thumbnailImage:(nullable UIImage *)thumbnailImage
|
||||
contentType:(nullable NSString *)contentType
|
||||
sourceFilename:(nullable NSString *)sourceFilename
|
||||
attachmentStream:(nullable TSAttachmentStream *)attachmentStream
|
||||
thumbnailAttachmentPointer:(nullable TSAttachmentPointer *)thumbnailAttachmentPointer
|
||||
thumbnailDownloadFailed:(BOOL)thumbnailDownloadFailed NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
authorId:(NSString *)authorId
|
||||
body:(nullable NSString *)body
|
||||
bodySource:(TSQuotedMessageContentSource)bodySource
|
||||
thumbnailImage:(nullable UIImage *)thumbnailImage
|
||||
contentType:(nullable NSString *)contentType
|
||||
sourceFilename:(nullable NSString *)sourceFilename
|
||||
attachmentStream:(nullable TSAttachmentStream *)attachmentStream
|
||||
thumbnailAttachmentPointer:(nullable TSAttachmentPointer *)thumbnailAttachmentPointer
|
||||
thumbnailDownloadFailed:(BOOL)thumbnailDownloadFailed NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -40,16 +40,16 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
#pragma mark - Initializers
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
authorId:(NSString *)authorId
|
||||
body:(nullable NSString *)body
|
||||
bodySource:(TSQuotedMessageContentSource)bodySource
|
||||
thumbnailImage:(nullable UIImage *)thumbnailImage
|
||||
contentType:(nullable NSString *)contentType
|
||||
sourceFilename:(nullable NSString *)sourceFilename
|
||||
attachmentStream:(nullable TSAttachmentStream *)attachmentStream
|
||||
thumbnailAttachmentPointer:(nullable TSAttachmentPointer *)thumbnailAttachmentPointer
|
||||
thumbnailDownloadFailed:(BOOL)thumbnailDownloadFailed
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
authorId:(NSString *)authorId
|
||||
body:(nullable NSString *)body
|
||||
bodySource:(TSQuotedMessageContentSource)bodySource
|
||||
thumbnailImage:(nullable UIImage *)thumbnailImage
|
||||
contentType:(nullable NSString *)contentType
|
||||
sourceFilename:(nullable NSString *)sourceFilename
|
||||
attachmentStream:(nullable TSAttachmentStream *)attachmentStream
|
||||
thumbnailAttachmentPointer:(nullable TSAttachmentPointer *)thumbnailAttachmentPointer
|
||||
thumbnailDownloadFailed:(BOOL)thumbnailDownloadFailed
|
||||
{
|
||||
self = [super init];
|
||||
if (!self) {
|
||||
|
@ -103,16 +103,16 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
}
|
||||
}
|
||||
|
||||
return [[self alloc] initWithTimestamp:quotedMessage.timestamp
|
||||
authorId:quotedMessage.authorId
|
||||
body:quotedMessage.body
|
||||
bodySource:quotedMessage.bodySource
|
||||
thumbnailImage:thumbnailImage
|
||||
contentType:attachmentInfo.contentType
|
||||
sourceFilename:attachmentInfo.sourceFilename
|
||||
attachmentStream:nil
|
||||
thumbnailAttachmentPointer:attachmentPointer
|
||||
thumbnailDownloadFailed:thumbnailDownloadFailed];
|
||||
return [[self alloc] initWithSenderTimestamp:quotedMessage.timestamp
|
||||
authorId:quotedMessage.authorId
|
||||
body:quotedMessage.body
|
||||
bodySource:quotedMessage.bodySource
|
||||
thumbnailImage:thumbnailImage
|
||||
contentType:attachmentInfo.contentType
|
||||
sourceFilename:attachmentInfo.sourceFilename
|
||||
attachmentStream:nil
|
||||
thumbnailAttachmentPointer:attachmentPointer
|
||||
thumbnailDownloadFailed:thumbnailDownloadFailed];
|
||||
}
|
||||
|
||||
+ (nullable instancetype)quotedReplyForSendingWithConversationViewItem:(ConversationViewItem *)conversationItem
|
||||
|
@ -151,16 +151,16 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
// because the QuotedReplyViewModel has some hardcoded assumptions that only quoted attachments have
|
||||
// thumbnails. Until we address that we want to be consistent about neither showing nor sending the
|
||||
// contactShare avatar in the quoted reply.
|
||||
return [[self alloc] initWithTimestamp:timestamp
|
||||
authorId:authorId
|
||||
body:[@"👤 " stringByAppendingString:contactShare.displayName]
|
||||
bodySource:TSQuotedMessageContentSourceLocal
|
||||
thumbnailImage:nil
|
||||
contentType:nil
|
||||
sourceFilename:nil
|
||||
attachmentStream:nil
|
||||
thumbnailAttachmentPointer:nil
|
||||
thumbnailDownloadFailed:NO];
|
||||
return [[self alloc] initWithSenderTimestamp:timestamp
|
||||
authorId:authorId
|
||||
body:[@"👤 " stringByAppendingString:contactShare.displayName]
|
||||
bodySource:TSQuotedMessageContentSourceLocal
|
||||
thumbnailImage:nil
|
||||
contentType:nil
|
||||
sourceFilename:nil
|
||||
attachmentStream:nil
|
||||
thumbnailAttachmentPointer:nil
|
||||
thumbnailDownloadFailed:NO];
|
||||
}
|
||||
|
||||
NSString *_Nullable quotedText = message.body;
|
||||
|
@ -223,16 +223,16 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
hasText = YES;
|
||||
}
|
||||
|
||||
return [[self alloc] initWithTimestamp:timestamp
|
||||
authorId:authorId
|
||||
body:quotedText
|
||||
bodySource:TSQuotedMessageContentSourceLocal
|
||||
thumbnailImage:quotedAttachment.thumbnailImageSmallSync
|
||||
contentType:quotedAttachment.contentType
|
||||
sourceFilename:quotedAttachment.sourceFilename
|
||||
attachmentStream:quotedAttachment
|
||||
thumbnailAttachmentPointer:nil
|
||||
thumbnailDownloadFailed:NO];
|
||||
return [[self alloc] initWithSenderTimestamp:timestamp
|
||||
authorId:authorId
|
||||
body:quotedText
|
||||
bodySource:TSQuotedMessageContentSourceLocal
|
||||
thumbnailImage:quotedAttachment.thumbnailImageSmallSync
|
||||
contentType:quotedAttachment.contentType
|
||||
sourceFilename:quotedAttachment.sourceFilename
|
||||
attachmentStream:quotedAttachment
|
||||
thumbnailAttachmentPointer:nil
|
||||
thumbnailDownloadFailed:NO];
|
||||
}
|
||||
|
||||
#pragma mark - Instance Methods
|
||||
|
@ -241,10 +241,11 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
{
|
||||
NSArray *attachments = self.attachmentStream ? @[ self.attachmentStream ] : @[];
|
||||
|
||||
return [[TSQuotedMessage alloc] initWithTimestamp:self.timestamp
|
||||
authorId:self.authorId
|
||||
body:self.body
|
||||
quotedAttachmentsForSending:attachments];
|
||||
// Legit usage of senderTimestamp to reference existing message
|
||||
return [[TSQuotedMessage alloc] initWithSenderTimestamp:self.timestamp
|
||||
authorId:self.authorId
|
||||
body:self.body
|
||||
quotedAttachmentsForSending:attachments];
|
||||
}
|
||||
|
||||
- (BOOL)isRemotelySourced
|
||||
|
|
|
@ -1124,8 +1124,9 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
|
|||
{
|
||||
OWSAssertIsOnMainThread();
|
||||
|
||||
// MJK TODO - should be safe to remove this senderTimestamp
|
||||
OWSProfileKeyMessage *message =
|
||||
[[OWSProfileKeyMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp] inThread:thread];
|
||||
[[OWSProfileKeyMessage alloc] initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp] inThread:thread];
|
||||
|
||||
BOOL isFeatureEnabled = NO;
|
||||
if (!isFeatureEnabled) {
|
||||
|
|
|
@ -121,10 +121,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
#pragma mark - Find Content
|
||||
|
||||
+ (nullable TSInteraction *)findInteractionInThreadByTimestamp:(uint64_t)timestamp
|
||||
authorId:(NSString *)authorId
|
||||
threadUniqueId:(NSString *)threadUniqueId
|
||||
transaction:(YapDatabaseReadTransaction *)transaction;
|
||||
+ (nullable TSInteraction *)findInteractionInThreadBySenderTimestamp:(uint64_t)timestamp
|
||||
authorId:(NSString *)authorId
|
||||
threadUniqueId:(NSString *)threadUniqueId
|
||||
transaction:(YapDatabaseReadTransaction *)transaction;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -128,17 +128,18 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:thread.uniqueId];
|
||||
|
||||
uint32_t expiresInSeconds = (configuration.isEnabled ? configuration.durationSeconds : 0);
|
||||
TSOutgoingMessage *message =
|
||||
[[TSOutgoingMessage alloc] initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:attachment.captionText
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:expiresInSeconds
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:[attachment isVoiceMessage]
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:[quotedReplyModel buildQuotedMessageForSending]
|
||||
contactShare:nil];
|
||||
// MJK TODO - remove senderTimestamp
|
||||
TSOutgoingMessage *message = [[TSOutgoingMessage alloc]
|
||||
initOutgoingMessageWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:attachment.captionText
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:expiresInSeconds
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:[attachment isVoiceMessage]
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:[quotedReplyModel buildQuotedMessageForSending]
|
||||
contactShare:nil];
|
||||
|
||||
[messageSender enqueueAttachment:attachment.dataSource
|
||||
contentType:attachment.mimeType
|
||||
|
@ -179,17 +180,18 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:thread.uniqueId];
|
||||
|
||||
uint32_t expiresInSeconds = (configuration.isEnabled ? configuration.durationSeconds : 0);
|
||||
// MJK TODO - remove senderTimestamp
|
||||
TSOutgoingMessage *message =
|
||||
[[TSOutgoingMessage alloc] initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:expiresInSeconds
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:contactShare];
|
||||
[[TSOutgoingMessage alloc] initOutgoingMessageWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:expiresInSeconds
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:contactShare];
|
||||
|
||||
[messageSender enqueueMessage:message
|
||||
success:^{
|
||||
|
@ -494,12 +496,12 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
// TODO MJK - remove this timestamp
|
||||
TSInteraction *offersMessage = [[OWSContactOffersInteraction alloc]
|
||||
initContactOffersWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
hasBlockOffer:shouldHaveBlockOffer
|
||||
hasAddToContactsOffer:shouldHaveAddToContactsOffer
|
||||
hasAddToProfileWhitelistOffer:shouldHaveAddToProfileWhitelistOffer
|
||||
recipientId:recipientId];
|
||||
initContactOffersWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
hasBlockOffer:shouldHaveBlockOffer
|
||||
hasAddToContactsOffer:shouldHaveAddToContactsOffer
|
||||
hasAddToProfileWhitelistOffer:shouldHaveAddToProfileWhitelistOffer
|
||||
recipientId:recipientId];
|
||||
[offersMessage saveWithTransaction:transaction];
|
||||
|
||||
OWSLogInfo(
|
||||
|
@ -791,10 +793,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
#pragma mark - Find Content
|
||||
|
||||
+ (nullable TSInteraction *)findInteractionInThreadByTimestamp:(uint64_t)timestamp
|
||||
authorId:(NSString *)authorId
|
||||
threadUniqueId:(NSString *)threadUniqueId
|
||||
transaction:(YapDatabaseReadTransaction *)transaction
|
||||
+ (nullable TSInteraction *)findInteractionInThreadBySenderTimestamp:(uint64_t)timestamp
|
||||
authorId:(NSString *)authorId
|
||||
threadUniqueId:(NSString *)threadUniqueId
|
||||
transaction:(YapDatabaseReadTransaction *)transaction
|
||||
{
|
||||
OWSAssertDebug(timestamp > 0);
|
||||
OWSAssertDebug(authorId.length > 0);
|
||||
|
@ -805,29 +807,29 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
return nil;
|
||||
}
|
||||
|
||||
NSArray<TSInteraction *> *interactions =
|
||||
[TSInteraction interactionsWithTimestamp:timestamp
|
||||
filter:^(TSInteraction *interaction) {
|
||||
NSString *_Nullable messageAuthorId = nil;
|
||||
if ([interaction isKindOfClass:[TSIncomingMessage class]]) {
|
||||
TSIncomingMessage *incomingMessage = (TSIncomingMessage *)interaction;
|
||||
messageAuthorId = incomingMessage.authorId;
|
||||
} else if ([interaction isKindOfClass:[TSOutgoingMessage class]]) {
|
||||
messageAuthorId = localNumber;
|
||||
}
|
||||
if (messageAuthorId.length < 1) {
|
||||
return NO;
|
||||
}
|
||||
NSArray<TSInteraction *> *interactions = [TSInteraction
|
||||
interactionsWithSenderTimestamp:timestamp
|
||||
filter:^(TSInteraction *interaction) {
|
||||
NSString *_Nullable messageAuthorId = nil;
|
||||
if ([interaction isKindOfClass:[TSIncomingMessage class]]) {
|
||||
TSIncomingMessage *incomingMessage = (TSIncomingMessage *)interaction;
|
||||
messageAuthorId = incomingMessage.authorId;
|
||||
} else if ([interaction isKindOfClass:[TSOutgoingMessage class]]) {
|
||||
messageAuthorId = localNumber;
|
||||
}
|
||||
if (messageAuthorId.length < 1) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![authorId isEqualToString:messageAuthorId]) {
|
||||
return NO;
|
||||
}
|
||||
if (![interaction.uniqueThreadId isEqualToString:threadUniqueId]) {
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
withTransaction:transaction];
|
||||
if (![authorId isEqualToString:messageAuthorId]) {
|
||||
return NO;
|
||||
}
|
||||
if (![interaction.uniqueThreadId isEqualToString:threadUniqueId]) {
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
withTransaction:transaction];
|
||||
if (interactions.count < 1) {
|
||||
return nil;
|
||||
}
|
||||
|
|
|
@ -10,16 +10,16 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@interface OWSReadReceiptsForSenderMessage : TSOutgoingMessage
|
||||
|
||||
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
- (instancetype)initOutgoingMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithThread:(nullable TSThread *)thread messageTimestamps:(NSArray<NSNumber *> *)messageTimestamps;
|
||||
|
||||
|
|
|
@ -21,16 +21,17 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
- (instancetype)initWithThread:(nullable TSThread *)thread messageTimestamps:(NSArray<NSNumber *> *)messageTimestamps
|
||||
{
|
||||
self = [super initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
// MJK TODO - remove senderTimestamp
|
||||
self = [super initOutgoingMessageWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -70,9 +70,11 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
if (transcript.isEndSessionMessage) {
|
||||
OWSLogInfo(@"EndSession was sent to recipient: %@.", transcript.recipientId);
|
||||
[self.primaryStorage deleteAllSessionsForContact:transcript.recipientId protocolContext:transaction];
|
||||
[[[TSInfoMessage alloc] initWithTimestamp:transcript.timestamp
|
||||
inThread:transcript.thread
|
||||
messageType:TSInfoMessageTypeSessionDidEnd] saveWithTransaction:transaction];
|
||||
// MJK TODO - verify we can delete this senderTimestamp
|
||||
[[[TSInfoMessage alloc] initWithSenderTimestamp:transcript.timestamp
|
||||
inThread:transcript.thread
|
||||
messageType:TSInfoMessageTypeSessionDidEnd]
|
||||
saveWithTransaction:transaction];
|
||||
|
||||
// Don't continue processing lest we print a bubble for the session reset.
|
||||
return;
|
||||
|
@ -85,17 +87,17 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
|
||||
// TODO group updates. Currently desktop doesn't support group updates, so not a problem yet.
|
||||
TSOutgoingMessage *outgoingMessage =
|
||||
[[TSOutgoingMessage alloc] initOutgoingMessageWithTimestamp:transcript.timestamp
|
||||
inThread:transcript.thread
|
||||
messageBody:transcript.body
|
||||
attachmentIds:[attachmentsProcessor.attachmentIds mutableCopy]
|
||||
expiresInSeconds:transcript.expirationDuration
|
||||
expireStartedAt:transcript.expirationStartedAt
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:transcript.quotedMessage
|
||||
contactShare:transcript.contact];
|
||||
TSOutgoingMessage *outgoingMessage = [[TSOutgoingMessage alloc]
|
||||
initOutgoingMessageWithSenderTimestamp:transcript.timestamp
|
||||
inThread:transcript.thread
|
||||
messageBody:transcript.body
|
||||
attachmentIds:[attachmentsProcessor.attachmentIds mutableCopy]
|
||||
expiresInSeconds:transcript.expirationDuration
|
||||
expireStartedAt:transcript.expirationStartedAt
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:transcript.quotedMessage
|
||||
contactShare:transcript.contact];
|
||||
|
||||
TSQuotedMessage *_Nullable quotedMessage = transcript.quotedMessage;
|
||||
if (quotedMessage && quotedMessage.thumbnailAttachmentPointerId) {
|
||||
|
|
|
@ -13,16 +13,16 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
*/
|
||||
@interface OWSOutgoingSyncMessage : TSOutgoingMessage
|
||||
|
||||
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
- (instancetype)initOutgoingMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)init NS_DESIGNATED_INITIALIZER;
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
|
|
|
@ -19,16 +19,17 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:nil
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
// MJK TODO - remove SenderTimestamp
|
||||
self = [super initOutgoingMessageWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:nil
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
|
||||
if (!self) {
|
||||
return self;
|
||||
|
|
|
@ -8,16 +8,16 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@interface OWSSyncGroupsRequestMessage : TSOutgoingMessage
|
||||
|
||||
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
- (instancetype)initOutgoingMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithThread:(nullable TSThread *)thread groupId:(NSData *)groupId;
|
||||
|
||||
|
|
|
@ -20,16 +20,17 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
- (instancetype)initWithThread:(nullable TSThread *)thread groupId:(NSData *)groupId
|
||||
{
|
||||
self = [super initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
// MJK TODO - remove senderTimestamp
|
||||
self = [super initOutgoingMessageWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -16,11 +16,12 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
/**
|
||||
* @param remoteName is nil when created by the local user
|
||||
*/
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
thread:(TSThread *)thread
|
||||
configuration:(OWSDisappearingMessagesConfiguration *)configuration
|
||||
createdByRemoteName:(nullable NSString *)remoteName
|
||||
createdInExistingGroup:(BOOL)createdInExistingGroup;
|
||||
// MJK TODO - can we remove sendertimestamp here
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
thread:(TSThread *)thread
|
||||
configuration:(OWSDisappearingMessagesConfiguration *)configuration
|
||||
createdByRemoteName:(nullable NSString *)remoteName
|
||||
createdInExistingGroup:(BOOL)createdInExistingGroup;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -18,13 +18,15 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@implementation OWSDisappearingConfigurationUpdateInfoMessage
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
thread:(TSThread *)thread
|
||||
configuration:(OWSDisappearingMessagesConfiguration *)configuration
|
||||
createdByRemoteName:(nullable NSString *)remoteName
|
||||
createdInExistingGroup:(BOOL)createdInExistingGroup
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
thread:(TSThread *)thread
|
||||
configuration:(OWSDisappearingMessagesConfiguration *)configuration
|
||||
createdByRemoteName:(nullable NSString *)remoteName
|
||||
createdInExistingGroup:(BOOL)createdInExistingGroup
|
||||
{
|
||||
self = [super initWithTimestamp:timestamp inThread:thread messageType:TSInfoMessageTypeDisappearingMessagesUpdate];
|
||||
self = [super initWithSenderTimestamp:timestamp
|
||||
inThread:thread
|
||||
messageType:TSInfoMessageTypeDisappearingMessagesUpdate];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -10,16 +10,17 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@interface OWSDisappearingMessagesConfigurationMessage : TSOutgoingMessage
|
||||
|
||||
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
// MJK TODO - remove senderTimestamp
|
||||
- (instancetype)initOutgoingMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithConfiguration:(OWSDisappearingMessagesConfiguration *)configuration thread:(TSThread *)thread;
|
||||
|
||||
|
|
|
@ -26,16 +26,17 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
- (instancetype)initWithConfiguration:(OWSDisappearingMessagesConfiguration *)configuration thread:(TSThread *)thread
|
||||
{
|
||||
self = [super initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
// MJK TODO - remove sender timestamp
|
||||
self = [super initOutgoingMessageWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -11,22 +11,23 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
typedef NSData *_Nonnull (^DynamicOutgoingMessageBlock)(SignalRecipient *);
|
||||
|
||||
/// This class is only used in debug tools
|
||||
@interface OWSDynamicOutgoingMessage : TSOutgoingMessage
|
||||
|
||||
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
- (instancetype)initOutgoingMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithPlainTextDataBlock:(DynamicOutgoingMessageBlock)block thread:(nullable TSThread *)thread;
|
||||
- (instancetype)initWithPlainTextDataBlock:(DynamicOutgoingMessageBlock)block
|
||||
timestamp:(uint64_t)timestamp
|
||||
senderTimestamp:(uint64_t)timestamp
|
||||
thread:(nullable TSThread *)thread;
|
||||
|
||||
@end
|
||||
|
|
|
@ -20,23 +20,24 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
- (instancetype)initWithPlainTextDataBlock:(DynamicOutgoingMessageBlock)block thread:(nullable TSThread *)thread
|
||||
{
|
||||
return [self initWithPlainTextDataBlock:block timestamp:[NSDate ows_millisecondTimeStamp] thread:thread];
|
||||
return [self initWithPlainTextDataBlock:block senderTimestamp:[NSDate ows_millisecondTimeStamp] thread:thread];
|
||||
}
|
||||
|
||||
// MJK TODO can we remove sender timestamp?
|
||||
- (instancetype)initWithPlainTextDataBlock:(DynamicOutgoingMessageBlock)block
|
||||
timestamp:(uint64_t)timestamp
|
||||
senderTimestamp:(uint64_t)timestamp
|
||||
thread:(nullable TSThread *)thread
|
||||
{
|
||||
self = [super initOutgoingMessageWithTimestamp:timestamp
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
self = [super initOutgoingMessageWithSenderTimestamp:timestamp
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
|
||||
if (self) {
|
||||
_block = block;
|
||||
|
|
|
@ -9,18 +9,20 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
NS_SWIFT_NAME(EndSessionMessage)
|
||||
@interface OWSEndSessionMessage : TSOutgoingMessage
|
||||
|
||||
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
- (instancetype)initOutgoingMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp inThread:(nullable TSThread *)thread NS_DESIGNATED_INITIALIZER;
|
||||
// MJK TODO can we remove the sender timestamp?
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
|
|
@ -14,18 +14,18 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
return [super initWithCoder:coder];
|
||||
}
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp inThread:(nullable TSThread *)thread
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp inThread:(nullable TSThread *)thread
|
||||
{
|
||||
return [super initOutgoingMessageWithTimestamp:timestamp
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
return [super initOutgoingMessageWithSenderTimestamp:timestamp
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
}
|
||||
|
||||
- (BOOL)shouldBeSaved
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSRecipientIdentity.h"
|
||||
|
@ -15,11 +15,11 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@property (nonatomic, readonly) OWSVerificationState verificationState;
|
||||
@property (nonatomic, readonly) BOOL isLocalChange;
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
thread:(TSThread *)thread
|
||||
recipientId:(NSString *)recipientId
|
||||
verificationState:(OWSVerificationState)verificationState
|
||||
isLocalChange:(BOOL)isLocalChange;
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
thread:(TSThread *)thread
|
||||
recipientId:(NSString *)recipientId
|
||||
verificationState:(OWSVerificationState)verificationState
|
||||
isLocalChange:(BOOL)isLocalChange;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSVerificationStateChangeMessage.h"
|
||||
|
@ -9,15 +9,15 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@implementation OWSVerificationStateChangeMessage
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
thread:(TSThread *)thread
|
||||
recipientId:(NSString *)recipientId
|
||||
verificationState:(OWSVerificationState)verificationState
|
||||
isLocalChange:(BOOL)isLocalChange
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
thread:(TSThread *)thread
|
||||
recipientId:(NSString *)recipientId
|
||||
verificationState:(OWSVerificationState)verificationState
|
||||
isLocalChange:(BOOL)isLocalChange
|
||||
{
|
||||
OWSAssertDebug(recipientId.length > 0);
|
||||
|
||||
self = [super initWithTimestamp:timestamp inThread:thread messageType:TSInfoMessageVerificationStateChange];
|
||||
self = [super initWithSenderTimestamp:timestamp inThread:thread messageType:TSInfoMessageVerificationStateChange];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -28,32 +28,32 @@ typedef NS_ENUM(int32_t, TSErrorMessageType) {
|
|||
|
||||
@interface TSErrorMessage : TSMessage <OWSReadTracking>
|
||||
|
||||
- (instancetype)initMessageWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contact NS_UNAVAILABLE;
|
||||
- (instancetype)initMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contact NS_UNAVAILABLE;
|
||||
|
||||
- (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 NS_UNAVAILABLE;
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt NS_UNAVAILABLE;
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
failedMessageType:(TSErrorMessageType)errorMessageType
|
||||
recipientId:(nullable NSString *)recipientId NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
failedMessageType:(TSErrorMessageType)errorMessageType
|
||||
recipientId:(nullable NSString *)recipientId NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
failedMessageType:(TSErrorMessageType)errorMessageType;
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
failedMessageType:(TSErrorMessageType)errorMessageType;
|
||||
|
||||
+ (instancetype)corruptedMessageWithEnvelope:(SSKProtoEnvelope *)envelope
|
||||
withTransaction:(YapDatabaseReadWriteTransaction *)transaction;
|
||||
|
|
|
@ -48,19 +48,19 @@ NSUInteger TSErrorMessageSchemaVersion = 1;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
failedMessageType:(TSErrorMessageType)errorMessageType
|
||||
recipientId:(nullable NSString *)recipientId
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
failedMessageType:(TSErrorMessageType)errorMessageType
|
||||
recipientId:(nullable NSString *)recipientId
|
||||
{
|
||||
self = [super initMessageWithTimestamp:timestamp
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:@[]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
self = [super initMessageWithSenderTimestamp:timestamp
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:@[]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
|
||||
if (!self) {
|
||||
return self;
|
||||
|
@ -77,11 +77,11 @@ NSUInteger TSErrorMessageSchemaVersion = 1;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
failedMessageType:(TSErrorMessageType)errorMessageType
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
failedMessageType:(TSErrorMessageType)errorMessageType
|
||||
{
|
||||
return [self initWithTimestamp:timestamp inThread:thread failedMessageType:errorMessageType recipientId:nil];
|
||||
return [self initWithSenderTimestamp:timestamp inThread:thread failedMessageType:errorMessageType recipientId:nil];
|
||||
}
|
||||
|
||||
- (instancetype)initWithEnvelope:(SSKProtoEnvelope *)envelope
|
||||
|
@ -91,12 +91,16 @@ NSUInteger TSErrorMessageSchemaVersion = 1;
|
|||
TSContactThread *contactThread =
|
||||
[TSContactThread getOrCreateThreadWithContactId:envelope.source transaction:transaction];
|
||||
|
||||
return [self initWithTimestamp:envelope.timestamp inThread:contactThread failedMessageType:errorMessageType];
|
||||
// MJK FIXME - cannot rely on envelope timestamp for sorting, ensure this is saved immediately.
|
||||
return [self initWithSenderTimestamp:envelope.timestamp inThread:contactThread failedMessageType:errorMessageType];
|
||||
}
|
||||
|
||||
- (instancetype)initWithFailedMessageType:(TSErrorMessageType)errorMessageType
|
||||
{
|
||||
return [self initWithTimestamp:[NSDate ows_millisecondTimeStamp] inThread:nil failedMessageType:errorMessageType];
|
||||
// MJK FIXME - cannot rely on envelope timestamp for sorting, ensure this is saved immediately.
|
||||
return [self initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:nil
|
||||
failedMessageType:errorMessageType];
|
||||
}
|
||||
|
||||
- (OWSInteractionType)interactionType
|
||||
|
@ -184,10 +188,11 @@ NSUInteger TSErrorMessageSchemaVersion = 1;
|
|||
|
||||
+ (instancetype)nonblockingIdentityChangeInThread:(TSThread *)thread recipientId:(NSString *)recipientId
|
||||
{
|
||||
return [[self alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
failedMessageType:TSErrorMessageNonBlockingIdentityChange
|
||||
recipientId:recipientId];
|
||||
// MJK TODO - should be safe to remove this senderTimestamp
|
||||
return [[self alloc] initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
failedMessageType:TSErrorMessageNonBlockingIdentityChange
|
||||
recipientId:recipientId];
|
||||
}
|
||||
|
||||
#pragma mark - OWSReadTracking
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
@interface TSErrorMessage ()
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(TSThread *)thread
|
||||
failedMessageType:(TSErrorMessageType)errorMessageType NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(TSThread *)thread
|
||||
failedMessageType:(TSErrorMessageType)errorMessageType NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@property (atomic, nullable) NSData *envelopeData;
|
||||
|
||||
|
|
|
@ -12,14 +12,14 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@interface TSIncomingMessage : TSMessage <OWSReadTracking>
|
||||
|
||||
- (instancetype)initMessageWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
- (instancetype)initMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
* Inits an incoming group message that expires.
|
||||
|
@ -43,15 +43,15 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
*
|
||||
* @return initiated incoming group message
|
||||
*/
|
||||
- (instancetype)initIncomingMessageWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(TSThread *)thread
|
||||
authorId:(NSString *)authorId
|
||||
sourceDeviceId:(uint32_t)sourceDeviceId
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initIncomingMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(TSThread *)thread
|
||||
authorId:(NSString *)authorId
|
||||
sourceDeviceId:(uint32_t)sourceDeviceId
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
|
@ -65,7 +65,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
*
|
||||
*/
|
||||
+ (nullable instancetype)findMessageWithAuthorId:(NSString *)authorId
|
||||
timestamp:(uint64_t)timestamp
|
||||
senderTimestamp:(uint64_t)timestamp
|
||||
transaction:(YapDatabaseReadWriteTransaction *)transaction;
|
||||
|
||||
// This will be 0 for messages created before we were tracking sourceDeviceId
|
||||
|
|
|
@ -36,24 +36,24 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initIncomingMessageWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(TSThread *)thread
|
||||
authorId:(NSString *)authorId
|
||||
sourceDeviceId:(uint32_t)sourceDeviceId
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
- (instancetype)initIncomingMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(TSThread *)thread
|
||||
authorId:(NSString *)authorId
|
||||
sourceDeviceId:(uint32_t)sourceDeviceId
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
{
|
||||
self = [super initMessageWithTimestamp:timestamp
|
||||
inThread:thread
|
||||
messageBody:body
|
||||
attachmentIds:attachmentIds
|
||||
expiresInSeconds:expiresInSeconds
|
||||
expireStartedAt:0
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:contactShare];
|
||||
self = [super initMessageWithSenderTimestamp:timestamp
|
||||
inThread:thread
|
||||
messageBody:body
|
||||
attachmentIds:attachmentIds
|
||||
expiresInSeconds:expiresInSeconds
|
||||
expireStartedAt:0
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:contactShare];
|
||||
|
||||
if (!self) {
|
||||
return self;
|
||||
|
@ -67,7 +67,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
}
|
||||
|
||||
+ (nullable instancetype)findMessageWithAuthorId:(NSString *)authorId
|
||||
timestamp:(uint64_t)timestamp
|
||||
senderTimestamp:(uint64_t)timestamp
|
||||
transaction:(YapDatabaseReadWriteTransaction *)transaction
|
||||
{
|
||||
OWSAssertDebug(transaction);
|
||||
|
@ -76,22 +76,22 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
// In theory we could build a new secondaryIndex for (authorId,timestamp), but in practice there should
|
||||
// be *very* few (millisecond) timestamps with multiple authors.
|
||||
[TSDatabaseSecondaryIndexes
|
||||
enumerateMessagesWithTimestamp:timestamp
|
||||
withBlock:^(NSString *collection, NSString *key, BOOL *stop) {
|
||||
TSInteraction *interaction =
|
||||
[TSInteraction fetchObjectWithUniqueID:key transaction:transaction];
|
||||
if ([interaction isKindOfClass:[TSIncomingMessage class]]) {
|
||||
TSIncomingMessage *message = (TSIncomingMessage *)interaction;
|
||||
enumerateMessagesWithSenderTimestamp:timestamp
|
||||
withBlock:^(NSString *collection, NSString *key, BOOL *stop) {
|
||||
TSInteraction *interaction =
|
||||
[TSInteraction fetchObjectWithUniqueID:key transaction:transaction];
|
||||
if ([interaction isKindOfClass:[TSIncomingMessage class]]) {
|
||||
TSIncomingMessage *message = (TSIncomingMessage *)interaction;
|
||||
|
||||
NSString *messageAuthorId = message.messageAuthorId;
|
||||
OWSAssertDebug(messageAuthorId.length > 0);
|
||||
NSString *messageAuthorId = message.messageAuthorId;
|
||||
OWSAssertDebug(messageAuthorId.length > 0);
|
||||
|
||||
if ([messageAuthorId isEqualToString:authorId]) {
|
||||
foundMessage = message;
|
||||
}
|
||||
}
|
||||
}
|
||||
usingTransaction:transaction];
|
||||
if ([messageAuthorId isEqualToString:authorId]) {
|
||||
foundMessage = message;
|
||||
}
|
||||
}
|
||||
}
|
||||
usingTransaction:transaction];
|
||||
|
||||
return foundMessage;
|
||||
}
|
||||
|
|
|
@ -29,37 +29,37 @@ typedef NS_ENUM(NSInteger, TSInfoMessageType) {
|
|||
@property (atomic, readonly, nullable) NSString *customMessage;
|
||||
@property (atomic, readonly, nullable) NSString *unregisteredRecipientId;
|
||||
|
||||
- (instancetype)initMessageWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contact NS_UNAVAILABLE;
|
||||
- (instancetype)initMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contact NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(TSThread *)contact
|
||||
messageType:(TSInfoMessageType)infoMessage NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(TSThread *)contact
|
||||
messageType:(TSInfoMessageType)infoMessage NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(TSThread *)thread
|
||||
messageType:(TSInfoMessageType)infoMessage
|
||||
customMessage:(NSString *)customMessage;
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(TSThread *)thread
|
||||
messageType:(TSInfoMessageType)infoMessage
|
||||
customMessage:(NSString *)customMessage;
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(TSThread *)thread
|
||||
messageType:(TSInfoMessageType)infoMessage
|
||||
unregisteredRecipientId:(NSString *)unregisteredRecipientId;
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(TSThread *)thread
|
||||
messageType:(TSInfoMessageType)infoMessage
|
||||
unregisteredRecipientId:(NSString *)unregisteredRecipientId;
|
||||
|
||||
- (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 NS_UNAVAILABLE;
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -44,18 +44,19 @@ NSUInteger TSInfoMessageSchemaVersion = 1;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(TSThread *)thread
|
||||
messageType:(TSInfoMessageType)infoMessage
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(TSThread *)thread
|
||||
messageType:(TSInfoMessageType)infoMessage
|
||||
{
|
||||
self = [super initMessageWithTimestamp:timestamp
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:@[]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
// MJK TODO - remove senderTimestamp
|
||||
self = [super initMessageWithSenderTimestamp:timestamp
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:@[]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
|
||||
if (!self) {
|
||||
return self;
|
||||
|
@ -71,24 +72,24 @@ NSUInteger TSInfoMessageSchemaVersion = 1;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(TSThread *)thread
|
||||
messageType:(TSInfoMessageType)infoMessage
|
||||
customMessage:(NSString *)customMessage
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(TSThread *)thread
|
||||
messageType:(TSInfoMessageType)infoMessage
|
||||
customMessage:(NSString *)customMessage
|
||||
{
|
||||
self = [self initWithTimestamp:timestamp inThread:thread messageType:infoMessage];
|
||||
self = [self initWithSenderTimestamp:timestamp inThread:thread messageType:infoMessage];
|
||||
if (self) {
|
||||
_customMessage = customMessage;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(TSThread *)thread
|
||||
messageType:(TSInfoMessageType)infoMessage
|
||||
unregisteredRecipientId:(NSString *)unregisteredRecipientId
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(TSThread *)thread
|
||||
messageType:(TSInfoMessageType)infoMessage
|
||||
unregisteredRecipientId:(NSString *)unregisteredRecipientId
|
||||
{
|
||||
self = [self initWithTimestamp:timestamp inThread:thread messageType:infoMessage];
|
||||
self = [self initWithSenderTimestamp:timestamp inThread:thread messageType:infoMessage];
|
||||
if (self) {
|
||||
_unregisteredRecipientId = unregisteredRecipientId;
|
||||
}
|
||||
|
@ -100,10 +101,11 @@ NSUInteger TSInfoMessageSchemaVersion = 1;
|
|||
OWSAssertDebug(thread);
|
||||
OWSAssertDebug(recipientId);
|
||||
|
||||
return [[self alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageType:TSInfoMessageUserNotRegistered
|
||||
unregisteredRecipientId:recipientId];
|
||||
// MJK TODO - remove senderTimestamp
|
||||
return [[self alloc] initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageType:TSInfoMessageUserNotRegistered
|
||||
unregisteredRecipientId:recipientId];
|
||||
}
|
||||
|
||||
- (OWSInteractionType)interactionType
|
||||
|
|
|
@ -28,7 +28,7 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value);
|
|||
|
||||
@interface TSInteraction : TSYapDatabaseObject
|
||||
|
||||
- (instancetype)initInteractionWithTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread;
|
||||
- (instancetype)initInteractionWithSenderTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread;
|
||||
|
||||
@property (nonatomic, readonly) NSString *uniqueThreadId;
|
||||
@property (nonatomic, readonly) TSThread *thread;
|
||||
|
@ -47,13 +47,13 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value);
|
|||
|
||||
#pragma mark Utility Method
|
||||
|
||||
+ (NSArray<TSInteraction *> *)interactionsWithTimestamp:(uint64_t)timestamp
|
||||
ofClass:(Class)clazz
|
||||
withTransaction:(YapDatabaseReadTransaction *)transaction;
|
||||
+ (NSArray<TSInteraction *> *)interactionsWithSenderTimestamp:(uint64_t)timestamp
|
||||
ofClass:(Class)clazz
|
||||
withTransaction:(YapDatabaseReadTransaction *)transaction;
|
||||
|
||||
+ (NSArray<TSInteraction *> *)interactionsWithTimestamp:(uint64_t)timestamp
|
||||
filter:(BOOL (^_Nonnull)(TSInteraction *))filter
|
||||
withTransaction:(YapDatabaseReadTransaction *)transaction;
|
||||
+ (NSArray<TSInteraction *> *)interactionsWithSenderTimestamp:(uint64_t)timestamp
|
||||
filter:(BOOL (^_Nonnull)(TSInteraction *))filter
|
||||
withTransaction:(YapDatabaseReadTransaction *)transaction;
|
||||
|
||||
- (NSDate *)dateForSorting;
|
||||
- (uint64_t)timestampForSorting;
|
||||
|
|
|
@ -39,40 +39,39 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
|
|||
|
||||
@implementation TSInteraction
|
||||
|
||||
+ (NSArray<TSInteraction *> *)interactionsWithTimestamp:(uint64_t)timestamp
|
||||
ofClass:(Class)clazz
|
||||
withTransaction:(YapDatabaseReadTransaction *)transaction
|
||||
+ (NSArray<TSInteraction *> *)interactionsWithSenderTimestamp:(uint64_t)timestamp
|
||||
ofClass:(Class)clazz
|
||||
withTransaction:(YapDatabaseReadTransaction *)transaction
|
||||
{
|
||||
OWSAssertDebug(timestamp > 0);
|
||||
|
||||
// Accept any interaction.
|
||||
return [self interactionsWithTimestamp:timestamp
|
||||
filter:^(TSInteraction *interaction) {
|
||||
return [interaction isKindOfClass:clazz];
|
||||
}
|
||||
withTransaction:transaction];
|
||||
return [self interactionsWithSenderTimestamp:timestamp
|
||||
filter:^(TSInteraction *interaction) {
|
||||
return [interaction isKindOfClass:clazz];
|
||||
}
|
||||
withTransaction:transaction];
|
||||
}
|
||||
|
||||
+ (NSArray<TSInteraction *> *)interactionsWithTimestamp:(uint64_t)timestamp
|
||||
filter:(BOOL (^_Nonnull)(TSInteraction *))filter
|
||||
withTransaction:(YapDatabaseReadTransaction *)transaction
|
||||
+ (NSArray<TSInteraction *> *)interactionsWithSenderTimestamp:(uint64_t)timestamp
|
||||
filter:(BOOL (^_Nonnull)(TSInteraction *))filter
|
||||
withTransaction:(YapDatabaseReadTransaction *)transaction
|
||||
{
|
||||
OWSAssertDebug(timestamp > 0);
|
||||
|
||||
NSMutableArray<TSInteraction *> *interactions = [NSMutableArray new];
|
||||
|
||||
[TSDatabaseSecondaryIndexes
|
||||
enumerateMessagesWithTimestamp:timestamp
|
||||
withBlock:^(NSString *collection, NSString *key, BOOL *stop) {
|
||||
|
||||
TSInteraction *interaction =
|
||||
[TSInteraction fetchObjectWithUniqueID:key transaction:transaction];
|
||||
if (!filter(interaction)) {
|
||||
return;
|
||||
}
|
||||
[interactions addObject:interaction];
|
||||
}
|
||||
usingTransaction:transaction];
|
||||
enumerateMessagesWithSenderTimestamp:timestamp
|
||||
withBlock:^(NSString *collection, NSString *key, BOOL *stop) {
|
||||
TSInteraction *interaction =
|
||||
[TSInteraction fetchObjectWithUniqueID:key transaction:transaction];
|
||||
if (!filter(interaction)) {
|
||||
return;
|
||||
}
|
||||
[interactions addObject:interaction];
|
||||
}
|
||||
usingTransaction:transaction];
|
||||
|
||||
return [interactions copy];
|
||||
}
|
||||
|
@ -81,7 +80,7 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
|
|||
return @"TSInteraction";
|
||||
}
|
||||
|
||||
- (instancetype)initInteractionWithTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread
|
||||
- (instancetype)initInteractionWithSenderTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread
|
||||
{
|
||||
OWSAssertDebug(timestamp > 0);
|
||||
|
||||
|
|
|
@ -27,16 +27,16 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@property (nonatomic, readonly, nullable) TSQuotedMessage *quotedMessage;
|
||||
@property (nonatomic, readonly, nullable) OWSContact *contactShare;
|
||||
|
||||
- (instancetype)initInteractionWithTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread NS_UNAVAILABLE;
|
||||
- (instancetype)initInteractionWithSenderTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initMessageWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
|
|
|
@ -60,16 +60,16 @@ static const NSUInteger OWSMessageSchemaVersion = 4;
|
|||
|
||||
@implementation TSMessage
|
||||
|
||||
- (instancetype)initMessageWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
- (instancetype)initMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
{
|
||||
self = [super initInteractionWithTimestamp:timestamp inThread:thread];
|
||||
self = [super initInteractionWithSenderTimestamp:timestamp inThread:thread];
|
||||
|
||||
if (!self) {
|
||||
return self;
|
||||
|
|
|
@ -68,25 +68,26 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
|
|||
|
||||
@interface TSOutgoingMessage : TSMessage
|
||||
|
||||
- (instancetype)initMessageWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
- (instancetype)initMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_DESIGNATED_INITIALIZER;
|
||||
// MJK TODO - Can we remove the sender timestamp param?
|
||||
- (instancetype)initOutgoingMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
|
|
|
@ -261,53 +261,55 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
|
|||
[attachmentIds addObject:attachmentId];
|
||||
}
|
||||
|
||||
return [[TSOutgoingMessage alloc] initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:body
|
||||
attachmentIds:attachmentIds
|
||||
expiresInSeconds:expiresInSeconds
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:nil];
|
||||
// MJK TODO remove SenderTimestamp?
|
||||
return [[TSOutgoingMessage alloc] initOutgoingMessageWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:body
|
||||
attachmentIds:attachmentIds
|
||||
expiresInSeconds:expiresInSeconds
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:nil];
|
||||
}
|
||||
|
||||
+ (instancetype)outgoingMessageInThread:(nullable TSThread *)thread
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds;
|
||||
{
|
||||
return [[TSOutgoingMessage alloc] initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:expiresInSeconds
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:groupMetaMessage
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
// MJK TODO remove SenderTimestamp?
|
||||
return [[TSOutgoingMessage alloc] initOutgoingMessageWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:expiresInSeconds
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:groupMetaMessage
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
}
|
||||
|
||||
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
- (instancetype)initOutgoingMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
{
|
||||
self = [super initMessageWithTimestamp:timestamp
|
||||
inThread:thread
|
||||
messageBody:body
|
||||
attachmentIds:attachmentIds
|
||||
expiresInSeconds:expiresInSeconds
|
||||
expireStartedAt:expireStartedAt
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:contactShare];
|
||||
self = [super initMessageWithSenderTimestamp:timestamp
|
||||
inThread:thread
|
||||
messageBody:body
|
||||
attachmentIds:attachmentIds
|
||||
expiresInSeconds:expiresInSeconds
|
||||
expireStartedAt:expireStartedAt
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:contactShare];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -84,17 +84,17 @@ typedef NS_ENUM(NSUInteger, TSQuotedMessageContentSource) {
|
|||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
// used when receiving quoted messages
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
authorId:(NSString *)authorId
|
||||
body:(NSString *_Nullable)body
|
||||
bodySource:(TSQuotedMessageContentSource)bodySource
|
||||
receivedQuotedAttachmentInfos:(NSArray<OWSAttachmentInfo *> *)attachmentInfos;
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
authorId:(NSString *)authorId
|
||||
body:(NSString *_Nullable)body
|
||||
bodySource:(TSQuotedMessageContentSource)bodySource
|
||||
receivedQuotedAttachmentInfos:(NSArray<OWSAttachmentInfo *> *)attachmentInfos;
|
||||
|
||||
// used when sending quoted messages
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
authorId:(NSString *)authorId
|
||||
body:(NSString *_Nullable)body
|
||||
quotedAttachmentsForSending:(NSArray<TSAttachment *> *)attachments;
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
authorId:(NSString *)authorId
|
||||
body:(NSString *_Nullable)body
|
||||
quotedAttachmentsForSending:(NSArray<TSAttachment *> *)attachments;
|
||||
|
||||
|
||||
+ (nullable instancetype)quotedMessageForDataMessage:(SSKProtoDataMessage *)dataMessage
|
||||
|
|
|
@ -56,11 +56,11 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@implementation TSQuotedMessage
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
authorId:(NSString *)authorId
|
||||
body:(NSString *_Nullable)body
|
||||
bodySource:(TSQuotedMessageContentSource)bodySource
|
||||
receivedQuotedAttachmentInfos:(NSArray<OWSAttachmentInfo *> *)attachmentInfos
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
authorId:(NSString *)authorId
|
||||
body:(NSString *_Nullable)body
|
||||
bodySource:(TSQuotedMessageContentSource)bodySource
|
||||
receivedQuotedAttachmentInfos:(NSArray<OWSAttachmentInfo *> *)attachmentInfos
|
||||
{
|
||||
OWSAssertDebug(timestamp > 0);
|
||||
OWSAssertDebug(authorId.length > 0);
|
||||
|
@ -79,10 +79,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
authorId:(NSString *)authorId
|
||||
body:(NSString *_Nullable)body
|
||||
quotedAttachmentsForSending:(NSArray<TSAttachmentStream *> *)attachments
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
authorId:(NSString *)authorId
|
||||
body:(NSString *_Nullable)body
|
||||
quotedAttachmentsForSending:(NSArray<TSAttachmentStream *> *)attachments
|
||||
{
|
||||
OWSAssertDebug(timestamp > 0);
|
||||
OWSAssertDebug(authorId.length > 0);
|
||||
|
@ -136,9 +136,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
TSQuotedMessageContentSource bodySource = TSQuotedMessageContentSourceUnknown;
|
||||
|
||||
// Prefer to generate the text snippet locally if available.
|
||||
TSMessage *_Nullable localRecord = (TSMessage *)[
|
||||
[TSInteraction interactionsWithTimestamp:quoteProto.id ofClass:TSMessage.class withTransaction:transaction]
|
||||
firstObject];
|
||||
TSMessage *_Nullable localRecord
|
||||
= (TSMessage *)[[TSInteraction interactionsWithSenderTimestamp:quoteProto.id
|
||||
ofClass:TSMessage.class
|
||||
withTransaction:transaction] firstObject];
|
||||
|
||||
if (localRecord) {
|
||||
bodySource = TSQuotedMessageContentSourceLocal;
|
||||
|
@ -208,11 +209,12 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
return nil;
|
||||
}
|
||||
|
||||
return [[TSQuotedMessage alloc] initWithTimestamp:timestamp
|
||||
authorId:authorId
|
||||
body:body
|
||||
bodySource:bodySource
|
||||
receivedQuotedAttachmentInfos:attachmentInfos];
|
||||
// Legit usage of senderTimestamp - this class references the message it is quoting by it's sender timestamp
|
||||
return [[TSQuotedMessage alloc] initWithSenderTimestamp:timestamp
|
||||
authorId:authorId
|
||||
body:body
|
||||
bodySource:bodySource
|
||||
receivedQuotedAttachmentInfos:attachmentInfos];
|
||||
}
|
||||
|
||||
+ (nullable TSAttachmentStream *)tryToDeriveLocalThumbnailWithAttachmentInfo:(OWSAttachmentInfo *)attachmentInfo
|
||||
|
@ -227,25 +229,23 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
}
|
||||
|
||||
NSArray<TSMessage *> *quotedMessages = (NSArray<TSMessage *> *)[TSInteraction
|
||||
interactionsWithTimestamp:timestamp
|
||||
filter:^BOOL(TSInteraction *interaction) {
|
||||
interactionsWithSenderTimestamp:timestamp
|
||||
filter:^BOOL(TSInteraction *interaction) {
|
||||
if (![threadId isEqual:interaction.uniqueThreadId]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![threadId isEqual:interaction.uniqueThreadId]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if ([interaction isKindOfClass:[TSIncomingMessage class]]) {
|
||||
TSIncomingMessage *incomingMessage = (TSIncomingMessage *)interaction;
|
||||
return [authorId isEqual:incomingMessage.messageAuthorId];
|
||||
} else if ([interaction isKindOfClass:[TSOutgoingMessage class]]) {
|
||||
return [authorId isEqual:[TSAccountManager localNumber]];
|
||||
} else {
|
||||
// ignore other interaction types
|
||||
return NO;
|
||||
}
|
||||
|
||||
}
|
||||
withTransaction:transaction];
|
||||
if ([interaction isKindOfClass:[TSIncomingMessage class]]) {
|
||||
TSIncomingMessage *incomingMessage = (TSIncomingMessage *)interaction;
|
||||
return [authorId isEqual:incomingMessage.messageAuthorId];
|
||||
} else if ([interaction isKindOfClass:[TSOutgoingMessage class]]) {
|
||||
return [authorId isEqual:[TSAccountManager localNumber]];
|
||||
} else {
|
||||
// ignore other interaction types
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
withTransaction:transaction];
|
||||
|
||||
TSMessage *_Nullable quotedMessage = quotedMessages.firstObject;
|
||||
|
||||
|
|
|
@ -38,18 +38,22 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
{
|
||||
TSContactThread *contactThread =
|
||||
[TSContactThread getOrCreateThreadWithContactId:envelope.source transaction:transaction];
|
||||
|
||||
// MJK - FIXME, can't rely on envelope.timestamp for sorting, ensure this is saved immediately.
|
||||
TSInvalidIdentityKeyReceivingErrorMessage *errorMessage =
|
||||
[[self alloc] initForUnknownIdentityKeyWithTimestamp:envelope.timestamp
|
||||
inThread:contactThread
|
||||
incomingEnvelope:envelope];
|
||||
[[self alloc] initForUnknownIdentityKeyWithSenderTimestamp:envelope.timestamp
|
||||
inThread:contactThread
|
||||
incomingEnvelope:envelope];
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initForUnknownIdentityKeyWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(TSThread *)thread
|
||||
incomingEnvelope:(SSKProtoEnvelope *)envelope
|
||||
- (nullable instancetype)initForUnknownIdentityKeyWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(TSThread *)thread
|
||||
incomingEnvelope:(SSKProtoEnvelope *)envelope
|
||||
{
|
||||
self = [self initWithTimestamp:timestamp inThread:thread failedMessageType:TSErrorMessageWrongTrustedIdentityKey];
|
||||
self = [self initWithSenderTimestamp:timestamp
|
||||
inThread:thread
|
||||
failedMessageType:TSErrorMessageWrongTrustedIdentityKey];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -32,10 +32,11 @@ NSString *TSInvalidRecipientKey = @"TSInvalidRecipientKey";
|
|||
preKeyBundle:(PreKeyBundle *)preKeyBundle
|
||||
{
|
||||
// We want the error message to appear after the message.
|
||||
self = [super initWithTimestamp:message.timestamp + 1
|
||||
inThread:thread
|
||||
failedMessageType:TSErrorMessageWrongTrustedIdentityKey
|
||||
recipientId:recipientId];
|
||||
// MJK FIXME - we can't rely on sort order like this.
|
||||
self = [super initWithSenderTimestamp:message.timestamp + 1
|
||||
inThread:thread
|
||||
failedMessageType:TSErrorMessageWrongTrustedIdentityKey
|
||||
recipientId:recipientId];
|
||||
|
||||
if (self) {
|
||||
_messageId = message.uniqueId;
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSInfoMessage.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// This is a deprecated class, we're keeping it around to avoid YapDB serialization errors
|
||||
// TODO - remove this class, clean up existing instances, ensure any missed ones don't explode (UnknownDBObject)
|
||||
__attribute__((deprecated))
|
||||
@interface OWSAddToContactsOfferMessage : TSInfoMessage
|
||||
|
||||
+ (instancetype)addToContactsOfferMessage:(uint64_t)timestamp thread:(TSThread *)thread contactId:(NSString *)contactId;
|
||||
+ (instancetype)addToContactsOfferMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
thread:(TSThread *)thread
|
||||
contactId:(NSString *)contactId;
|
||||
|
||||
@property (nonatomic, readonly) NSString *contactId;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSAddToContactsOfferMessage.h"
|
||||
|
@ -14,16 +14,20 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
#pragma mark -
|
||||
|
||||
// This is a deprecated class, we're keeping it around to avoid YapDB serialization errors
|
||||
// TODO - remove this class, clean up existing instances, ensure any missed ones don't explode (UnknownDBObject)
|
||||
@implementation OWSAddToContactsOfferMessage
|
||||
|
||||
+ (instancetype)addToContactsOfferMessage:(uint64_t)timestamp thread:(TSThread *)thread contactId:(NSString *)contactId
|
||||
+ (instancetype)addToContactsOfferMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
thread:(TSThread *)thread
|
||||
contactId:(NSString *)contactId
|
||||
{
|
||||
return [[OWSAddToContactsOfferMessage alloc] initWithTimestamp:timestamp thread:thread contactId:contactId];
|
||||
return [[OWSAddToContactsOfferMessage alloc] initWithSenderTimestamp:timestamp thread:thread contactId:contactId];
|
||||
}
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp thread:(TSThread *)thread contactId:(NSString *)contactId
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp thread:(TSThread *)thread contactId:(NSString *)contactId
|
||||
{
|
||||
self = [super initWithTimestamp:timestamp inThread:thread messageType:TSInfoMessageAddToContactsOffer];
|
||||
self = [super initWithSenderTimestamp:timestamp inThread:thread messageType:TSInfoMessageAddToContactsOffer];
|
||||
|
||||
if (self) {
|
||||
_contactId = contactId;
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSInfoMessage.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface OWSAddToProfileWhitelistOfferMessage : TSInfoMessage
|
||||
// This is a deprecated class, we're keeping it around to avoid YapDB serialization errors
|
||||
// TODO - remove this class, clean up existing instances, ensure any missed ones don't explode (UnknownDBObject)
|
||||
__attribute__((deprecated)) @interface OWSAddToProfileWhitelistOfferMessage : TSInfoMessage
|
||||
|
||||
+ (instancetype)addToProfileWhitelistOfferMessage:(uint64_t)timestamp thread:(TSThread *)thread;
|
||||
+ (instancetype)addToProfileWhitelistOfferMessageWithSenderTimestamp:(uint64_t)timestamp thread:(TSThread *)thread;
|
||||
|
||||
@property (nonatomic, readonly) NSString *contactId;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSAddToProfileWhitelistOfferMessage.h"
|
||||
|
@ -7,15 +7,17 @@
|
|||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// This is a deprecated class, we're keeping it around to avoid YapDB serialization errors
|
||||
// TODO - remove this class, clean up existing instances, ensure any missed ones don't explode (UnknownDBObject)
|
||||
@implementation OWSAddToProfileWhitelistOfferMessage
|
||||
|
||||
+ (instancetype)addToProfileWhitelistOfferMessage:(uint64_t)timestamp thread:(TSThread *)thread
|
||||
+ (instancetype)addToProfileWhitelistOfferMessageWithSenderTimestamp:(uint64_t)timestamp thread:(TSThread *)thread
|
||||
{
|
||||
return [[OWSAddToProfileWhitelistOfferMessage alloc]
|
||||
initWithTimestamp:timestamp
|
||||
inThread:thread
|
||||
messageType:(thread.isGroupThread ? TSInfoMessageAddGroupToProfileWhitelistOffer
|
||||
: TSInfoMessageAddUserToProfileWhitelistOffer)];
|
||||
initWithSenderTimestamp:timestamp
|
||||
inThread:thread
|
||||
messageType:(thread.isGroupThread ? TSInfoMessageAddGroupToProfileWhitelistOffer
|
||||
: TSInfoMessageAddUserToProfileWhitelistOffer)];
|
||||
}
|
||||
|
||||
- (BOOL)shouldUseReceiptDateForSorting
|
||||
|
|
|
@ -52,9 +52,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
* @param createdInExistingGroup
|
||||
* YES when being added to a group which already has DM enabled, otherwise NO
|
||||
*/
|
||||
// MJK FIXME - we can't rely on timestampForSorting
|
||||
- (void)becomeConsistentWithDisappearingDuration:(uint32_t)duration
|
||||
thread:(TSThread *)thread
|
||||
appearBeforeTimestamp:(uint64_t)timestampForSorting
|
||||
appearBeforeSenderTimestamp:(uint64_t)timestampForSorting
|
||||
createdByRemoteContactName:(nullable NSString *)remoteContactName
|
||||
createdInExistingGroup:(BOOL)createdInExistingGroup
|
||||
transaction:(YapDatabaseReadWriteTransaction *)transaction;
|
||||
|
|
|
@ -204,17 +204,19 @@ void AssertIsOnDisappearingMessagesQueue()
|
|||
remoteContactName = [contactsManager displayNameForPhoneIdentifier:incomingMessage.messageAuthorId];
|
||||
}
|
||||
|
||||
// MJK - we can't rely on timestampForSorting
|
||||
[self becomeConsistentWithDisappearingDuration:message.expiresInSeconds
|
||||
thread:thread
|
||||
appearBeforeTimestamp:message.timestampForSorting
|
||||
appearBeforeSenderTimestamp:message.timestampForSorting
|
||||
createdByRemoteContactName:remoteContactName
|
||||
createdInExistingGroup:NO
|
||||
transaction:transaction];
|
||||
}
|
||||
|
||||
// MJK - we can't rely on timestampForSorting
|
||||
- (void)becomeConsistentWithDisappearingDuration:(uint32_t)duration
|
||||
thread:(TSThread *)thread
|
||||
appearBeforeTimestamp:(uint64_t)timestampForSorting
|
||||
appearBeforeSenderTimestamp:(uint64_t)timestampForSorting
|
||||
createdByRemoteContactName:(nullable NSString *)remoteContactName
|
||||
createdInExistingGroup:(BOOL)createdInExistingGroup
|
||||
transaction:(YapDatabaseReadWriteTransaction *)transaction
|
||||
|
@ -247,12 +249,13 @@ void AssertIsOnDisappearingMessagesQueue()
|
|||
[disappearingMessagesConfiguration saveWithTransaction:transaction];
|
||||
|
||||
// We want the info message to appear _before_ the message.
|
||||
// MJK FIXME - we have to affect ordering by creation sequence, not sender timestamp
|
||||
OWSDisappearingConfigurationUpdateInfoMessage *infoMessage =
|
||||
[[OWSDisappearingConfigurationUpdateInfoMessage alloc] initWithTimestamp:timestampForSorting - 1
|
||||
thread:thread
|
||||
configuration:disappearingMessagesConfiguration
|
||||
createdByRemoteName:remoteContactName
|
||||
createdInExistingGroup:createdInExistingGroup];
|
||||
[[OWSDisappearingConfigurationUpdateInfoMessage alloc] initWithSenderTimestamp:timestampForSorting - 1
|
||||
thread:thread
|
||||
configuration:disappearingMessagesConfiguration
|
||||
createdByRemoteName:remoteContactName
|
||||
createdInExistingGroup:createdInExistingGroup];
|
||||
[infoMessage saveWithTransaction:transaction];
|
||||
|
||||
OWSAssertDebug(backgroundTask);
|
||||
|
|
|
@ -845,7 +845,9 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
|
|||
TSContactThread *contactThread =
|
||||
[TSContactThread getOrCreateThreadWithContactId:recipientId transaction:transaction];
|
||||
OWSAssertDebug(contactThread);
|
||||
[messages addObject:[[OWSVerificationStateChangeMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
// MJK TODO - should be safe to remove senderTimestamp
|
||||
[messages
|
||||
addObject:[[OWSVerificationStateChangeMessage alloc] initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:contactThread
|
||||
recipientId:recipientId
|
||||
verificationState:verificationState
|
||||
|
@ -853,14 +855,16 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
|
|||
|
||||
for (TSGroupThread *groupThread in
|
||||
[TSGroupThread groupThreadsWithRecipientId:recipientId transaction:transaction]) {
|
||||
[messages
|
||||
addObject:[[OWSVerificationStateChangeMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:groupThread
|
||||
recipientId:recipientId
|
||||
verificationState:verificationState
|
||||
isLocalChange:isLocalChange]];
|
||||
// MJK TODO - should be safe to remove senderTimestamp
|
||||
[messages addObject:[[OWSVerificationStateChangeMessage alloc]
|
||||
initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:groupThread
|
||||
recipientId:recipientId
|
||||
verificationState:verificationState
|
||||
isLocalChange:isLocalChange]];
|
||||
}
|
||||
|
||||
// MJK TODO - why not save in-line, vs storing in an array and saving the array?
|
||||
for (TSMessage *message in messages) {
|
||||
[message saveWithTransaction:transaction];
|
||||
}
|
||||
|
|
|
@ -288,9 +288,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
uint64_t timestamp = [nsTimestamp unsignedLongLongValue];
|
||||
|
||||
NSArray<TSOutgoingMessage *> *messages
|
||||
= (NSArray<TSOutgoingMessage *> *)[TSInteraction interactionsWithTimestamp:timestamp
|
||||
ofClass:[TSOutgoingMessage class]
|
||||
withTransaction:transaction];
|
||||
= (NSArray<TSOutgoingMessage *> *)[TSInteraction interactionsWithSenderTimestamp:timestamp
|
||||
ofClass:[TSOutgoingMessage class]
|
||||
withTransaction:transaction];
|
||||
if (messages.count < 1) {
|
||||
// The service sends delivery receipts for "unpersisted" messages
|
||||
// like group updates, so these errors are expected to a certain extent.
|
||||
|
@ -879,9 +879,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
TSContactThread *thread = [TSContactThread getOrCreateThreadWithContactId:envelope.source transaction:transaction];
|
||||
|
||||
[[[TSInfoMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageType:TSInfoMessageTypeSessionDidEnd] saveWithTransaction:transaction];
|
||||
// MJK TODO - safe to remove senderTimestamp
|
||||
[[[TSInfoMessage alloc] initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageType:TSInfoMessageTypeSessionDidEnd] saveWithTransaction:transaction];
|
||||
|
||||
[self.primaryStorage deleteAllSessionsForContact:envelope.source protocolContext:transaction];
|
||||
}
|
||||
|
@ -927,12 +928,13 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
OWSAssertDebug(disappearingMessagesConfiguration);
|
||||
[disappearingMessagesConfiguration saveWithTransaction:transaction];
|
||||
NSString *name = [self.contactsManager displayNameForPhoneIdentifier:envelope.source];
|
||||
// MJK TODO - safe to remove senderTimestamp
|
||||
OWSDisappearingConfigurationUpdateInfoMessage *message =
|
||||
[[OWSDisappearingConfigurationUpdateInfoMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
configuration:disappearingMessagesConfiguration
|
||||
createdByRemoteName:name
|
||||
createdInExistingGroup:NO];
|
||||
[[OWSDisappearingConfigurationUpdateInfoMessage alloc] initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
configuration:disappearingMessagesConfiguration
|
||||
createdByRemoteName:name
|
||||
createdInExistingGroup:NO];
|
||||
[message saveWithTransaction:transaction];
|
||||
}
|
||||
|
||||
|
@ -1155,17 +1157,19 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
newGroupThread.groupModel = newGroupModel;
|
||||
[newGroupThread saveWithTransaction:transaction];
|
||||
|
||||
TSInfoMessage *infoMessage = [[TSInfoMessage alloc] initWithTimestamp:now
|
||||
inThread:newGroupThread
|
||||
messageType:TSInfoMessageTypeGroupUpdate
|
||||
customMessage:updateGroupInfo];
|
||||
// MJK FIXME - seems like we're relying on senderTimestamp
|
||||
TSInfoMessage *infoMessage = [[TSInfoMessage alloc] initWithSenderTimestamp:now
|
||||
inThread:newGroupThread
|
||||
messageType:TSInfoMessageTypeGroupUpdate
|
||||
customMessage:updateGroupInfo];
|
||||
[infoMessage saveWithTransaction:transaction];
|
||||
|
||||
if (dataMessage.hasExpireTimer && dataMessage.expireTimer > 0) {
|
||||
// MJK - we can't rely on senderTimestamp
|
||||
[[OWSDisappearingMessagesJob sharedJob]
|
||||
becomeConsistentWithDisappearingDuration:dataMessage.expireTimer
|
||||
thread:newGroupThread
|
||||
appearBeforeTimestamp:now
|
||||
appearBeforeSenderTimestamp:now
|
||||
createdByRemoteContactName:nil
|
||||
createdInExistingGroup:YES
|
||||
transaction:transaction];
|
||||
|
@ -1185,10 +1189,11 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
NSString *nameString = [self.contactsManager displayNameForPhoneIdentifier:envelope.source];
|
||||
NSString *updateGroupInfo =
|
||||
[NSString stringWithFormat:NSLocalizedString(@"GROUP_MEMBER_LEFT", @""), nameString];
|
||||
[[[TSInfoMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:oldGroupThread
|
||||
messageType:TSInfoMessageTypeGroupUpdate
|
||||
customMessage:updateGroupInfo] saveWithTransaction:transaction];
|
||||
// MJK TODO - should be safe to remove senderTimestamp
|
||||
[[[TSInfoMessage alloc] initWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:oldGroupThread
|
||||
messageType:TSInfoMessageTypeGroupUpdate
|
||||
customMessage:updateGroupInfo] saveWithTransaction:transaction];
|
||||
return nil;
|
||||
}
|
||||
case SSKProtoGroupContextTypeDeliver: {
|
||||
|
@ -1214,16 +1219,17 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
groupId,
|
||||
(unsigned long)timestamp);
|
||||
|
||||
// Legit usage of senderTimestamp when creating an incoming group message record
|
||||
TSIncomingMessage *incomingMessage =
|
||||
[[TSIncomingMessage alloc] initIncomingMessageWithTimestamp:timestamp
|
||||
inThread:oldGroupThread
|
||||
authorId:envelope.source
|
||||
sourceDeviceId:envelope.sourceDevice
|
||||
messageBody:body
|
||||
attachmentIds:attachmentIds
|
||||
expiresInSeconds:dataMessage.expireTimer
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:contact];
|
||||
[[TSIncomingMessage alloc] initIncomingMessageWithSenderTimestamp:timestamp
|
||||
inThread:oldGroupThread
|
||||
authorId:envelope.source
|
||||
sourceDeviceId:envelope.sourceDevice
|
||||
messageBody:body
|
||||
attachmentIds:attachmentIds
|
||||
expiresInSeconds:dataMessage.expireTimer
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:contact];
|
||||
|
||||
[self finalizeIncomingMessage:incomingMessage
|
||||
thread:oldGroupThread
|
||||
|
@ -1253,16 +1259,17 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
thread:thread
|
||||
transaction:transaction];
|
||||
|
||||
// Legit usage of senderTimestamp when creating incoming message from received envelope
|
||||
TSIncomingMessage *incomingMessage =
|
||||
[[TSIncomingMessage alloc] initIncomingMessageWithTimestamp:timestamp
|
||||
inThread:thread
|
||||
authorId:[thread contactIdentifier]
|
||||
sourceDeviceId:envelope.sourceDevice
|
||||
messageBody:body
|
||||
attachmentIds:attachmentIds
|
||||
expiresInSeconds:dataMessage.expireTimer
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:contact];
|
||||
[[TSIncomingMessage alloc] initIncomingMessageWithSenderTimestamp:timestamp
|
||||
inThread:thread
|
||||
authorId:[thread contactIdentifier]
|
||||
sourceDeviceId:envelope.sourceDevice
|
||||
messageBody:body
|
||||
attachmentIds:attachmentIds
|
||||
expiresInSeconds:dataMessage.expireTimer
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:contact];
|
||||
|
||||
[self finalizeIncomingMessage:incomingMessage
|
||||
thread:thread
|
||||
|
|
|
@ -1416,15 +1416,17 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
|
|||
// TODO: Why is this necessary?
|
||||
[message save];
|
||||
} else if (message.groupMetaMessage == TSGroupMetaMessageQuit) {
|
||||
[[[TSInfoMessage alloc] initWithTimestamp:message.timestamp
|
||||
inThread:thread
|
||||
messageType:TSInfoMessageTypeGroupQuit
|
||||
customMessage:message.customMessage] save];
|
||||
// MJK TODO - remove senderTimestamp
|
||||
[[[TSInfoMessage alloc] initWithSenderTimestamp:message.timestamp
|
||||
inThread:thread
|
||||
messageType:TSInfoMessageTypeGroupQuit
|
||||
customMessage:message.customMessage] save];
|
||||
} else {
|
||||
[[[TSInfoMessage alloc] initWithTimestamp:message.timestamp
|
||||
inThread:thread
|
||||
messageType:TSInfoMessageTypeGroupUpdate
|
||||
customMessage:message.customMessage] save];
|
||||
// MJK TODO - remove senderTimestamp
|
||||
[[[TSInfoMessage alloc] initWithSenderTimestamp:message.timestamp
|
||||
inThread:thread
|
||||
messageType:TSInfoMessageTypeGroupUpdate
|
||||
customMessage:message.customMessage] save];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,16 +18,16 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
*/
|
||||
@interface OWSOutgoingCallMessage : TSOutgoingMessage
|
||||
|
||||
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
- (instancetype)initOutgoingMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithThread:(TSThread *)thread offerMessage:(SSKProtoCallMessageOffer *)offerMessage;
|
||||
- (instancetype)initWithThread:(TSThread *)thread answerMessage:(SSKProtoCallMessageAnswer *)answerMessage;
|
||||
|
|
|
@ -15,18 +15,19 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
- (instancetype)initWithThread:(TSThread *)thread
|
||||
{
|
||||
// MJK TODO - investigate this.
|
||||
// These records aren't saved, but their timestamp is used in the event
|
||||
// of a failing message send to insert the error at the appropriate place.
|
||||
self = [super initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
self = [super initOutgoingMessageWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -11,16 +11,16 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@interface OWSOutgoingNullMessage : TSOutgoingMessage
|
||||
|
||||
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
- (instancetype)initOutgoingMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithContactThread:(TSContactThread *)contactThread
|
||||
verificationStateSyncMessage:(OWSVerificationStateSyncMessage *)verificationStateSyncMessage;
|
||||
|
|
|
@ -24,16 +24,17 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
- (instancetype)initWithContactThread:(TSContactThread *)contactThread
|
||||
verificationStateSyncMessage:(OWSVerificationStateSyncMessage *)verificationStateSyncMessage
|
||||
{
|
||||
self = [super initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:contactThread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
// MJK TODO - remove senderTimestamp
|
||||
self = [super initOutgoingMessageWithSenderTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:contactThread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -8,18 +8,19 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@interface OWSProfileKeyMessage : TSOutgoingMessage
|
||||
|
||||
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
- (instancetype)initOutgoingMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp inThread:(nullable TSThread *)thread NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread NS_DESIGNATED_INITIALIZER;
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
|
|
@ -12,18 +12,18 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@implementation OWSProfileKeyMessage
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp inThread:(nullable TSThread *)thread
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp inThread:(nullable TSThread *)thread
|
||||
{
|
||||
return [super initOutgoingMessageWithTimestamp:timestamp
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
return [super initOutgoingMessageWithSenderTimestamp:timestamp
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)coder
|
||||
|
|
|
@ -361,10 +361,10 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
|
|||
for (NSNumber *nsSentTimestamp in sentTimestamps) {
|
||||
UInt64 sentTimestamp = [nsSentTimestamp unsignedLongLongValue];
|
||||
|
||||
NSArray<TSOutgoingMessage *> *messages
|
||||
= (NSArray<TSOutgoingMessage *> *)[TSInteraction interactionsWithTimestamp:sentTimestamp
|
||||
ofClass:[TSOutgoingMessage class]
|
||||
withTransaction:transaction];
|
||||
NSArray<TSOutgoingMessage *> *messages = (NSArray<TSOutgoingMessage *> *)[TSInteraction
|
||||
interactionsWithSenderTimestamp:sentTimestamp
|
||||
ofClass:[TSOutgoingMessage class]
|
||||
withTransaction:transaction];
|
||||
if (messages.count > 1) {
|
||||
OWSLogError(@"More than one matching message with timestamp: %llu.", sentTimestamp);
|
||||
}
|
||||
|
@ -461,9 +461,9 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
|
|||
}
|
||||
|
||||
NSArray<TSIncomingMessage *> *messages
|
||||
= (NSArray<TSIncomingMessage *> *)[TSInteraction interactionsWithTimestamp:messageIdTimestamp
|
||||
ofClass:[TSIncomingMessage class]
|
||||
withTransaction:transaction];
|
||||
= (NSArray<TSIncomingMessage *> *)[TSInteraction interactionsWithSenderTimestamp:messageIdTimestamp
|
||||
ofClass:[TSIncomingMessage class]
|
||||
withTransaction:transaction];
|
||||
if (messages.count > 0) {
|
||||
for (TSIncomingMessage *message in messages) {
|
||||
NSTimeInterval secondsSinceRead = [NSDate new].timeIntervalSince1970 - readTimestamp / 1000;
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSErrorMessage.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface OWSUnknownContactBlockOfferMessage : TSErrorMessage
|
||||
// This is a deprecated class, we're keeping it around to avoid YapDB serialization errors
|
||||
// TODO - remove this class, clean up existing instances, ensure any missed ones don't explode (UnknownDBObject)
|
||||
__attribute__((deprecated)) @interface OWSUnknownContactBlockOfferMessage : TSErrorMessage
|
||||
|
||||
+ (instancetype)unknownContactBlockOfferMessage:(uint64_t)timestamp
|
||||
thread:(TSThread *)thread
|
||||
contactId:(NSString *)contactId;
|
||||
+ (instancetype)unknownContactBlockOfferMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
thread:(TSThread *)thread
|
||||
contactId:(NSString *)contactId;
|
||||
|
||||
@property (nonatomic, readonly) NSString *contactId;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSUnknownContactBlockOfferMessage.h"
|
||||
|
@ -14,18 +14,24 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
#pragma mark -
|
||||
|
||||
// This is a deprecated class, we're keeping it around to avoid YapDB serialization errors
|
||||
// TODO - remove this class, clean up existing instances, ensure any missed ones don't explode (UnknownDBObject)
|
||||
@implementation OWSUnknownContactBlockOfferMessage
|
||||
|
||||
+ (instancetype)unknownContactBlockOfferMessage:(uint64_t)timestamp
|
||||
thread:(TSThread *)thread
|
||||
contactId:(NSString *)contactId
|
||||
+ (instancetype)unknownContactBlockOfferMessageWithSenderTimestamp:(uint64_t)timestamp
|
||||
thread:(TSThread *)thread
|
||||
contactId:(NSString *)contactId
|
||||
{
|
||||
return [[OWSUnknownContactBlockOfferMessage alloc] initWithTimestamp:timestamp thread:thread contactId:contactId];
|
||||
return [[OWSUnknownContactBlockOfferMessage alloc] initWithSenderTimestamp:timestamp
|
||||
thread:thread
|
||||
contactId:contactId];
|
||||
}
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp thread:(TSThread *)thread contactId:(NSString *)contactId
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp thread:(TSThread *)thread contactId:(NSString *)contactId
|
||||
{
|
||||
self = [super initWithTimestamp:timestamp inThread:thread failedMessageType:TSErrorMessageUnknownContactBlockOffer];
|
||||
self = [super initWithSenderTimestamp:timestamp
|
||||
inThread:thread
|
||||
failedMessageType:TSErrorMessageUnknownContactBlockOffer];
|
||||
|
||||
if (self) {
|
||||
_contactId = contactId;
|
||||
|
|
|
@ -27,12 +27,12 @@ NSString *NSStringFromCallType(RPRecentCallType callType);
|
|||
|
||||
@property (nonatomic, readonly) RPRecentCallType callType;
|
||||
|
||||
- (instancetype)initInteractionWithTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread NS_UNAVAILABLE;
|
||||
- (instancetype)initInteractionWithSenderTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
withCallNumber:(NSString *)contactNumber
|
||||
callType:(RPRecentCallType)callType
|
||||
inThread:(TSContactThread *)thread NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
withCallNumber:(NSString *)contactNumber
|
||||
callType:(RPRecentCallType)callType
|
||||
inThread:(TSContactThread *)thread NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
|
|
|
@ -45,12 +45,12 @@ NSUInteger TSCallCurrentSchemaVersion = 1;
|
|||
|
||||
@implementation TSCall
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
withCallNumber:(NSString *)contactNumber
|
||||
callType:(RPRecentCallType)callType
|
||||
inThread:(TSContactThread *)thread
|
||||
- (instancetype)initWithSenderTimestamp:(uint64_t)timestamp
|
||||
withCallNumber:(NSString *)contactNumber
|
||||
callType:(RPRecentCallType)callType
|
||||
inThread:(TSContactThread *)thread
|
||||
{
|
||||
self = [super initInteractionWithTimestamp:timestamp inThread:thread];
|
||||
self = [super initInteractionWithSenderTimestamp:timestamp inThread:thread];
|
||||
|
||||
if (!self) {
|
||||
return self;
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
+ (YapDatabaseSecondaryIndex *)registerTimeStampIndex;
|
||||
|
||||
+ (void)enumerateMessagesWithTimestamp:(uint64_t)timestamp
|
||||
withBlock:(void (^)(NSString *collection, NSString *key, BOOL *stop))block
|
||||
usingTransaction:(YapDatabaseReadTransaction *)transaction;
|
||||
+ (void)enumerateMessagesWithSenderTimestamp:(uint64_t)timestamp
|
||||
withBlock:(void (^)(NSString *collection, NSString *key, BOOL *stop))block
|
||||
usingTransaction:(YapDatabaseReadTransaction *)transaction;
|
||||
|
||||
@end
|
||||
|
|
|
@ -38,9 +38,9 @@
|
|||
}
|
||||
|
||||
|
||||
+ (void)enumerateMessagesWithTimestamp:(uint64_t)timestamp
|
||||
withBlock:(void (^)(NSString *collection, NSString *key, BOOL *stop))block
|
||||
usingTransaction:(YapDatabaseReadTransaction *)transaction
|
||||
+ (void)enumerateMessagesWithSenderTimestamp:(uint64_t)timestamp
|
||||
withBlock:(void (^)(NSString *collection, NSString *key, BOOL *stop))block
|
||||
usingTransaction:(YapDatabaseReadTransaction *)transaction
|
||||
{
|
||||
NSString *formattedString = [NSString stringWithFormat:@"WHERE %@ = %lld", TSTimeStampSQLiteIndex, timestamp];
|
||||
YapDatabaseQuery *query = [YapDatabaseQuery queryWithFormat:formattedString];
|
||||
|
|
Loading…
Reference in a new issue