fix: empty messages in open groups now correct properly

This commit is contained in:
jubb 2021-03-29 16:40:56 +11:00
parent d292c760c4
commit c3f7425ccd
3 changed files with 35 additions and 32 deletions

View File

@ -182,8 +182,7 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
override fun resumeMessageSendJobIfNeeded(messageSendJobID: String) {
val job = DatabaseFactory.getSessionJobDatabase(context).getMessageSendJob(messageSendJobID) ?: return
job.delegate = JobQueue.shared
job.execute()
JobQueue.shared.add(job)
}
override fun isJobCanceled(job: Job): Boolean {

View File

@ -34,8 +34,8 @@ class AttachmentDownloadJob(val attachmentID: Long, val databaseMessageID: Long)
}
override fun execute() {
try {
val messageDataProvider = MessagingConfiguration.shared.messageDataProvider
messageDataProvider.getDatabaseAttachment(attachmentID)
val attachment = messageDataProvider.getDatabaseAttachment(attachmentID) ?: return handleFailure(Error.NoAttachment)
messageDataProvider.setAttachmentState(AttachmentState.STARTED, attachmentID, this.databaseMessageID)
val tempFile = createTempFile()
@ -69,6 +69,9 @@ class AttachmentDownloadJob(val attachmentID: Long, val databaseMessageID: Long)
tempFile.delete()
handleSuccess()
} catch (e: Exception) {
handleFailure(e)
}
}
private fun handleSuccess() {

View File

@ -42,7 +42,8 @@ data class OpenGroupMessage(
}()
// Message
val displayname = storage.getUserDisplayName() ?: "Anonymous"
val body = message.text ?: message.sentTimestamp.toString() // The back-end doesn't accept messages without a body so we use this as a workaround
val text = message.text
val body = if (text.isNullOrEmpty()) message.sentTimestamp.toString() else text // The back-end doesn't accept messages without a body so we use this as a workaround
val result = OpenGroupMessage(null, userPublicKey, displayname, body, message.sentTimestamp!!, OpenGroupAPI.openGroupMessageType, quote, mutableListOf(), null, null, 0)
// Link preview
val linkPreview = message.linkPreview