Save prekey bundle from content message.

This commit is contained in:
Mikunj 2019-05-13 12:19:05 +10:00 committed by Mikunj Varsani
parent ea7205ce76
commit 8fff98d94e
2 changed files with 23 additions and 1 deletions

View File

@ -1,5 +1,17 @@
public extension SSKProtoPrekeyBundleMessage {
@objc public var preKeyBundle: PreKeyBundle? {
let registrationId = TSAccountManager.sharedInstance().getOrGenerateRegistrationId()
return PreKeyBundle(registrationId: Int32(registrationId),
deviceId: Int32(self.deviceID),
preKeyId: Int32(self.prekeyID),
preKeyPublic: self.prekey,
signedPreKeyPublic: self.signedKey,
signedPreKeyId: Int32(self.signedKeyID),
signedPreKeySignature: self.signature,
identityKey: self.identityKey)
}
@objc public class func builder(fromPreKeyBundle preKeyBundle: PreKeyBundle) -> SSKProtoPrekeyBundleMessageBuilder {
let builder = self.builder()
@ -12,5 +24,4 @@ public extension SSKProtoPrekeyBundleMessage {
return builder
}
}

View File

@ -26,6 +26,7 @@
#import "OWSMessageUtils.h"
#import "OWSOutgoingReceiptManager.h"
#import "OWSPrimaryStorage+SessionStore.h"
#import "OWSPrimaryStorage+Loki.h"
#import "OWSPrimaryStorage.h"
#import "OWSReadReceiptManager.h"
#import "OWSRecordTranscriptJob.h"
@ -411,6 +412,16 @@ NS_ASSUME_NONNULL_BEGIN
return;
}
OWSLogInfo(@"handling content: <Content: %@>", [self descriptionForContent:contentProto]);
// Loki: Handle PreKeyBundle message
if (contentProto.prekeyBundleMessage) {
OWSLogInfo(@"Received a prekey bundle message from: %@", envelope.source);
PreKeyBundle *_Nullable bundle = contentProto.prekeyBundleMessage.preKeyBundle;
if (!bundle) {
OWSFailDebug(@"Failed to create PreKeyBundle from message");
}
[[OWSPrimaryStorage sharedManager] setPreKeyBundle:bundle forContact:envelope.source];
}
if (contentProto.syncMessage) {
[self throws_handleIncomingEnvelope:envelope