fix: profile avatar fixes for local user now that we aren't setting local user profile key

This commit is contained in:
0x330a 2023-04-06 10:32:54 +10:00
parent 72982c6ea4
commit 3f569e3403
No known key found for this signature in database
GPG Key ID: 267811D6E6A2698C
1 changed files with 14 additions and 1 deletions

View File

@ -14,6 +14,7 @@ import org.session.libsession.utilities.Util;
import org.session.libsession.utilities.recipients.Recipient;
import org.session.libsignal.exceptions.PushNetworkException;
import org.session.libsignal.streams.ProfileCipherInputStream;
import org.session.libsignal.utilities.Base64;
import org.session.libsignal.utilities.Log;
import org.thoughtcrime.securesms.database.RecipientDatabase;
import org.thoughtcrime.securesms.dependencies.DatabaseComponent;
@ -78,7 +79,19 @@ public class RetrieveProfileAvatarJob extends BaseJob {
@Override
public void onRun() throws IOException {
RecipientDatabase database = DatabaseComponent.get(context).recipientDatabase();
byte[] profileKey = recipient.resolve().getProfileKey();
byte[] profileKey = null;
if (recipient.resolve().isLocalNumber()) {
try {
String encodedProfileKey = TextSecurePreferences.getProfileKey(context);
if (encodedProfileKey != null) {
profileKey = Base64.decode(encodedProfileKey);
}
} catch (Exception e) {
Log.e(TAG, "Failed to decode local user profile key", e);
}
} else {
profileKey = recipient.resolve().getProfileKey();
}
if (profileKey == null || (profileKey.length != 32 && profileKey.length != 16)) {
Log.w(TAG, "Recipient profile key is gone!");