Ensure notifications for new users won't be generated first fetch

This commit is contained in:
Moxie Marlinspike
2017-11-21 11:54:18 -08:00
parent 66e1be1aeb
commit f855e161d9
11 changed files with 36 additions and 19 deletions

View File

@@ -21,22 +21,25 @@ public class DirectoryRefreshJob extends ContextJob {
@Nullable private transient Recipient recipient;
@Nullable private transient MasterSecret masterSecret;
private transient boolean notifyOfNewUsers;
public DirectoryRefreshJob(@NonNull Context context) {
this(context, null, null);
public DirectoryRefreshJob(@NonNull Context context, boolean notifyOfNewUsers) {
this(context, null, null, notifyOfNewUsers);
}
public DirectoryRefreshJob(@NonNull Context context,
@Nullable MasterSecret masterSecret,
@Nullable Recipient recipient)
@Nullable Recipient recipient,
boolean notifyOfNewUsers)
{
super(context, JobParameters.newBuilder()
.withGroupId(DirectoryRefreshJob.class.getSimpleName())
.withRequirement(new NetworkRequirement(context))
.create());
this.recipient = recipient;
this.masterSecret = masterSecret;
this.recipient = recipient;
this.masterSecret = masterSecret;
this.notifyOfNewUsers = notifyOfNewUsers;
}
@Override
@@ -51,7 +54,7 @@ public class DirectoryRefreshJob extends ContextJob {
try {
wakeLock.acquire();
if (recipient == null) {
DirectoryHelper.refreshDirectory(context, KeyCachingService.getMasterSecret(context));
DirectoryHelper.refreshDirectory(context, KeyCachingService.getMasterSecret(context), notifyOfNewUsers);
} else {
DirectoryHelper.refreshDirectoryFor(context, masterSecret, recipient);
}

View File

@@ -75,7 +75,7 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
Log.w(TAG, ifae);
database.markAsPendingInsecureSmsFallback(messageId);
notifyMediaMessageDeliveryFailed(context, messageId);
ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context));
ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context, false));
} catch (UntrustedIdentityException uie) {
Log.w(TAG, uie);
database.addMismatchedIdentity(messageId, Address.fromSerialized(uie.getE164Number()), uie.getIdentityKey());

View File

@@ -29,7 +29,7 @@ public abstract class PushReceivedJob extends ContextJob {
if (!isActiveNumber(recipient)) {
DatabaseFactory.getRecipientDatabase(context).setRegistered(recipient, RecipientDatabase.RegisteredState.REGISTERED);
ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context, KeyCachingService.getMasterSecret(context), recipient));
ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context, KeyCachingService.getMasterSecret(context), recipient, false));
}
if (envelope.isReceipt()) {

View File

@@ -66,7 +66,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
Log.w(TAG, e);
database.markAsPendingInsecureSmsFallback(record.getId());
MessageNotifier.notifyMessageDeliveryFailed(context, record.getRecipient(), record.getThreadId());
ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context));
ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context, false));
} catch (UntrustedIdentityException e) {
Log.w(TAG, e);
database.addMismatchedIdentity(record.getId(), Address.fromSerialized(e.getE164Number()), e.getIdentityKey());