1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-22 16:47:13 +00:00

base ktor request call factories became classes to avoid sharing of their cache between bots

This commit is contained in:
InsanusMokrassar 2021-08-08 16:14:43 +06:00
parent 96d980cb8a
commit 75f4226772
4 changed files with 7 additions and 5 deletions

View File

@ -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`

View File

@ -52,7 +52,7 @@ class KtorRequestsExecutor(
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
private val callsFactories: List<KtorCallFactory> = callsFactories.run {
if (!excludeDefaultFactories) {
this + listOf(SimpleRequestCallFactory, MultipartRequestCallFactory, DownloadFileRequestCallFactory)
this + listOf(SimpleRequestCallFactory(), MultipartRequestCallFactory(), DownloadFileRequestCallFactory)
} else {
this
}

View File

@ -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 <T : Any> prepareCallBody(
client: HttpClient,
urlsKeeper: TelegramAPIUrlsKeeper,
@ -35,4 +35,4 @@ object MultipartRequestCallFactory : AbstractRequestCallFactory() {
}
)
}
}
}

View File

@ -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 <T : Any> prepareCallBody(
client: HttpClient,
urlsKeeper: TelegramAPIUrlsKeeper,
@ -19,4 +19,4 @@ object SimpleRequestCallFactory : AbstractRequestCallFactory() {
ContentType.Application.Json
)
}
}
}