diff --git a/cache/content/common/src/commonMain/kotlin/dev/inmo/tgbotapi/libraries/cache/media/common/DefaultMessageContentCache.kt b/cache/content/common/src/commonMain/kotlin/dev/inmo/tgbotapi/libraries/cache/media/common/DefaultMessageContentCache.kt index 5c8c26a..817cc92 100644 --- a/cache/content/common/src/commonMain/kotlin/dev/inmo/tgbotapi/libraries/cache/media/common/DefaultMessageContentCache.kt +++ b/cache/content/common/src/commonMain/kotlin/dev/inmo/tgbotapi/libraries/cache/media/common/DefaultMessageContentCache.kt @@ -52,6 +52,10 @@ class DefaultMessageContentCache( messagesFilesCache.set(key, filename, inputAllocator) }.onFailure { simpleMessageContentCache.remove(key) + }.onSuccess { + with(mediaFileActualityChecker) { + bot.saved(content) + } } return key diff --git a/cache/content/common/src/commonMain/kotlin/dev/inmo/tgbotapi/libraries/cache/media/common/MediaFileActualityChecker.kt b/cache/content/common/src/commonMain/kotlin/dev/inmo/tgbotapi/libraries/cache/media/common/MediaFileActualityChecker.kt index 5a3d258..a82127f 100644 --- a/cache/content/common/src/commonMain/kotlin/dev/inmo/tgbotapi/libraries/cache/media/common/MediaFileActualityChecker.kt +++ b/cache/content/common/src/commonMain/kotlin/dev/inmo/tgbotapi/libraries/cache/media/common/MediaFileActualityChecker.kt @@ -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() + } } }