mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
46 lines
1.4 KiB
Objective-C
46 lines
1.4 KiB
Objective-C
//
|
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
|
//
|
|
|
|
#import "OWSLinkedDeviceReadReceipt.h"
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
@implementation OWSLinkedDeviceReadReceipt
|
|
|
|
- (instancetype)initWithSenderId:(NSString *)senderId timestamp:(uint64_t)timestamp;
|
|
{
|
|
OWSAssert(senderId.length > 0 && timestamp > 0);
|
|
|
|
self = [super initWithUniqueId:[OWSLinkedDeviceReadReceipt uniqueIdForSenderId:senderId timestamp:timestamp]];
|
|
if (!self) {
|
|
return self;
|
|
}
|
|
|
|
_senderId = senderId;
|
|
_timestamp = timestamp;
|
|
|
|
return self;
|
|
}
|
|
|
|
+ (NSString *)uniqueIdForSenderId:(NSString *)senderId timestamp:(uint64_t)timestamp
|
|
{
|
|
OWSAssert(senderId.length > 0 && timestamp > 0);
|
|
|
|
return [NSString stringWithFormat:@"%@-%llu", senderId, timestamp];
|
|
}
|
|
|
|
+ (nullable OWSLinkedDeviceReadReceipt *)findLinkedDeviceReadReceiptWithSenderId:(NSString *)senderId
|
|
timestamp:(uint64_t)timestamp
|
|
transaction:
|
|
(YapDatabaseReadTransaction *)transaction
|
|
{
|
|
OWSAssert(transaction);
|
|
|
|
return [OWSLinkedDeviceReadReceipt fetchObjectWithUniqueID:[self uniqueIdForSenderId:senderId timestamp:timestamp]
|
|
transaction:transaction];
|
|
}
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|