Review fixes.

pull/14/head
Mikunj 6 years ago
parent 38b698a531
commit e714d9b3ab

@ -30,13 +30,13 @@ public class CreatePreKeysOperation: OWSOperation {
/// Loki: We don't generate PreKeyRecords here.
/// This is because we need the records to be linked to a contact since we don't have a central server.
/// It is done automatically when we generate a PreKeyBundle to send to a contact (`generatePreKeyBundleForContact:`).
/// You can use `getPreKeyForContact:` to generate one if needed.
/// You can use `getOrCreatePreKeyForContact:` to generate one if needed.
let signedPreKeyRecord = self.primaryStorage.generateRandomSignedRecord()
signedPreKeyRecord.markAsAcceptedByService()
self.primaryStorage.storeSignedPreKey(signedPreKeyRecord.id, signedPreKeyRecord: signedPreKeyRecord)
self.primaryStorage.setCurrentSignedPrekeyId(signedPreKeyRecord.id)
Logger.debug("done")
Logger.debug("[CreatePreKeysOperation] done")
self.reportSuccess()
/* Loki: Original Code

@ -52,7 +52,7 @@ public class RefreshPreKeysOperation: OWSOperation {
TSPreKeyManager.clearPreKeyUpdateFailureCount()
TSPreKeyManager.clearSignedPreKeyRecords()
Logger.debug("done")
Logger.debug("[PreKeyRefreshOperation] done")
self.reportSuccess()
}

@ -37,7 +37,7 @@ public class RotateSignedPreKeyOperation: OWSOperation {
TSPreKeyManager.clearPreKeyUpdateFailureCount()
TSPreKeyManager.clearSignedPreKeyRecords()
Logger.debug("done")
Logger.debug("[RotateSignedKeyOperation] done")
self.reportSuccess()
}

@ -18,12 +18,12 @@ NS_ASSUME_NONNULL_BEGIN
/**
Get the PreKeyRecord associated with the given contact.
If the record doesn't exist then this will generate a new one.
If the record doesn't exist then this will create a new one.
@param pubKey The hex encoded public key of the contact.
@return The record associated with the contact.
*/
- (PreKeyRecord *)getPreKeyForContact:(NSString *)pubKey;
- (PreKeyRecord *)getOrCreatePreKeyForContact:(NSString *)pubKey;
# pragma mark - PreKeyBundle

@ -20,12 +20,12 @@
return preKeyId > 0;
}
- (PreKeyRecord *)getPreKeyForContact:(NSString *)pubKey {
- (PreKeyRecord *)getOrCreatePreKeyForContact:(NSString *)pubKey {
OWSAssertDebug(pubKey.length > 0);
int preKeyId = [self.dbReadWriteConnection intForKey:pubKey inCollection:LokiPreKeyContactCollection];
// If we don't have an id then generate and store a new one
if (preKeyId < 1) {
if (preKeyId <= 0) {
return [self generateAndStorePreKeyForContact:pubKey];
}
@ -46,7 +46,7 @@
[self storePreKeyRecords:records];
OWSAssertDebug(records.count > 0);
PreKeyRecord *record = [records firstObject];
PreKeyRecord *record = records.firstObject;
[self.dbReadWriteConnection setInt:record.Id forKey:pubKey inCollection:LokiPreKeyContactCollection];
return record;
@ -58,7 +58,7 @@
// Check prekeys to make sure we have them for this function
[TSPreKeyManager checkPreKeys];
ECKeyPair *_Nullable myKeyPair = [[OWSIdentityManager sharedManager] identityKeyPair];
ECKeyPair *_Nullable myKeyPair = OWSIdentityManager.sharedManager.identityKeyPair;
OWSAssertDebug(myKeyPair);
SignedPreKeyRecord *_Nullable signedPreKey = [self currentSignedPreKey];
@ -66,8 +66,8 @@
OWSFailDebug(@"Signed prekey is null");
}
PreKeyRecord *preKey = [self getPreKeyForContact:pubKey];
uint32_t registrationId = [[TSAccountManager sharedInstance] getOrGenerateRegistrationId];
PreKeyRecord *preKey = [self getOrCreatePreKeyForContact:pubKey];
uint32_t registrationId = [TSAccountManager.sharedInstance getOrGenerateRegistrationId];
PreKeyBundle *bundle = [[PreKeyBundle alloc] initWithRegistrationId:registrationId
deviceId:OWSDevicePrimaryDeviceId

Loading…
Cancel
Save