add MediaFileActualityChecker

This commit is contained in:
InsanusMokrassar 2022-04-20 00:19:25 +06:00
parent 570568cd26
commit d5ae880e77
2 changed files with 9 additions and 0 deletions

View File

@ -52,6 +52,10 @@ class DefaultMessageContentCache<K>(
messagesFilesCache.set(key, filename, inputAllocator)
}.onFailure {
simpleMessageContentCache.remove(key)
}.onSuccess {
with(mediaFileActualityChecker) {
bot.saved(content)
}
}
return key

View File

@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
fun interface MediaFileActualityChecker {
suspend fun TelegramBot.isActual(mediaContent: MediaContent): Boolean
suspend fun TelegramBot.saved(mediaContent: MediaContent) {}
class Default(
private val checkingChatId: ChatId
@ -46,5 +47,9 @@ fun interface MediaFileActualityChecker {
true
}
}
override suspend fun TelegramBot.saved(mediaContent: MediaContent) {
fileIdChecksMap[mediaContent.media.fileId] = DateTime.now()
}
}
}