1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-09-05 08:09:21 +00:00

fixes in new multipart api

This commit is contained in:
2025-06-01 19:24:58 +06:00
parent ddb79c0d8d
commit 44f92e8d6c
3 changed files with 10 additions and 6 deletions

View File

@@ -21,7 +21,11 @@ class MultipartRequestCallFactory(logger: KSLog? = null) : AbstractRequestCallFa
): T? { ): T? {
return when (request) { return when (request) {
!is MultipartRequest -> null !is MultipartRequest -> null
is MultipartRequest.Common -> localSimpleRequestCallFactory.makeCall(client, urlsKeeper, request.data, jsonFormatter) is MultipartRequest.Common -> if (request.mediaMap.isEmpty()) {
localSimpleRequestCallFactory.makeCall(client, urlsKeeper, request.data, jsonFormatter)
} else {
super.makeCall(client, urlsKeeper, request, jsonFormatter)
}
else -> super.makeCall(client, urlsKeeper, request, jsonFormatter) else -> super.makeCall(client, urlsKeeper, request, jsonFormatter)
} }
} }

View File

@@ -17,7 +17,7 @@ import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.JsonObject
@Serializable @Serializable(InputProfilePhoto.Companion::class)
sealed interface InputProfilePhoto { sealed interface InputProfilePhoto {
val type: String val type: String
val mediaPair: Pair<String, MultipartFile> val mediaPair: Pair<String, MultipartFile>
@@ -27,7 +27,7 @@ sealed interface InputProfilePhoto {
val photo: MultipartFile val photo: MultipartFile
) : InputProfilePhoto { ) : InputProfilePhoto {
override val mediaPair: Pair<String, MultipartFile> override val mediaPair: Pair<String, MultipartFile>
get() = photoField to photo get() = photo.fileId to photo
@EncodeDefault @EncodeDefault
override val type: String = "static" override val type: String = "static"
} }
@@ -39,7 +39,7 @@ sealed interface InputProfilePhoto {
val mainFrameTimestamp: DoubleSeconds? = null val mainFrameTimestamp: DoubleSeconds? = null
) : InputProfilePhoto { ) : InputProfilePhoto {
override val mediaPair: Pair<String, MultipartFile> override val mediaPair: Pair<String, MultipartFile>
get() = animationField to animation get() = animation.fileId to animation
@EncodeDefault @EncodeDefault
override val type: String = "animated" override val type: String = "animated"
} }

View File

@@ -29,7 +29,7 @@ sealed interface InputStoryContent {
@EncodeDefault @EncodeDefault
override val type: Type = Companion override val type: Type = Companion
override val media: Pair<String, MultipartFile> override val media: Pair<String, MultipartFile>
get() = photoField to photo get() = photo.fileId to photo
companion object : Type { companion object : Type {
override val name: String override val name: String
@@ -50,7 +50,7 @@ sealed interface InputStoryContent {
@EncodeDefault @EncodeDefault
override val type: Type = Companion override val type: Type = Companion
override val media: Pair<String, MultipartFile> override val media: Pair<String, MultipartFile>
get() = videoField to video get() = video.fileId to video
companion object : Type { companion object : Type {
override val name: String override val name: String