Merge branch 'master' of github.com:loki-project/loki-messenger-ios

pull/14/head
Niels Andriesse 6 years ago
commit 38d2fbfbeb

@ -1 +1 @@
Subproject commit aa0882607c603f6ef576c9538e2f6481d09fd0ce Subproject commit 93c439b844c98a76a0785c5f9529966c8c076f18

@ -88,18 +88,7 @@ typedef void (^BuildOutgoingMessageCompletionBlock)(TSOutgoingMessage *savedMess
// Loki: TODO We may change this? // Loki: TODO We may change this?
+ (TSOutgoingMessage *)enqueueFriendRequestAcceptMessageInThread:(TSThread *)thread + (TSOutgoingMessage *)enqueueFriendRequestAcceptMessageInThread:(TSThread *)thread
{ {
TSOutgoingMessage *message = TSOutgoingMessage *message = [TSOutgoingMessage emptyOutgoingMessageInThread:thread];
[[TSOutgoingMessage alloc] initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:thread
messageBody:@""
attachmentIds:[NSMutableArray new]
expiresInSeconds:0
expireStartedAt:0
isVoiceMessage:NO
groupMetaMessage:TSGroupMetaMessageUnspecified
quotedMessage:nil
contactShare:nil
linkPreview:nil];
[self.dbConnection asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { [self.dbConnection asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[self.messageSenderJobQueue addMessage:message transaction:transaction]; [self.messageSenderJobQueue addMessage:message transaction:transaction];
}]; }];

@ -37,8 +37,8 @@ public extension LokiAPI {
let destination = signalMessage["destination"] as! String let destination = signalMessage["destination"] as! String
let ttl = LokiAPI.defaultMessageTTL let ttl = LokiAPI.defaultMessageTTL
if isPoWRequired { if isPoWRequired {
// timeIntervalSince1970 returns a time interval in seconds but the storage server takes a time interval in milliseconds // Storage server takes a time interval in milliseconds
let now = UInt64(Date().timeIntervalSince1970 * 1000) let now = NSDate.ows_millisecondTimeStamp()
if let nonce = ProofOfWork.calculate(data: data, pubKey: destination, timestamp: now, ttl: ttl) { if let nonce = ProofOfWork.calculate(data: data, pubKey: destination, timestamp: now, ttl: ttl) {
let result = Message(destination: destination, data: data, ttl: ttl, timestamp: now, nonce: nonce) let result = Message(destination: destination, data: data, ttl: ttl, timestamp: now, nonce: nonce)
seal.fulfill(result) seal.fulfill(result)

@ -0,0 +1,17 @@
public extension TSOutgoingMessage {
/// Loki: This is a message used to establish sessions
@objc public static func emptyOutgoingMessage(inThread thread: TSThread) -> TSOutgoingMessage {
return TSOutgoingMessage(outgoingMessageWithTimestamp: NSDate.ows_millisecondTimeStamp(),
in: thread,
messageBody: "",
attachmentIds: [],
expiresInSeconds: 0,
expireStartedAt: 0,
isVoiceMessage: false,
groupMetaMessage: .unspecified,
quotedMessage: nil,
contactShare: nil,
linkPreview: nil)
}
}
Loading…
Cancel
Save