mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
fixes
This commit is contained in:
parent
fc59ab0cdd
commit
a85e7d7387
@ -1,6 +1,7 @@
|
||||
package dev.inmo.tgbotapi.bot.Ktor.base
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.safely
|
||||
import dev.inmo.micro_utils.coroutines.safelyWithResult
|
||||
import dev.inmo.tgbotapi.bot.Ktor.KtorCallFactory
|
||||
import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
||||
import dev.inmo.tgbotapi.requests.GetUpdates
|
||||
@ -57,7 +58,7 @@ abstract class AbstractRequestCallFactory : KtorCallFactory {
|
||||
val content = response.receive<String>()
|
||||
val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content)
|
||||
|
||||
return safely {
|
||||
return safelyWithResult {
|
||||
(responseObject.result?.let {
|
||||
jsonFormatter.decodeFromJsonElement(request.resultDeserializer, it)
|
||||
} ?: response.let {
|
||||
@ -67,7 +68,7 @@ abstract class AbstractRequestCallFactory : KtorCallFactory {
|
||||
"Can't get result object from $content"
|
||||
)
|
||||
})
|
||||
}
|
||||
}.getOrThrow()
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,4 +77,4 @@ abstract class AbstractRequestCallFactory : KtorCallFactory {
|
||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
||||
request: Request<T>
|
||||
): Any?
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,7 @@ package dev.inmo.tgbotapi.requests.chat.invite_links
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
sealed interface ChatJoinRequestAnswer : SimpleRequest<Boolean> {
|
||||
@ -17,7 +15,9 @@ sealed interface ChatJoinRequestAnswer : SimpleRequest<Boolean> {
|
||||
|
||||
@Serializable
|
||||
data class ApproveChatJoinRequest(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier,
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId
|
||||
) : ChatJoinRequestAnswer {
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
@ -28,7 +28,9 @@ data class ApproveChatJoinRequest(
|
||||
|
||||
@Serializable
|
||||
data class DeclineChatJoinRequest(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier,
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId
|
||||
) : ChatJoinRequestAnswer {
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
|
@ -9,12 +9,12 @@ import kotlinx.serialization.Serializable
|
||||
data class ChatJoinRequest(
|
||||
@SerialName(chatField)
|
||||
val chat: PublicChat,
|
||||
@SerialName(userField)
|
||||
@SerialName(fromField)
|
||||
override val from: User,
|
||||
@SerialName(dateField)
|
||||
val date: TelegramDate,
|
||||
@SerialName(bioField)
|
||||
val bio: String,
|
||||
@SerialName(inviteLinkField)
|
||||
val inviteLink: ChatInviteLink
|
||||
val inviteLink: ChatInviteLink,
|
||||
@SerialName(bioField)
|
||||
val bio: String? = null
|
||||
) : FromUser
|
||||
|
Loading…
Reference in New Issue
Block a user