session-ios/Signal/src/textsecure/Messages/TSIncomingMessage.m
Frederic Jacobs 7aad5c5971 Fixing UX issue with unsynchronized clocks.
TextSecure messages don’t get assigned a timestamp by the server. All
of it is done end-to-end between both clients. A client could have a
misconfigured clock or might want to forge a timestamp. Therefore, we
address this issue by introducing a new receivedAt timestamp for
incoming messages that will be used to sort the messages.
2015-02-28 15:27:56 +01:00

47 lines
1.2 KiB
Objective-C

//
// TSIncomingMessage.m
// TextSecureKit
//
// Created by Frederic Jacobs on 15/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import "TSIncomingMessage.h"
@implementation TSIncomingMessage
- (instancetype)initWithTimestamp:(uint64_t)timestamp
inThread:(TSGroupThread*)thread
authorId:(NSString*)authorId
messageBody:(NSString*)body
attachments:(NSArray *)attachments
{
self = [super initWithTimestamp:timestamp inThread:thread messageBody:body attachments:attachments];
if (self) {
_authorId = authorId;
_read = NO;
_receivedAt = [NSDate date];
}
return self;
}
- (instancetype)initWithTimestamp:(uint64_t)timestamp
inThread:(TSContactThread *)thread
messageBody:(NSString *)body
attachments:(NSArray *)attachments
{
self = [super initWithTimestamp:timestamp inThread:thread messageBody:body attachments:attachments];
if (self) {
_authorId = nil;
_read = NO;
_receivedAt = [NSDate date];
}
return self;
}
@end