From 75f4226772a3f9e0c29e5bac5c0a280f95cc31d7 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 8 Aug 2021 16:14:43 +0600 Subject: [PATCH] base ktor request call factories became classes to avoid sharing of their cache between bots --- CHANGELOG.md | 2 ++ .../kotlin/dev/inmo/tgbotapi/bot/Ktor/KtorRequestsExecutor.kt | 2 +- .../tgbotapi/bot/Ktor/base/MultipartRequestCallFactory.kt | 4 ++-- .../inmo/tgbotapi/bot/Ktor/base/SimpleRequestCallFactory.kt | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af914fe97c..16ea4e1f91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ * `Ktor`: `1.6.1` -> `1.6.2` * `MicroUtils`: `0.5.16` -> `0.5.18` * `Core`: + * **`SimpleRequestCallFactory` and `MultipartRequestCallFactory` became a classes instead of objects to avoid + collisions in different bots** * Support of strongly-typed ietf language codes has been added * `API`: * New extension `TelegramBot#downloadFile` for any `MediaContent` diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/KtorRequestsExecutor.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/KtorRequestsExecutor.kt index 97225fce01..65a0f62e2f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/KtorRequestsExecutor.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/KtorRequestsExecutor.kt @@ -52,7 +52,7 @@ class KtorRequestsExecutor( ) : BaseRequestsExecutor(telegramAPIUrlsKeeper) { private val callsFactories: List = callsFactories.run { if (!excludeDefaultFactories) { - this + listOf(SimpleRequestCallFactory, MultipartRequestCallFactory, DownloadFileRequestCallFactory) + this + listOf(SimpleRequestCallFactory(), MultipartRequestCallFactory(), DownloadFileRequestCallFactory) } else { this } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/MultipartRequestCallFactory.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/MultipartRequestCallFactory.kt index 87cae741b3..23fa67e7a8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/MultipartRequestCallFactory.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/MultipartRequestCallFactory.kt @@ -9,7 +9,7 @@ import io.ktor.client.request.forms.formData import io.ktor.http.Headers import io.ktor.http.HttpHeaders -object MultipartRequestCallFactory : AbstractRequestCallFactory() { +class MultipartRequestCallFactory : AbstractRequestCallFactory() { override fun prepareCallBody( client: HttpClient, urlsKeeper: TelegramAPIUrlsKeeper, @@ -35,4 +35,4 @@ object MultipartRequestCallFactory : AbstractRequestCallFactory() { } ) } -} \ No newline at end of file +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/SimpleRequestCallFactory.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/SimpleRequestCallFactory.kt index 8dba9b73e5..388531be12 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/SimpleRequestCallFactory.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/SimpleRequestCallFactory.kt @@ -6,7 +6,7 @@ import io.ktor.client.HttpClient import io.ktor.http.ContentType import io.ktor.http.content.TextContent -object SimpleRequestCallFactory : AbstractRequestCallFactory() { +class SimpleRequestCallFactory : AbstractRequestCallFactory() { override fun prepareCallBody( client: HttpClient, urlsKeeper: TelegramAPIUrlsKeeper, @@ -19,4 +19,4 @@ object SimpleRequestCallFactory : AbstractRequestCallFactory() { ContentType.Application.Json ) } -} \ No newline at end of file +}