Fix retry issues with RotateProfileKeyJob.
This commit is contained in:
parent
5468f1705c
commit
6a9476c6d0
3 changed files with 12 additions and 20 deletions
|
@ -19,6 +19,8 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
|||
import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
||||
import org.whispersystems.signalservice.api.util.StreamDetails;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class ProfileUploadJob extends BaseJob {
|
||||
|
||||
private static final String TAG = Log.tag(ProfileUploadJob.class);
|
||||
|
@ -34,9 +36,9 @@ public final class ProfileUploadJob extends BaseJob {
|
|||
this(new Job.Parameters.Builder()
|
||||
.addConstraint(NetworkConstraint.KEY)
|
||||
.setQueue(QUEUE)
|
||||
.setLifespan(Parameters.IMMORTAL)
|
||||
.setLifespan(TimeUnit.DAYS.toMillis(30))
|
||||
.setMaxAttempts(Parameters.UNLIMITED)
|
||||
.setMaxInstances(1)
|
||||
.setMaxInstances(2)
|
||||
.build());
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ public class RefreshAttributesJob extends BaseJob {
|
|||
this(new Job.Parameters.Builder()
|
||||
.addConstraint(NetworkConstraint.KEY)
|
||||
.setQueue("RefreshAttributesJob")
|
||||
.setMaxInstances(2)
|
||||
.build());
|
||||
}
|
||||
|
||||
|
|
|
@ -26,9 +26,7 @@ public class RotateProfileKeyJob extends BaseJob {
|
|||
public RotateProfileKeyJob() {
|
||||
this(new Job.Parameters.Builder()
|
||||
.setQueue("__ROTATE_PROFILE_KEY__")
|
||||
.addConstraint(NetworkConstraint.KEY)
|
||||
.setMaxAttempts(25)
|
||||
.setMaxInstances(1)
|
||||
.setMaxInstances(2)
|
||||
.build());
|
||||
}
|
||||
|
||||
|
@ -47,21 +45,13 @@ public class RotateProfileKeyJob extends BaseJob {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onRun() throws Exception {
|
||||
SignalServiceAccountManager accountManager = ApplicationDependencies.getSignalServiceAccountManager();
|
||||
RecipientDatabase recipientDatabase = DatabaseFactory.getRecipientDatabase(context);
|
||||
ProfileKey profileKey = ProfileKeyUtil.createNew();
|
||||
Recipient self = Recipient.self();
|
||||
public void onRun() {
|
||||
ProfileKey newProfileKey = ProfileKeyUtil.createNew();
|
||||
Recipient self = Recipient.self();
|
||||
|
||||
recipientDatabase.setProfileKey(self.getId(), profileKey);
|
||||
|
||||
try (StreamDetails avatarStream = AvatarHelper.getSelfProfileAvatarStream(context)) {
|
||||
accountManager.setVersionedProfile(self.getUuid().get(),
|
||||
profileKey,
|
||||
Recipient.self().getProfileName().serialize(),
|
||||
avatarStream);
|
||||
}
|
||||
DatabaseFactory.getRecipientDatabase(context).setProfileKey(self.getId(), newProfileKey);
|
||||
|
||||
ApplicationDependencies.getJobManager().add(new ProfileUploadJob());
|
||||
ApplicationDependencies.getJobManager().add(new RefreshAttributesJob());
|
||||
|
||||
updateProfileKeyOnAllV2Groups();
|
||||
|
@ -77,12 +67,11 @@ public class RotateProfileKeyJob extends BaseJob {
|
|||
|
||||
@Override
|
||||
public void onFailure() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onShouldRetry(@NonNull Exception exception) {
|
||||
return exception instanceof PushNetworkException;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static final class Factory implements Job.Factory<RotateProfileKeyJob> {
|
||||
|
|
Loading…
Add table
Reference in a new issue