1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-26 12:08:43 +00:00

rename PollAnswer inheritors

This commit is contained in:
InsanusMokrassar 2023-08-20 00:27:33 +06:00
parent 117d891ff2
commit d59e204002

View File

@ -20,7 +20,7 @@ sealed interface PollAnswer: FromUser {
get() = user get() = user
@Serializable @Serializable
data class Common( data class Public(
@SerialName(pollIdField) @SerialName(pollIdField)
override val pollId: PollIdentifier, override val pollId: PollIdentifier,
@SerialName(userField) @SerialName(userField)
@ -30,7 +30,7 @@ sealed interface PollAnswer: FromUser {
) : PollAnswer ) : PollAnswer
@Serializable @Serializable
data class InChannel( data class Anonymous(
@SerialName(pollIdField) @SerialName(pollIdField)
override val pollId: PollIdentifier, override val pollId: PollIdentifier,
@SerialName(voterChatField) @SerialName(voterChatField)
@ -67,7 +67,7 @@ sealed interface PollAnswer: FromUser {
pollId: PollIdentifier, pollId: PollIdentifier,
user: User, user: User,
chosen: List<Int>, chosen: List<Int>,
) = Common(pollId, user, chosen) ) = Public(pollId, user, chosen)
override val descriptor: SerialDescriptor override val descriptor: SerialDescriptor
get() = PollAnswerSurrogate.serializer().descriptor get() = PollAnswerSurrogate.serializer().descriptor
@ -75,9 +75,9 @@ sealed interface PollAnswer: FromUser {
override fun deserialize(decoder: Decoder): PollAnswer { override fun deserialize(decoder: Decoder): PollAnswer {
val surrogate = PollAnswerSurrogate.serializer().deserialize(decoder) val surrogate = PollAnswerSurrogate.serializer().deserialize(decoder)
return if (surrogate.voterChat != null) { return if (surrogate.voterChat != null) {
InChannel(surrogate.pollId, surrogate.voterChat, surrogate.chosen) Anonymous(surrogate.pollId, surrogate.voterChat, surrogate.chosen)
} else { } else {
Common(surrogate.pollId, surrogate.user, surrogate.chosen) Public(surrogate.pollId, surrogate.user, surrogate.chosen)
} }
} }
@ -88,7 +88,7 @@ sealed interface PollAnswer: FromUser {
value.pollId, value.pollId,
value.user, value.user,
value.chosen, value.chosen,
(value as? InChannel) ?.voterChat (value as? Anonymous) ?.voterChat
) )
) )
} }