mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 02:10:44 +01:00
Fallback to profile fetches for unlisted contacts.
This commit is contained in:
@@ -1801,6 +1801,12 @@ public class RecipientDatabase extends Database {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles inserts the (e164, UUID) pairs, which could result in merges. Does not mark users as
|
||||
* registered.
|
||||
*
|
||||
* @return A mapping of (RecipientId, UUID)
|
||||
*/
|
||||
public @NonNull Map<RecipientId, String> bulkProcessCdsResult(@NonNull Map<String, UUID> mapping) {
|
||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
||||
HashMap<RecipientId, String> uuidMap = new HashMap<>();
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.sqlcipher.database.SQLiteDatabase;
|
||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.util.SqlUtil;
|
||||
import org.whispersystems.libsignal.state.SessionRecord;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
@@ -145,6 +146,16 @@ public class SessionDatabase extends Database {
|
||||
database.delete(TABLE_NAME, RECIPIENT_ID + " = ?", new String[] {recipientId.serialize()});
|
||||
}
|
||||
|
||||
public boolean hasSessionFor(@NonNull RecipientId recipientId) {
|
||||
SQLiteDatabase database = databaseHelper.getReadableDatabase();
|
||||
String query = RECIPIENT_ID + " = ?";
|
||||
String[] args = SqlUtil.buildArgs(recipientId);
|
||||
|
||||
try (Cursor cursor = database.query(TABLE_NAME, new String[] { ID }, query, args, null, null, null, "1")) {
|
||||
return cursor != null && cursor.moveToFirst();
|
||||
}
|
||||
}
|
||||
|
||||
public static final class SessionRow {
|
||||
private final RecipientId recipientId;
|
||||
private final int deviceId;
|
||||
|
||||
@@ -872,22 +872,17 @@ public class ThreadDatabase extends Database {
|
||||
deleteAllThreads();
|
||||
}
|
||||
|
||||
public long getThreadIdIfExistsFor(Recipient recipient) {
|
||||
public long getThreadIdIfExistsFor(@NonNull RecipientId recipientId) {
|
||||
SQLiteDatabase db = databaseHelper.getReadableDatabase();
|
||||
String where = RECIPIENT_ID + " = ?";
|
||||
String[] recipientsArg = new String[] {recipient.getId().serialize()};
|
||||
Cursor cursor = null;
|
||||
String[] recipientsArg = new String[] {recipientId.serialize()};
|
||||
|
||||
try {
|
||||
cursor = db.query(TABLE_NAME, new String[]{ID}, where, recipientsArg, null, null, null);
|
||||
|
||||
if (cursor != null && cursor.moveToFirst())
|
||||
return cursor.getLong(cursor.getColumnIndexOrThrow(ID));
|
||||
else
|
||||
return -1L;
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
try (Cursor cursor = db.query(TABLE_NAME, new String[]{ ID }, where, recipientsArg, null, null, null, "1")) {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
return CursorUtil.requireLong(cursor, ID);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -950,6 +945,10 @@ public class ThreadDatabase extends Database {
|
||||
return Recipient.resolved(id);
|
||||
}
|
||||
|
||||
public boolean hasThread(@NonNull RecipientId recipientId) {
|
||||
return getThreadIdIfExistsFor(recipientId) > -1;
|
||||
}
|
||||
|
||||
public void setHasSent(long threadId, boolean hasSent) {
|
||||
ContentValues contentValues = new ContentValues(1);
|
||||
contentValues.put(HAS_SENT, hasSent ? 1 : 0);
|
||||
|
||||
Reference in New Issue
Block a user