mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-03 21:32:19 +00:00
Ensure notifications for new users won't be generated first fetch
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user