mirror of
https://github.com/dalbodeule/chibot-chzzk-bot.git
synced 2025-08-07 21:01:14 +00:00
debug discordHook logics, session fix.
- DiscordHook normal respond is not defined - add MariadbSessionStorage
This commit is contained in:
@@ -47,7 +47,7 @@ val server = embeddedServer(Netty, port = 8080, ) {
|
||||
})
|
||||
}
|
||||
install(Sessions) {
|
||||
cookie<UserSession>("user_session", storage = SessionStorageMemory()) {}
|
||||
cookie<UserSession>("user_session", storage = MariadbSessionStorage()) {}
|
||||
}
|
||||
install(Authentication) {
|
||||
oauth("auth-oauth-naver") {
|
||||
|
@@ -0,0 +1,32 @@
|
||||
package space.mori.chzzk_bot.webserver
|
||||
|
||||
import io.ktor.server.sessions.*
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import space.mori.chzzk_bot.common.models.Session
|
||||
import space.mori.chzzk_bot.common.models.Sessions as SessionTable
|
||||
|
||||
class MariadbSessionStorage: SessionStorage {
|
||||
override suspend fun invalidate(id: String) {
|
||||
return transaction {
|
||||
val session = Session.find(
|
||||
SessionTable.key eq id
|
||||
).firstOrNull()
|
||||
session?.delete()
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun read(id: String): String {
|
||||
return transaction {
|
||||
val session = Session.find(SessionTable.key eq id).firstOrNull()
|
||||
?: throw NoSuchElementException("Session $id not found")
|
||||
session.value
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun write(id: String, value: String) {
|
||||
Session.findSingleByAndUpdate(SessionTable.key eq id) {
|
||||
it.value = value
|
||||
}
|
||||
}
|
||||
}
|
@@ -49,12 +49,12 @@ fun Route.apiDiscordRoutes() {
|
||||
return@get
|
||||
}
|
||||
|
||||
|
||||
call.respond(HttpStatusCode.OK)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data class DiscordRequireRegisterDTO(
|
||||
val user: String,
|
||||
val passkey: String
|
||||
val token: String
|
||||
)
|
Reference in New Issue
Block a user