update fixes

This commit is contained in:
InsanusMokrassar 2022-12-08 21:35:06 +06:00
parent 7ae5a158bb
commit 5646b2f581
3 changed files with 8 additions and 5 deletions

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -3,8 +3,10 @@ package db
import dev.inmo.micro_utils.repos.exposed.ExposedRepo
import dev.inmo.micro_utils.repos.exposed.initTable
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.IdChatIdentifier
import model.ChatSettings
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.transactions.transaction
internal class WelcomeTable(
@ -19,7 +21,7 @@ internal class WelcomeTable(
initTable()
}
fun get(chatId: ChatId): ChatSettings? = transaction(database) {
fun get(chatId: IdChatIdentifier): ChatSettings? = transaction(database) {
select { targetChatIdColumn.eq(chatId.chatId) }.limit(1).firstOrNull() ?.let {
ChatSettings(
ChatId(it[targetChatIdColumn]),
@ -38,7 +40,7 @@ internal class WelcomeTable(
}.insertedCount > 0
}
fun unset(chatId: ChatId): Boolean = transaction(database) {
fun unset(chatId: IdChatIdentifier): Boolean = transaction(database) {
deleteWhere { targetChatIdColumn.eq(chatId.chatId) } > 0
}
}

View File

@ -1,12 +1,13 @@
package model
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.MessageIdentifier
import kotlinx.serialization.Serializable
@Serializable
internal data class ChatSettings(
val targetChatId: ChatId,
val sourceChatId: ChatId,
val targetChatId: IdChatIdentifier,
val sourceChatId: IdChatIdentifier,
val sourceMessageId: MessageIdentifier
)