Clean up RetrieveProfileAvatarJob

This commit is contained in:
Niels Andriesse 2021-05-14 10:56:47 +10:00
parent 43c5fce526
commit 446ff908ba

View File

@ -1,6 +1,5 @@
package org.thoughtcrime.securesms.jobs; package org.thoughtcrime.securesms.jobs;
import android.app.Application; import android.app.Application;
import android.text.TextUtils; import android.text.TextUtils;
@ -39,7 +38,7 @@ public class RetrieveProfileAvatarJob extends BaseJob implements InjectableType
private static final String TAG = RetrieveProfileAvatarJob.class.getSimpleName(); private static final String TAG = RetrieveProfileAvatarJob.class.getSimpleName();
private static final int MAX_PROFILE_SIZE_BYTES = 20 * 1024 * 1024; private static final int MAX_PROFILE_SIZE_BYTES = 10 * 1024 * 1024;
private static final String KEY_PROFILE_AVATAR = "profile_avatar"; private static final String KEY_PROFILE_AVATAR = "profile_avatar";
private static final String KEY_ADDRESS = "address"; private static final String KEY_ADDRESS = "address";
@ -51,18 +50,17 @@ public class RetrieveProfileAvatarJob extends BaseJob implements InjectableType
public RetrieveProfileAvatarJob(Recipient recipient, String profileAvatar) { public RetrieveProfileAvatarJob(Recipient recipient, String profileAvatar) {
this(new Job.Parameters.Builder() this(new Job.Parameters.Builder()
.setQueue("RetrieveProfileAvatarJob" + recipient.getAddress().serialize()) .setQueue("RetrieveProfileAvatarJob" + recipient.getAddress().serialize())
.addConstraint(NetworkConstraint.KEY) .addConstraint(NetworkConstraint.KEY)
.setLifespan(TimeUnit.HOURS.toMillis(1)) .setLifespan(TimeUnit.HOURS.toMillis(1))
.setMaxAttempts(3) .setMaxAttempts(10)
.build(), .build(),
recipient, recipient,
profileAvatar); profileAvatar);
} }
private RetrieveProfileAvatarJob(@NonNull Job.Parameters parameters, @NonNull Recipient recipient, String profileAvatar) { private RetrieveProfileAvatarJob(@NonNull Job.Parameters parameters, @NonNull Recipient recipient, String profileAvatar) {
super(parameters); super(parameters);
this.recipient = recipient; this.recipient = recipient;
this.profileAvatar = profileAvatar; this.profileAvatar = profileAvatar;
} }
@ -70,9 +68,10 @@ public class RetrieveProfileAvatarJob extends BaseJob implements InjectableType
@Override @Override
public @NonNull public @NonNull
Data serialize() { Data serialize() {
return new Data.Builder().putString(KEY_PROFILE_AVATAR, profileAvatar) return new Data.Builder()
.putString(KEY_ADDRESS, recipient.getAddress().serialize()) .putString(KEY_PROFILE_AVATAR, profileAvatar)
.build(); .putString(KEY_ADDRESS, recipient.getAddress().serialize())
.build();
} }
@Override @Override