Skip to content

Commit

Permalink
fix: discord 전송 실패 메세지 청크로 분리해서 전송하도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
wjdtkdgns committed Sep 2, 2024
1 parent d0449f3 commit 543146f
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,24 @@ class ResendFailedSentDiscordMessageJob(
// 재전송
runCatching {
coroutineScope {
val sendDeferreds = message.map { (token, message) ->
val sendDeferreds = message.flatMap { (token, message) ->
val discordMessageModel = DiscordMessageModel(content = message)

async(Dispatchers.IO) {
discordClient.sendMessage(
message = discordMessageModel,
token = token,
withRecover = false
)
message.chunked(1900).map {
async(Dispatchers.IO) {
discordClient.sendMessage(
message = discordMessageModel,
token = token,
withRecover = false
)
}
}
}.toTypedArray()

awaitAll(*sendDeferreds)
}
}.onFailure {
// 재전송 실패시 1분 뒤에 다시 보낼 수 있게, 1분 뒤에 보내는 메세지 목록에 추가
logger.warn { "postpone resend discord message" }

postponeResendTimeOfFailedMessage(targetTime, message)
}

Expand Down

0 comments on commit 543146f

Please sign in to comment.