Skip to content

Commit 3da13ac

Browse files
committed
getAllReferencedAddresses() returns Address now
1 parent 481604c commit 3da13ac

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

app/src/main/java/org/thoughtcrime/securesms/database/MmsSmsDatabase.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,17 +449,23 @@ public Cursor getUnreadOrUnseenReactions() {
449449
return queryTables(PROJECTION, selection, order, null);
450450
}
451451

452-
public Set<String> getAllReferencedAddresses() {
452+
public Set<Address> getAllReferencedAddresses() {
453453
final String[] projection = new String[] { "DISTINCT " + MmsSmsColumns.ADDRESS };
454454
final String selection =
455455
"NOT " + MmsSmsColumns.IS_DELETED +
456456
" AND " + MmsSmsColumns.ADDRESS + " IS NOT NULL" +
457457
" AND " + MmsSmsColumns.ADDRESS + " != ''";
458458

459-
Set<String> out = new HashSet<>();
459+
Set<Address> out = new HashSet<>();
460460
try (Cursor cursor = queryTables(projection, selection, null, null)) {
461461
while (cursor != null && cursor.moveToNext()) {
462-
out.add(cursor.getString(0));
462+
String serialized = cursor.getString(0);
463+
try {
464+
out.add(Address.fromSerialized(serialized));
465+
} catch (Exception e) {
466+
// If parsing fails, skip this row
467+
Log.w(TAG, "Skipping unparsable address: " + serialized, e);
468+
}
463469
}
464470
}
465471
return out;

0 commit comments

Comments
 (0)