Skip to content

Commit

Permalink
Translate missing recipients into unknown recipients.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Dec 21, 2024
1 parent 034e048 commit 47a5816
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ class GroupTable(context: Context?, databaseHelper: SignalDatabase?) : DatabaseT
recipientId = RecipientId.from(cursor.requireNonNullString(RECIPIENT_ID)),
title = cursor.requireString(TITLE),
serializedMembers = cursor.requireString(MEMBER_GROUP_CONCAT),
serializedUnmigratedV1Members = cursor.requireString(UNMIGRATED_V1_MEMBERS),
serializedUnmigratedV1Members = null,
avatarId = cursor.requireLong(AVATAR_ID),
avatarKey = cursor.requireBlob(AVATAR_KEY),
avatarContentType = cursor.requireString(AVATAR_CONTENT_TYPE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.thoughtcrime.securesms.database.GroupTable;
import org.thoughtcrime.securesms.database.RecipientTable;
import org.thoughtcrime.securesms.database.SignalDatabase;
import org.thoughtcrime.securesms.database.model.RecipientRecord;
import org.thoughtcrime.securesms.util.livedata.LiveDataUtil;

import java.util.Objects;
Expand Down Expand Up @@ -189,7 +190,15 @@ public void refresh(@NonNull RecipientId id) {
}

private @NonNull Recipient fetchAndCacheRecipientFromDisk(@NonNull RecipientId id) {
Recipient recipient = RecipientCreator.forRecord(context, recipientTable.getRecord(id));
RecipientRecord record;
try {
record = recipientTable.getRecord(id);
} catch (RecipientTable.MissingRecipientException e) {
Log.w(TAG, "Failed to find " + id + "! Returning UNKNOWN.");
return Recipient.UNKNOWN;
}

Recipient recipient = RecipientCreator.forRecord(context, record);
RecipientIdCache.INSTANCE.put(recipient);
return recipient;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,6 @@ object RecipientCreator {
return recipient
}

@JvmStatic
fun forUnknown(): Recipient {
return Recipient.UNKNOWN
}

@JvmStatic
fun forUnknownGroup(id: RecipientId, groupId: GroupId?): Recipient {
return Recipient(
Expand Down

0 comments on commit 47a5816

Please sign in to comment.