fix quoting message in open groups

This commit is contained in:
Ryan ZHAO 2021-03-11 14:37:53 +11:00
parent b490ed0c22
commit 42c7f440e9
3 changed files with 8 additions and 3 deletions

View File

@ -330,6 +330,10 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
DatabaseFactory.getLokiMessageDatabase(context).setServerID(messageID, serverID)
}
override fun getQuoteServerID(quoteID: Long, publicKey: String): Long? {
return DatabaseFactory.getLokiMessageDatabase(context).getQuoteServerID(quoteID, publicKey)
}
override fun markAsSent(timestamp: Long, author: String) {
val database = DatabaseFactory.getMmsSmsDatabase(context)
val messageRecord = database.getMessageFor(timestamp, author) ?: return

View File

@ -59,6 +59,8 @@ interface StorageProtocol {
fun getThreadID(openGroupID: String): String?
fun getAllOpenGroups(): Map<Long, PublicChat>
fun addOpenGroup(server: String, channel: Long)
fun setOpenGroupServerMessageID(messageID: Long, serverID: Long)
fun getQuoteServerID(quoteID: Long, publicKey: String): Long?
// Open Group Public Keys
fun getOpenGroupPublicKey(server: String): String?
@ -94,7 +96,6 @@ interface StorageProtocol {
fun persistAttachments(messageId: Long, attachments: List<Attachment>): List<Long>
fun getMessageIdInDatabase(timestamp: Long, author: String): Long?
fun setOpenGroupServerMessageID(messageID: Long, serverID: Long)
fun markAsSent(timestamp: Long, author: String)
fun markUnidentified(timestamp: Long, author: String)
fun setErrorMessage(timestamp: Long, author: String, error: Exception)

View File

@ -33,8 +33,8 @@ data class OpenGroupMessage(
val quote = message.quote
if (quote != null && quote.isValid()) {
val quotedMessageBody = quote.text ?: quote.timestamp!!.toString()
// FIXME: For some reason the server always returns a 500 if quotedMessageServerID is set...
Quote(quote.timestamp!!, quote.publicKey!!, quotedMessageBody, null)
val serverID = storage.getQuoteServerID(quote.timestamp!!, quote.publicKey!!)
Quote(quote.timestamp!!, quote.publicKey!!, quotedMessageBody, serverID)
} else {
null
}