mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2026-03-03 09:22:22 +00:00
add support of extended chat id in private chats
This commit is contained in:
@@ -123,7 +123,7 @@ val RawChatId.userLink: String
|
||||
val UserId.userLink: String
|
||||
get() = chatId.userLink
|
||||
val User.userLink: String
|
||||
get() = id.userLink
|
||||
get() = id.toChatId().userLink
|
||||
|
||||
typealias UserId = ChatId
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ sealed interface UsernameChat : Chat {
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@Serializable(ChatSerializer::class)
|
||||
sealed interface PrivateChat : Chat, UsernameChat {
|
||||
override val id: UserId
|
||||
override val id: IdChatIdentifier
|
||||
val firstName: String
|
||||
val lastName: String
|
||||
}
|
||||
@@ -25,6 +25,7 @@ sealed interface PrivateUserChat : PrivateChat
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@Serializable(ChatSerializer::class)
|
||||
sealed interface PrivateForumChat : PrivateUserChat, ForumChat {
|
||||
override val id: IdChatIdentifier
|
||||
}
|
||||
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
|
||||
@@ -183,7 +183,7 @@ data class ExtendedPrivateChatImpl(
|
||||
data class ExtendedPrivateForumChatImpl(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(idField)
|
||||
override val id: UserId,
|
||||
override val id: IdChatIdentifier,
|
||||
@SerialName(photoField)
|
||||
override val chatPhoto: ChatPhoto? = null,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
|
||||
@@ -38,7 +38,7 @@ data class PrivateChatImpl(
|
||||
data class PrivateForumChatImpl(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(idField)
|
||||
override val id: UserId,
|
||||
override val id: IdChatIdentifier,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(usernameField)
|
||||
override val username: Username? = null,
|
||||
|
||||
@@ -750,14 +750,22 @@ internal data class RawMessage(
|
||||
is PreviewPrivateChat -> if (business_connection_id == null) {
|
||||
when {
|
||||
is_topic_message == true -> {
|
||||
val chatId = ChatIdWithThreadId(
|
||||
chat.id.chatId,
|
||||
messageThreadId ?: error("Was detected forum private message, but message thread id was not found")
|
||||
)
|
||||
val actualForumChat = when (chat) {
|
||||
is PrivateForumChatImpl -> chat.copy(id = chatId)
|
||||
is CommonUser -> chat
|
||||
is CommonBot -> chat
|
||||
is PrivateChatImpl -> chat
|
||||
}
|
||||
PrivateForumContentMessageImpl(
|
||||
messageId = messageId,
|
||||
from = checkedFrom ?: from
|
||||
?: error("Was detected common message, but owner (sender) of the message was not found"),
|
||||
threadId = messageThreadId
|
||||
?: error("Was detected forum private message, but message thread id was not found"),
|
||||
from = checkedFrom ?: from ?: error("Was detected common message, but owner (sender) of the message was not found"),
|
||||
threadId = messageThreadId,
|
||||
threadCreatingInfo = forum_topic_created,
|
||||
chat = chat,
|
||||
chat = actualForumChat,
|
||||
content = content,
|
||||
date = date.asDate,
|
||||
editDate = edit_date?.asDate,
|
||||
|
||||
Reference in New Issue
Block a user