diff --git a/SignalServiceKit/src/Loki/API/LokiAPI+Message.swift b/SignalServiceKit/src/Loki/API/LokiAPI+Message.swift index 95f12f771..3abc5bd73 100644 --- a/SignalServiceKit/src/Loki/API/LokiAPI+Message.swift +++ b/SignalServiceKit/src/Loki/API/LokiAPI+Message.swift @@ -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. /// diff --git a/SignalServiceKit/src/Messages/Interactions/TSOutgoingMessage.h b/SignalServiceKit/src/Messages/Interactions/TSOutgoingMessage.h index 25ca6539b..598b30fa2 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSOutgoingMessage.h +++ b/SignalServiceKit/src/Messages/Interactions/TSOutgoingMessage.h @@ -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; /** diff --git a/SignalServiceKit/src/Messages/OWSMessageSender.m b/SignalServiceKit/src/Messages/OWSMessageSender.m index c685f66fb..a89d90664 100644 --- a/SignalServiceKit/src/Messages/OWSMessageSender.m +++ b/SignalServiceKit/src/Messages/OWSMessageSender.m @@ -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; diff --git a/SignalServiceKit/src/Messages/OWSMessageServiceParams.h b/SignalServiceKit/src/Messages/OWSMessageServiceParams.h index 55a335069..3a8dc25c9 100644 --- a/SignalServiceKit/src/Messages/OWSMessageServiceParams.h +++ b/SignalServiceKit/src/Messages/OWSMessageServiceParams.h @@ -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 diff --git a/SignalServiceKit/src/Messages/OWSMessageServiceParams.m b/SignalServiceKit/src/Messages/OWSMessageServiceParams.m index 16eeb684e..cfd88bd3e 100644 --- a/SignalServiceKit/src/Messages/OWSMessageServiceParams.m +++ b/SignalServiceKit/src/Messages/OWSMessageServiceParams.m @@ -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; }