fixing crash when sending messages, updating version for store release

This commit is contained in:
Adam Brown 2022-04-05 22:40:01 +01:00
parent 81d88b51fc
commit e17dd6ed3f
2 changed files with 10 additions and 5 deletions

View File

@ -12,6 +12,8 @@ import kotlinx.serialization.json.Json
import java.net.SocketException
import java.net.UnknownHostException
private const val MATRIX_MESSAGE_TASK_TYPE = "matrix-text-message"
internal class DefaultMessageService(
httpClient: MatrixHttpClient,
private val localEchoStore: LocalEchoStore,
@ -22,10 +24,10 @@ internal class DefaultMessageService(
private val sendMessageUseCase = SendMessageUseCase(httpClient, messageEncrypter)
private val sendEventMessageUseCase = SendEventMessageUseCase(httpClient)
override suspend fun canRun(task: MatrixTaskRunner.MatrixTask) = task.type == "text-message"
override suspend fun canRun(task: MatrixTaskRunner.MatrixTask) = task.type == MATRIX_MESSAGE_TASK_TYPE
override suspend fun run(task: MatrixTaskRunner.MatrixTask): MatrixTaskRunner.TaskResult {
require(task.type == "text-message")
require(task.type == MATRIX_MESSAGE_TASK_TYPE)
val message = Json.decodeFromString(MessageService.Message.TextMessage.serializer(), task.jsonPayload)
return try {
sendMessage(message)
@ -61,7 +63,10 @@ internal class DefaultMessageService(
private fun MessageService.Message.toTask(): BackgroundScheduler.Task {
return when (this) {
is MessageService.Message.TextMessage -> {
BackgroundScheduler.Task(type = "text-message", Json.encodeToString(MessageService.Message.TextMessage.serializer(), this))
BackgroundScheduler.Task(
type = MATRIX_MESSAGE_TASK_TYPE,
Json.encodeToString(MessageService.Message.TextMessage.serializer(), this)
)
}
}
}

View File

@ -1,4 +1,4 @@
{
"name": "0.0.1-alpha02",
"code": 3
"name": "0.0.1-alpha03",
"code": 4
}