Skip to content

Commit

Permalink
add a delay for failed messages
Browse files Browse the repository at this point in the history
  • Loading branch information
benkuly committed Mar 13, 2024
1 parent 5c2e260 commit 863ade8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repositories {
}

group = "net.folivo"
version = "0.5.8"
version = "0.5.9"
java.sourceCompatibility = JavaVersion.VERSION_11

tasks.withType<org.springframework.boot.gradle.tasks.bundling.BootJar>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ data class SmsBridgeProperties(
val singleModeEnabled: Boolean = false,
val defaultRegion: String,
val defaultLocalPart: String = "sms_",
val defaultTimeZone: String = "UTC"
val defaultTimeZone: String = "UTC",
val retryQueueDelay: Long = 30,
) {
data class SmsBridgeTemplateProperties(
val outgoingMessage: String = "{sender} wrote:\n\n{body}",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.folivo.matrix.bridge.sms.provider.android

import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.reactive.awaitFirstOrNull
import net.folivo.matrix.bridge.sms.SmsBridgeProperties
Expand All @@ -11,6 +12,8 @@ import org.slf4j.LoggerFactory
import org.springframework.http.HttpStatus.BAD_REQUEST
import org.springframework.web.reactive.function.client.WebClient
import org.springframework.web.reactive.function.client.awaitBody
import kotlin.time.ExperimentalTime
import kotlin.time.seconds

class AndroidSmsProvider(
private val receiveSmsService: ReceiveSmsService,
Expand Down Expand Up @@ -53,6 +56,7 @@ class AndroidSmsProvider(
outSmsMessageRepository.findAll().collect {
sendOutSmsMessageRequest(AndroidOutSmsMessageRequest(it.receiver, it.body))
outSmsMessageRepository.delete(it)
delay(smsBridgeProperties.retryQueueDelay * 1000)
}
if (smsBridgeProperties.defaultRoomId != null) {
matrixClient.roomsApi.sendRoomEvent(
Expand Down

0 comments on commit 863ade8

Please sign in to comment.