Unverified Commit b9f51766 authored by Rafael Kellermann Streit's avatar Rafael Kellermann Streit Committed by GitHub

Merge pull request #1265 from RocketChat/fix/crash-on-jobscheduler-send-message

[FIX] Do not reschedule failed sending if the API returns inconsistent
parents c4fc4746 e192f489
...@@ -60,8 +60,16 @@ class MessageService : JobService() { ...@@ -60,8 +60,16 @@ class MessageService : JobService() {
) )
messageRepository.save(message.copy(isTemporary = false)) messageRepository.save(message.copy(isTemporary = false))
Timber.d("Sent scheduled message given by id: ${message.id}") Timber.d("Sent scheduled message given by id: ${message.id}")
} catch (ex: RocketChatException) { } catch (ex: Exception) {
Timber.e(ex) Timber.e(ex)
// TODO - remove the generic message when we implement :userId:/message subscription
if (ex is IllegalStateException) {
Timber.d(ex, "Probably a read-only problem...")
// TODO: For now we are only going to reschedule when api is fixed.
messageRepository.removeById(message.id)
jobFinished(params, false)
} else {
// some other error
if (ex.message?.contains("E11000", true) == true) { if (ex.message?.contains("E11000", true) == true) {
// XXX: Temporary solution. We need proper error codes from the api. // XXX: Temporary solution. We need proper error codes from the api.
messageRepository.save(message.copy(isTemporary = false)) messageRepository.save(message.copy(isTemporary = false))
...@@ -71,6 +79,7 @@ class MessageService : JobService() { ...@@ -71,6 +79,7 @@ class MessageService : JobService() {
} }
} }
} }
}
companion object { companion object {
const val RETRY_SEND_MESSAGE_ID = 1 const val RETRY_SEND_MESSAGE_ID = 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment