Ignore empty profile fetches in RefreshOwnProfileJob.

This commit is contained in:
Greyson Parrelli
2022-04-27 14:13:09 -04:00
parent 3f1abe05fc
commit 8bb1b2d596
3 changed files with 18 additions and 3 deletions

View File

@@ -114,6 +114,15 @@ public class RefreshOwnProfileJob extends BaseJob {
ProfileAndCredential profileAndCredential = ProfileUtil.retrieveProfileSync(context, self, getRequestType(self), false);
SignalServiceProfile profile = profileAndCredential.getProfile();
if (Util.isEmpty(profile.getName()) &&
Util.isEmpty(profile.getAvatar()) &&
Util.isEmpty(profile.getAbout()) &&
Util.isEmpty(profile.getAboutEmoji()))
{
Log.w(TAG, "The profile we retrieved was empty! Ignoring it.");
return;
}
setProfileName(profile.getName());
setProfileAbout(profile.getAbout(), profile.getAboutEmoji());
setProfileAvatar(profile.getAvatar());
@@ -155,8 +164,13 @@ public class RefreshOwnProfileJob extends BaseJob {
String plaintextName = ProfileUtil.decryptString(profileKey, encryptedName);
ProfileName profileName = ProfileName.fromSerialized(plaintextName);
Log.d(TAG, "Saving " + (!Util.isEmpty(plaintextName) ? "non-" : "") + "empty name.");
SignalDatabase.recipients().setProfileName(Recipient.self().getId(), profileName);
if (!profileName.isEmpty()) {
Log.d(TAG, "Saving non-empty name.");
SignalDatabase.recipients().setProfileName(Recipient.self().getId(), profileName);
} else {
Log.w(TAG, "Ignoring empty name.");
}
} catch (InvalidCiphertextException | IOException e) {
Log.w(TAG, e);
}

View File

@@ -151,6 +151,7 @@ public class RecipientUtil {
if (!isBlockable(recipient)) {
throw new AssertionError("Recipient is not blockable!");
}
Log.w(TAG, "Blocking " + recipient.getId() + " (group: " + recipient.isGroup() + ")");
recipient = recipient.resolve();
@@ -177,6 +178,7 @@ public class RecipientUtil {
if (!isBlockable(recipient)) {
throw new AssertionError("Recipient is not blockable!");
}
Log.i(TAG, "Unblocking " + recipient.getId() + " (group: " + recipient.isGroup() + ")");
SignalDatabase.recipients().setBlocked(recipient.getId(), false);
SignalDatabase.recipients().setProfileSharing(recipient.getId(), true);

View File

@@ -81,7 +81,6 @@ public final class ProfileUtil {
ApplicationDependencies.getJobManager()
.startChain(new RefreshAttributesJob())
.then(new ProfileUploadJob())
.then(new RefreshOwnProfileJob())
.then(new MultiDeviceProfileKeyUpdateJob())
.then(gv2UpdateJobs)
.enqueue();