Ignore friend request messages before restoration,

This commit is contained in:
Mikunj 2019-12-05 12:10:29 +11:00
parent fdba9023fc
commit e285ede03d
3 changed files with 17 additions and 0 deletions

View File

@ -281,6 +281,12 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
cipher.validateBackgroundMessage(envelope, envelope.getContent());
}
// Loki - Ignore any friend requests that we got before restoration
if (envelope.isFriendRequest() && envelope.getTimestamp() < TextSecurePreferences.getRestorationTime(context)) {
Log.i(TAG, "Ignoring friend request that was received before restoration");
return;
}
SignalServiceContent content = cipher.decrypt(envelope);
if (shouldIgnore(content)) {

View File

@ -206,6 +206,9 @@ class SeedActivity : BaseActionBarActivity(), DeviceLinkingDelegate, ScanListene
DatabaseFactory.getIdentityDatabase(this).saveIdentity(Address.fromSerialized(userHexEncodedPublicKey), keyPair.publicKey,
IdentityDatabase.VerifiedStatus.VERIFIED, true, System.currentTimeMillis(), true)
TextSecurePreferences.setLocalNumber(this, userHexEncodedPublicKey)
if (mode == Mode.Restore) {
TextSecurePreferences.setRestorationTime(this, System.currentTimeMillis())
}
when (mode) {
Mode.Register -> Analytics.shared.track("Seed Created")
Mode.Restore -> Analytics.shared.track("Seed Restored")

View File

@ -1220,6 +1220,14 @@ public class TextSecurePreferences {
public static boolean needsRevocationCheck(Context context) {
return getBooleanPreference(context, "needs_revocation", false);
}
public static void setRestorationTime(Context context, long time) {
setLongPreference(context, "restoration_time", time);
}
public static long getRestorationTime(Context context) {
return getLongPreference(context, "restoration_time", 0);
}
// endregion
public static void clearAll(Context context) {