This commit is contained in:
charles 2022-12-21 18:33:48 +11:00
parent 1ba8f9f80d
commit e460e086e6
4 changed files with 0 additions and 31 deletions

View File

@ -201,17 +201,6 @@ class DatabaseAttachmentProvider(context: Context, helper: SQLCipherOpenHelper)
return messageDB.getMessageServerHash(messageID) return messageDB.getMessageServerHash(messageID)
} }
override fun getServerHashForMessages(messageIDs: List<Long>): List<Pair<Long, String?>> {
val messageDB = DatabaseComponent.get(context).lokiMessageDatabase()
return messageDB.getMessageServerHashes(messageIDs)
}
override fun getMessageTimestampForServerHash(serverHash: String): Long? {
return DatabaseComponent.get(context).lokiMessageDatabase().getMessageIdForServerHash(serverHash)?.let {
DatabaseComponent.get(context).mmsSmsDatabase().getMessage(it)?.timestamp
}
}
override fun getDatabaseAttachment(attachmentId: Long): DatabaseAttachment? { override fun getDatabaseAttachment(attachmentId: Long): DatabaseAttachment? {
val attachmentDatabase = DatabaseComponent.get(context).attachmentDatabase() val attachmentDatabase = DatabaseComponent.get(context).attachmentDatabase()
return attachmentDatabase.getAttachment(AttachmentId(attachmentId, 0)) return attachmentDatabase.getAttachment(AttachmentId(attachmentId, 0))

View File

@ -170,13 +170,6 @@ class LokiMessageDatabase(context: Context, helper: SQLCipherOpenHelper) : Datab
} }
} }
fun getMessageServerHashes(messageIDs: List<Long>): List<Pair<Long, String?>> {
val database = databaseHelper.readableDatabase
return database.getAll(messageHashTable, "${Companion.messageID} IN (?)", arrayOf(messageIDs.joinToString(","))) { cursor ->
cursor.getLong(messageID) to cursor.getStringOrNull(serverHash)
}
}
fun setMessageServerHash(messageID: Long, serverHash: String) { fun setMessageServerHash(messageID: Long, serverHash: String) {
val database = databaseHelper.writableDatabase val database = databaseHelper.writableDatabase
val contentValues = ContentValues(2) val contentValues = ContentValues(2)
@ -197,9 +190,4 @@ class LokiMessageDatabase(context: Context, helper: SQLCipherOpenHelper) : Datab
database.update(messageThreadMappingTable, contentValues, "$threadID = ?", arrayOf(legacyThreadId.toString())) database.update(messageThreadMappingTable, contentValues, "$threadID = ?", arrayOf(legacyThreadId.toString()))
} }
fun getMessageIdForServerHash(serverHash: String): Long? {
return readableDatabase.get(messageHashTable, "$serverHash = ?", arrayOf(serverHash)) { cursor ->
cursor.getLong(messageID)
}
}
} }

View File

@ -81,12 +81,6 @@ public class MmsSmsDatabase extends Database {
super(context, databaseHelper); super(context, databaseHelper);
} }
public @Nullable MessageRecord getMessage(long messageId) {
try (Cursor cursor = queryTables(PROJECTION, MmsSmsColumns.ID + " = " + messageId, null, null)) {
return readerFor(cursor).getNext();
}
}
public @Nullable MessageRecord getMessageForTimestamp(long timestamp) { public @Nullable MessageRecord getMessageForTimestamp(long timestamp) {
try (Cursor cursor = queryTables(PROJECTION, MmsSmsColumns.NORMALIZED_DATE_SENT + " = " + timestamp, null, null)) { try (Cursor cursor = queryTables(PROJECTION, MmsSmsColumns.NORMALIZED_DATE_SENT + " = " + timestamp, null, null)) {
MmsSmsDatabase.Reader reader = readerFor(cursor); MmsSmsDatabase.Reader reader = readerFor(cursor);

View File

@ -23,8 +23,6 @@ interface MessageDataProvider {
fun deleteMessage(messageID: Long, isSms: Boolean) fun deleteMessage(messageID: Long, isSms: Boolean)
fun updateMessageAsDeleted(timestamp: Long, author: String) fun updateMessageAsDeleted(timestamp: Long, author: String)
fun getServerHashForMessage(messageID: Long): String? fun getServerHashForMessage(messageID: Long): String?
fun getServerHashForMessages(messageIDs: List<Long>): List<Pair<Long, String?>>
fun getMessageTimestampForServerHash(serverHash: String): Long?
fun getDatabaseAttachment(attachmentId: Long): DatabaseAttachment? fun getDatabaseAttachment(attachmentId: Long): DatabaseAttachment?
fun getAttachmentStream(attachmentId: Long): SessionServiceAttachmentStream? fun getAttachmentStream(attachmentId: Long): SessionServiceAttachmentStream?
fun getAttachmentPointer(attachmentId: Long): SessionServiceAttachmentPointer? fun getAttachmentPointer(attachmentId: Long): SessionServiceAttachmentPointer?