Fix ttl not being set in friend requests.

This commit is contained in:
Mikunj 2019-05-22 13:24:13 +10:00
parent b5cc66262d
commit 8c8f6231a5
5 changed files with 15 additions and 11 deletions

View file

@ -7,7 +7,7 @@ public extension LokiAPI {
let destination: String
/// The content of the message.
let data: LosslessStringConvertible
/// The time to live for the message.
/// The time to live for the message in seconds.
let ttl: UInt64
/// When the proof of work was calculated, if applicable.
///

View file

@ -144,7 +144,7 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
// Loki: Bool to indicate if proof of work is being calculated for this message
@property (atomic, readonly) BOOL isCalculatingPoW;
// Loki: Time to live for the message
// Loki: Time to live for the message in seconds
@property (nonatomic, readonly) uint ttl;
/**

View file

@ -1773,6 +1773,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
SignalRecipient *recipient = messageSend.recipient;
NSString *recipientId = recipient.recipientId;
TSOutgoingMessage *message = messageSend.message;
FallBackSessionCipher *cipher = [[FallBackSessionCipher alloc] initWithRecipientId:recipientId identityKeyStore:self.identityManager];
@ -1790,7 +1791,8 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
content:serializedMessage
isSilent:false
isOnline:false
registrationId:0];
registrationId:0
ttl:message.ttl];
NSError *error;
NSDictionary *jsonDict = [MTLJSONAdapter JSONDictionaryFromModel:messageParams error:&error];
@ -1884,14 +1886,12 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
content:serializedMessage
isSilent:isSilent
isOnline:isOnline
registrationId:[cipher throws_remoteRegistrationId:transaction]];
// Loki: Add the ttl to the message params
messageParams.ttl = message.ttl;
registrationId:[cipher throws_remoteRegistrationId:transaction]
ttl:message.ttl];
NSError *error;
NSDictionary *jsonDict = [MTLJSONAdapter JSONDictionaryFromModel:messageParams error:&error];
if (error) {
OWSProdError([OWSAnalyticsEvents messageSendErrorCouldNotSerializeMessageJson]);
return nil;

View file

@ -23,7 +23,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) NSString *content;
@property (nonatomic, readonly) BOOL silent;
@property (nonatomic, readonly) BOOL online;
@property (nonatomic) uint ttl;
// Loki: Message ttl
@property (nonatomic, readonly) uint ttl;
- (instancetype)initWithType:(TSWhisperMessageType)type
recipientId:(NSString *)destination
@ -31,7 +33,8 @@ NS_ASSUME_NONNULL_BEGIN
content:(NSData *)content
isSilent:(BOOL)isSilent
isOnline:(BOOL)isOnline
registrationId:(int)registrationId;
registrationId:(int)registrationId
ttl:(uint)ttl;
@end

View file

@ -22,6 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
isSilent:(BOOL)isSilent
isOnline:(BOOL)isOnline
registrationId:(int)registrationId
ttl:(uint)ttl
{
self = [super init];
@ -36,7 +37,7 @@ NS_ASSUME_NONNULL_BEGIN
_content = [content base64EncodedString];
_silent = isSilent;
_online = isOnline;
_ttl = 0;
_ttl = ttl;
return self;
}