pull/497/head
ryanzhao 3 years ago
parent 132ff0416f
commit da335a8401

@ -1158,7 +1158,7 @@ NS_ASSUME_NONNULL_BEGIN
break; break;
} }
uint64_t viewItemTimestamp = viewItem.interaction.timestampForUI; uint64_t viewItemTimestamp = viewItem.interaction.timestamp;
OWSAssertDebug(viewItemTimestamp > 0); OWSAssertDebug(viewItemTimestamp > 0);
BOOL shouldShowDate = NO; BOOL shouldShowDate = NO;
@ -1225,7 +1225,7 @@ NS_ASSUME_NONNULL_BEGIN
NSAttributedString *_Nullable senderName = nil; NSAttributedString *_Nullable senderName = nil;
OWSInteractionType interactionType = viewItem.interaction.interactionType; OWSInteractionType interactionType = viewItem.interaction.interactionType;
NSString *timestampText = [DateUtil formatTimestampShort:viewItem.interaction.timestampForUI]; NSString *timestampText = [DateUtil formatTimestampShort:viewItem.interaction.timestamp];
if (interactionType == OWSInteractionType_OutgoingMessage) { if (interactionType == OWSInteractionType_OutgoingMessage) {
TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)viewItem.interaction; TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)viewItem.interaction;

@ -12,8 +12,6 @@ NS_ASSUME_NONNULL_BEGIN
@interface TSIncomingMessage : TSMessage <OWSReadTracking> @interface TSIncomingMessage : TSMessage <OWSReadTracking>
@property (nonatomic, readonly, nullable) NSNumber *serverTimestamp;
@property (nonatomic, readonly) BOOL wasReceivedByUD; @property (nonatomic, readonly) BOOL wasReceivedByUD;
@property (nonatomic, readonly) BOOL isUserMentioned; @property (nonatomic, readonly) BOOL isUserMentioned;

@ -38,9 +38,6 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value);
@property (nonatomic, readonly) uint64_t timestamp; @property (nonatomic, readonly) uint64_t timestamp;
@property (nonatomic, readonly) uint64_t sortId; @property (nonatomic, readonly) uint64_t sortId;
@property (nonatomic, readonly) uint64_t receivedAtTimestamp; @property (nonatomic, readonly) uint64_t receivedAtTimestamp;
@property (nonatomic, readonly) BOOL shouldUseServerTime;
- (uint64_t)timestampForUI;
- (NSDate *)dateForUI; - (NSDate *)dateForUI;
@ -80,6 +77,8 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value);
- (void)saveNextSortIdWithTransaction:(YapDatabaseReadWriteTransaction *)transaction - (void)saveNextSortIdWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
NS_SWIFT_NAME(saveNextSortId(transaction:)); NS_SWIFT_NAME(saveNextSortId(transaction:));
- (void)updateTimestamp:(uint64_t)timestamp;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

@ -165,17 +165,6 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
#pragma mark Date operations #pragma mark Date operations
- (uint64_t)timestampForUI
{
// We always want to show the sent timestamp. In the case of one-on-one, closed group and V2 open group messages we get
// this from the protobuf. In the case of V1 open group messages we get it from the envelope in which the message is
// wrapped, which gets parsed to `serverTimestamp` in that case.
if ([self isKindOfClass:TSIncomingMessage.class] && ((TSIncomingMessage *)self).isOpenGroupMessage && ((TSIncomingMessage *)self).serverTimestamp != nil) {
return ((TSIncomingMessage *)self).serverTimestamp.unsignedLongLongValue;
}
return _timestamp;
}
- (uint64_t)timestampForLegacySorting - (uint64_t)timestampForLegacySorting
{ {
return self.timestamp; return self.timestamp;
@ -183,7 +172,7 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
- (NSDate *)dateForUI - (NSDate *)dateForUI
{ {
return [NSDate ows_dateWithMillisecondsSince1970:self.timestampForUI]; return [NSDate ows_dateWithMillisecondsSince1970:self.timestamp];
} }
- (NSDate *)receivedAtDate - (NSDate *)receivedAtDate
@ -229,12 +218,6 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
- (uint64_t)sortId - (uint64_t)sortId
{ {
// We always want to sort on the sent timestamp. In the case of one-on-one, closed group and V2 open group messages we get
// this from the protobuf. In the case of V1 open group messages we get it from the envelope in which the message is
// wrapped, which gets parsed to `serverTimestamp` in that case.
if ([self isKindOfClass:TSIncomingMessage.class] && ((TSIncomingMessage *)self).isOpenGroupMessage && ((TSIncomingMessage *)self).serverTimestamp != nil) {
return ((TSIncomingMessage *)self).serverTimestamp.unsignedLongLongValue;
}
return self.timestamp; return self.timestamp;
} }
@ -280,6 +263,12 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
[self saveWithTransaction:transaction]; [self saveWithTransaction:transaction];
} }
- (void)updateTimestamp:(uint64_t)timestamp
{
_timestamp = timestamp;
}
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

@ -73,7 +73,6 @@ public final class OpenGroupPollerV2 : NSObject {
let envelope = SNProtoEnvelope.builder(type: .sessionMessage, timestamp: message.sentTimestamp) let envelope = SNProtoEnvelope.builder(type: .sessionMessage, timestamp: message.sentTimestamp)
envelope.setContent(data) envelope.setContent(data)
envelope.setSource(message.sender!) // Safe because messages with a nil sender are filtered out envelope.setSource(message.sender!) // Safe because messages with a nil sender are filtered out
envelope.setServerTimestamp(message.sentTimestamp)
do { do {
let data = try envelope.buildSerializedData() let data = try envelope.buildSerializedData()
let (message, proto) = try MessageReceiver.parse(data, openGroupMessageServerID: UInt64(message.serverID!), isRetry: false, using: transaction) let (message, proto) = try MessageReceiver.parse(data, openGroupMessageServerID: UInt64(message.serverID!), isRetry: false, using: transaction)

Loading…
Cancel
Save