Ignore any friend requests that were made before we restored our device.

pull/71/head
Mikunj 5 years ago
parent 5301858c09
commit 8a57632ced

@ -407,6 +407,9 @@ final class SeedVC : OnboardingBaseViewController, DeviceLinkingModalDelegate, O
self.setUserInteractionEnabled(true)
}
} else {
if (mode == .restore) {
OWSPrimaryStorage.shared().setRestorationTime(Date().timeIntervalSince1970)
}
onboardingController.pushDisplayNameVC(from: self)
}
}

@ -36,6 +36,11 @@ NS_ASSUME_NONNULL_BEGIN
- (void)setIDForMessageWithServerID:(NSUInteger)serverID to:(NSString *)messageID in:(YapDatabaseReadWriteTransaction *)transaction;
- (NSString *_Nullable)getIDForMessageWithServerID:(NSUInteger)serverID in:(YapDatabaseReadTransaction *)transaction;
# pragma mark - Restoration
- (void)setRestorationTime:(NSTimeInterval)time;
- (NSTimeInterval)getRestorationTime;
@end
NS_ASSUME_NONNULL_END

@ -175,4 +175,16 @@
return [transaction objectForKey:key inCollection:LKMessageIDCollection];
}
# pragma mark - Restoration
#define LKGeneralCollection @"Loki"
- (void)setRestorationTime:(NSTimeInterval)time {
[self.dbReadWriteConnection setDouble:time forKey:@"restoration_time" inCollection:LKGeneralCollection];
}
- (NSTimeInterval)getRestorationTime {
return [self.dbReadConnection doubleForKey:@"restoration_time" inCollection:LKGeneralCollection defaultValue:0];
}
@end

@ -10,7 +10,7 @@
#import "OWSBackgroundTask.h"
#import "OWSBatchMessageProcessor.h"
#import "OWSMessageDecrypter.h"
#import "OWSPrimaryStorage.h"
#import "OWSPrimaryStorage+Loki.h"
#import "OWSQueues.h"
#import "OWSStorage.h"
#import "OWSIdentityManager.h"
@ -404,6 +404,16 @@ NSString *const OWSMessageDecryptJobFinderExtensionGroup = @"OWSMessageProcessin
return;
}
// Loki: Ignore any friend requests that we got before restoration
uint64_t restorationTime = [NSNumber numberWithDouble:[OWSPrimaryStorage.sharedManager getRestorationTime]].unsignedLongLongValue;
if (envelope.type == SSKProtoEnvelopeTypeFriendRequest && envelope.timestamp < restorationTime * 1000) {
OWSLogDebug(@"Ignoring friend request that was received before restoration.");
dispatch_async(self.serialQueue, ^{
completion(YES);
});
return;
}
// We use the original envelope for this check;
// the decryption process might rewrite the envelope.
BOOL wasReceivedByUD = [self wasReceivedByUD:envelope];

Loading…
Cancel
Save