impl of missing methods in DatabaseAttachmentProvider

This commit is contained in:
Brice 2021-01-19 11:39:45 +11:00
parent 883c71331b
commit 845ea16415
2 changed files with 12 additions and 19 deletions

View File

@ -8,8 +8,6 @@ import org.session.libsession.messaging.sending_receiving.attachments.*
import org.session.libsession.messaging.threads.Address
import org.session.libsignal.libsignal.util.guava.Optional
import org.session.libsignal.service.api.messages.SignalServiceAttachment
import org.session.libsignal.service.api.messages.SignalServiceAttachmentPointer
import org.thoughtcrime.securesms.ApplicationContext
import org.thoughtcrime.securesms.database.Database
import org.thoughtcrime.securesms.database.DatabaseFactory
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
@ -28,10 +26,6 @@ class DatabaseAttachmentProvider(context: Context, helper: SQLCipherOpenHelper)
return databaseAttachment.toAttachmentStream(context)
}
override fun getAttachmentPointer(attachmentID: String): SignalServiceAttachmentPointer? {
TODO("Not yet implemented")
}
override fun getAttachmentPointer(attachmentId: Long): SessionServiceAttachmentPointer? {
val attachmentDatabase = DatabaseFactory.getAttachmentDatabase(context)
val databaseAttachment = attachmentDatabase.getAttachment(AttachmentId(attachmentId, 0)) ?: return null
@ -50,15 +44,18 @@ class DatabaseAttachmentProvider(context: Context, helper: SQLCipherOpenHelper)
}
override fun getMessageForQuote(timestamp: Long, author: Address): Long? {
TODO("Not yet implemented")
val messagingDatabase = DatabaseFactory.getMmsSmsDatabase(context)
return messagingDatabase.getMessageFor(timestamp, author)?.id
}
override fun getAttachmentsWithLinkPreviewFor(messageID: Long): List<Attachment> {
TODO("Not yet implemented")
override fun getAttachmentsAndLinkPreviewFor(messageID: Long): List<Attachment> {
val attachmentDatabase = DatabaseFactory.getAttachmentDatabase(context)
return attachmentDatabase.getAttachmentsForMessage(messageID)
}
override fun getMessageBodyFor(messageID: Long): String {
TODO("Not yet implemented")
val messagingDatabase = DatabaseFactory.getSmsDatabase(context)
return messagingDatabase.getMessage(messageID).body
}
override fun insertAttachment(messageId: Long, attachmentId: Long, stream: InputStream) {
@ -72,13 +69,13 @@ class DatabaseAttachmentProvider(context: Context, helper: SQLCipherOpenHelper)
}
override fun getMessageID(serverID: Long): Long? {
TODO("Not yet implemented")
val openGroupMessagingDatabase = DatabaseFactory.getLokiMessageDatabase(context)
return openGroupMessagingDatabase.getMessageID(serverID)
}
override fun deleteMessage(messageID: Long) {
TODO("Not yet implemented")
//val publicChatAPI = ApplicationContext.getInstance(context).publicChatAPI
//publicChatAPI?.deleteMessage(messageID)
val messagingDatabase = DatabaseFactory.getSmsDatabase(context)
messagingDatabase.deleteMessage(messageID)
}
}

View File

@ -10,10 +10,6 @@ import java.io.InputStream
interface MessageDataProvider {
//fun getAttachment(attachmentId: Long): SignalServiceAttachmentStream?
fun getAttachmentPointer(attachmentID: String): SignalServiceAttachmentPointer?
fun getMessageID(serverID: Long): Long?
fun deleteMessage(messageID: Long)
@ -32,7 +28,7 @@ interface MessageDataProvider {
// Quotes
fun getMessageForQuote(timestamp: Long, author: Address): Long?
fun getAttachmentsWithLinkPreviewFor(messageID: Long): List<Attachment>
fun getAttachmentsAndLinkPreviewFor(messageID: Long): List<Attachment>
fun getMessageBodyFor(messageID: Long): String
}