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()); 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); SignalServiceContent content = cipher.decrypt(envelope);
if (shouldIgnore(content)) { if (shouldIgnore(content)) {

View file

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

View file

@ -1220,6 +1220,14 @@ public class TextSecurePreferences {
public static boolean needsRevocationCheck(Context context) { public static boolean needsRevocationCheck(Context context) {
return getBooleanPreference(context, "needs_revocation", false); 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 // endregion
public static void clearAll(Context context) { public static void clearAll(Context context) {