mirror of
https://github.com/InsanusMokrassar/PlaguPoster.git
synced 2025-09-15 13:09:29 +00:00
update dependencies
This commit is contained in:
@@ -30,7 +30,7 @@ import dev.inmo.tgbotapi.extensions.utils.extensions.sameMessage
|
||||
import dev.inmo.tgbotapi.extensions.utils.types.buttons.dataButton
|
||||
import dev.inmo.tgbotapi.extensions.utils.types.buttons.flatInlineKeyboard
|
||||
import dev.inmo.tgbotapi.types.IdChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.ReplyParameters
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackDataInlineKeyboardButton
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
@@ -129,7 +129,7 @@ object Plugin : Plugin {
|
||||
suspend fun refreshPostMessage(
|
||||
postId: PostId,
|
||||
chatId: IdChatIdentifier,
|
||||
messageId: MessageIdentifier
|
||||
messageId: MessageId
|
||||
) {
|
||||
val post = postsRepo.getById(postId) ?: return
|
||||
val buttons = api.buttonsBuilders.chunked(config.buttonsPerRow).mapNotNull { row ->
|
||||
|
@@ -4,21 +4,18 @@ import dev.inmo.micro_utils.repos.KeyValueRepo
|
||||
import dev.inmo.micro_utils.repos.exposed.keyvalue.ExposedKeyValueRepo
|
||||
import dev.inmo.micro_utils.repos.mappers.withMapper
|
||||
import dev.inmo.plaguposter.posts.models.PostId
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.FullChatIdentifierSerializer
|
||||
import dev.inmo.tgbotapi.types.IdChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.builtins.PairSerializer
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
import kotlinx.serialization.json.Json
|
||||
import org.jetbrains.exposed.sql.Database
|
||||
|
||||
private val ChatIdToMessageSerializer = PairSerializer(FullChatIdentifierSerializer, MessageIdentifier.serializer())
|
||||
private val ChatIdToMessageSerializer = PairSerializer(FullChatIdentifierSerializer, MessageId.serializer())
|
||||
|
||||
fun PostsMessages(
|
||||
database: Database,
|
||||
json: Json
|
||||
): KeyValueRepo<PostId, Pair<IdChatIdentifier, MessageIdentifier>> = ExposedKeyValueRepo<String, String>(
|
||||
): KeyValueRepo<PostId, Pair<IdChatIdentifier, MessageId>> = ExposedKeyValueRepo<String, String>(
|
||||
database,
|
||||
{ text("postId") },
|
||||
{ text("chatToMessage") },
|
||||
|
@@ -1,10 +1,7 @@
|
||||
package dev.inmo.plaguposter.posts.models
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.utils.possiblyMediaGroupMessageOrNull
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.FullChatIdentifierSerializer
|
||||
import dev.inmo.tgbotapi.types.IdChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
||||
import kotlinx.serialization.Serializable
|
||||
@@ -13,8 +10,8 @@ import kotlinx.serialization.Serializable
|
||||
data class PostContentInfo(
|
||||
@Serializable(FullChatIdentifierSerializer::class)
|
||||
val chatId: IdChatIdentifier,
|
||||
val messageId: MessageIdentifier,
|
||||
val group: String?,
|
||||
val messageId: MessageId,
|
||||
val group: MediaGroupId?,
|
||||
val order: Int
|
||||
) {
|
||||
companion object {
|
||||
|
@@ -5,10 +5,10 @@ import dev.inmo.micro_utils.repos.ReadCRUDRepo
|
||||
import dev.inmo.plaguposter.posts.models.*
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.IdChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
|
||||
interface ReadPostsRepo : ReadCRUDRepo<RegisteredPost, PostId> {
|
||||
suspend fun getIdByChatAndMessage(chatId: IdChatIdentifier, messageId: MessageIdentifier): PostId?
|
||||
suspend fun getIdByChatAndMessage(chatId: IdChatIdentifier, messageId: MessageId): PostId?
|
||||
suspend fun getPostCreationTime(postId: PostId): DateTime?
|
||||
suspend fun getFirstMessageInfo(postId: PostId): PostContentInfo?
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ import dev.inmo.plaguposter.posts.models.PostId
|
||||
import dev.inmo.plaguposter.posts.models.RegisteredPost
|
||||
import dev.inmo.plaguposter.posts.repo.PostsRepo
|
||||
import dev.inmo.tgbotapi.types.IdChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@@ -34,7 +34,7 @@ class CachedPostsRepo(
|
||||
) {
|
||||
override val removedPostsFlow: Flow<RegisteredPost> by parentRepo::removedPostsFlow
|
||||
|
||||
override suspend fun getIdByChatAndMessage(chatId: IdChatIdentifier, messageId: MessageIdentifier): PostId? {
|
||||
override suspend fun getIdByChatAndMessage(chatId: IdChatIdentifier, messageId: MessageId): PostId? {
|
||||
doForAllWithNextPaging(firstPageWithOneElementPagination) {
|
||||
kvCache.values(it).also {
|
||||
it.results.forEach {
|
||||
|
@@ -4,8 +4,7 @@ import com.benasher44.uuid.uuid4
|
||||
import dev.inmo.micro_utils.repos.KeyValuesRepo
|
||||
import dev.inmo.micro_utils.repos.exposed.*
|
||||
import dev.inmo.plaguposter.posts.models.*
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.IdChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import org.jetbrains.exposed.sql.*
|
||||
|
||||
internal class ExposedContentInfoRepo(
|
||||
@@ -21,9 +20,9 @@ internal class ExposedContentInfoRepo(
|
||||
|
||||
val ResultRow.asObject
|
||||
get() = PostContentInfo(
|
||||
IdChatIdentifier(get(chatIdColumn), get(threadIdColumn)),
|
||||
get(messageIdColumn),
|
||||
get(groupColumn),
|
||||
IdChatIdentifier(RawChatId(get(chatIdColumn)), get(threadIdColumn) ?.let(::MessageThreadId)),
|
||||
MessageId(get(messageIdColumn)),
|
||||
get(groupColumn) ?.let(::MediaGroupId),
|
||||
get(orderColumn)
|
||||
)
|
||||
|
||||
|
@@ -10,7 +10,7 @@ import dev.inmo.plaguposter.posts.models.*
|
||||
import dev.inmo.plaguposter.posts.repo.PostsRepo
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.IdChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.serialization.json.Json
|
||||
import org.jetbrains.exposed.sql.*
|
||||
@@ -93,10 +93,10 @@ class ExposedPostsRepo(
|
||||
post.content.forEach { contentInfo ->
|
||||
insert {
|
||||
it[postIdColumn] = post.id.string
|
||||
it[chatIdColumn] = contentInfo.chatId.chatId
|
||||
it[threadIdColumn] = contentInfo.chatId.threadId
|
||||
it[messageIdColumn] = contentInfo.messageId
|
||||
it[groupColumn] = contentInfo.group
|
||||
it[chatIdColumn] = contentInfo.chatId.chatId.long
|
||||
it[threadIdColumn] = contentInfo.chatId.threadId ?.long
|
||||
it[messageIdColumn] = contentInfo.messageId.long
|
||||
it[groupColumn] = contentInfo.group ?.string
|
||||
it[orderColumn] = contentInfo.order
|
||||
}
|
||||
}
|
||||
@@ -153,13 +153,13 @@ class ExposedPostsRepo(
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getIdByChatAndMessage(chatId: IdChatIdentifier, messageId: MessageIdentifier): PostId? {
|
||||
override suspend fun getIdByChatAndMessage(chatId: IdChatIdentifier, messageId: MessageId): PostId? {
|
||||
return transaction(database) {
|
||||
with(contentRepo) {
|
||||
select {
|
||||
chatIdColumn.eq(chatId.chatId)
|
||||
.and(chatId.threadId ?.let { threadIdColumn.eq(it) } ?: threadIdColumn.isNull())
|
||||
.and(messageIdColumn.eq(messageId))
|
||||
chatIdColumn.eq(chatId.chatId.long)
|
||||
.and(chatId.threadId ?.let { threadIdColumn.eq(it.long) } ?: threadIdColumn.isNull())
|
||||
.and(messageIdColumn.eq(messageId.long))
|
||||
}.limit(1).firstOrNull() ?.get(postIdColumn)
|
||||
} ?.let(::PostId)
|
||||
}
|
||||
|
Reference in New Issue
Block a user