use server timestamp to show the message time in open groups

pull/256/head
Ryan ZHAO 5 years ago
parent 2f8acd0779
commit af7a58cc1f

@ -174,6 +174,7 @@ public final class PublicChatPoller : NSObject {
envelope.setSource(senderPublicKey)
envelope.setSourceDevice(OWSDevicePrimaryDeviceId)
envelope.setContent(try! content.build().serializedData())
envelope.setServerTimestamp(message.serverTimestamp)
try! Storage.writeSync { transaction in
transaction.setObject(senderDisplayName, forKey: senderPublicKey, inCollection: publicChat.id)
let messageServerID = message.serverID

@ -42,6 +42,10 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value);
/// Used for public chats where a message sent from a slave device is interpreted as having been sent from the master device.
@property (nonatomic) NSString *actualSenderHexEncodedPublicKey;
- (void)setServerTimestampAsReceiveTimestamp:(uint64_t)receivedAtTimestamp;
- (uint64_t)timestamp;
- (NSDate *)receivedAtDate;
- (OWSInteractionType)interactionType;

@ -41,6 +41,8 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
@implementation TSInteraction
@synthesize timestamp = _timestamp;
+ (NSArray<TSInteraction *> *)interactionsWithTimestamp:(uint64_t)timestamp
ofClass:(Class)clazz
withTransaction:(YapDatabaseReadTransaction *)transaction
@ -175,11 +177,27 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
#pragma mark Date operations
- (uint64_t)timestamp
{
if (self.thread.isGroupThread) {
TSGroupThread *thread = (TSGroupThread *)self.thread;
if (thread.isPublicChat) {
return _receivedAtTimestamp;
}
}
return _timestamp;
}
- (uint64_t)timestampForLegacySorting
{
return self.timestamp;
}
- (void)setServerTimestampAsReceiveTimestamp:(uint64_t)receivedAtTimestamp
{
_receivedAtTimestamp = receivedAtTimestamp;
}
- (NSDate *)receivedAtDate
{
return [NSDate ows_dateWithMillisecondsSince1970:self.receivedAtTimestamp];

@ -1417,6 +1417,11 @@ NS_ASSUME_NONNULL_BEGIN
serverTimestamp:serverTimestamp
wasReceivedByUD:wasReceivedByUD];
//For open group messages, use server timestamp as the receive timestamp
if (oldGroupThread.isPublicChat) {
[incomingMessage setServerTimestampAsReceiveTimestamp:(uint64_t)envelope.serverTimestamp];
}
// Loki: Set open group server ID if needed
if (dataMessage.publicChatInfo != nil && dataMessage.publicChatInfo.hasServerID) {
incomingMessage.openGroupServerMessageID = dataMessage.publicChatInfo.serverID;

Loading…
Cancel
Save