diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/RefreshOwnProfileJob.java b/app/src/main/java/org/thoughtcrime/securesms/jobs/RefreshOwnProfileJob.java index 7ea869d21c..ae89883784 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/RefreshOwnProfileJob.java +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/RefreshOwnProfileJob.java @@ -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); } diff --git a/app/src/main/java/org/thoughtcrime/securesms/recipients/RecipientUtil.java b/app/src/main/java/org/thoughtcrime/securesms/recipients/RecipientUtil.java index 13656db383..db4eb0a098 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/recipients/RecipientUtil.java +++ b/app/src/main/java/org/thoughtcrime/securesms/recipients/RecipientUtil.java @@ -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); diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/ProfileUtil.java b/app/src/main/java/org/thoughtcrime/securesms/util/ProfileUtil.java index 71dafa54fc..31ca848756 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/ProfileUtil.java +++ b/app/src/main/java/org/thoughtcrime/securesms/util/ProfileUtil.java @@ -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();