diff --git a/webserver/src/main/kotlin/space/mori/chzzk_bot/webserver/routes/ApiCommandRoutes.kt b/webserver/src/main/kotlin/space/mori/chzzk_bot/webserver/routes/ApiCommandRoutes.kt index 89fd5b4..da2daa4 100644 --- a/webserver/src/main/kotlin/space/mori/chzzk_bot/webserver/routes/ApiCommandRoutes.kt +++ b/webserver/src/main/kotlin/space/mori/chzzk_bot/webserver/routes/ApiCommandRoutes.kt @@ -54,7 +54,7 @@ fun Routing.apiCommandRoutes() { return@put } - if(!user.managers.any { it.naverId == session?.id } && user.naverId != session?.id) { + if(!user.managers?.any { it.naverId == session?.id }!! ?: true && user.naverId != session?.id) { call.respond(HttpStatusCode.BadRequest, "User does not exist") return@put } @@ -84,7 +84,7 @@ fun Routing.apiCommandRoutes() { return@post } - if(!user.managers.any { it.naverId == session?.id } && user.naverId != session?.id) { + if(!user.managers?.any { it.naverId == session?.id }!! ?: true && user.naverId != session?.id) { call.respond(HttpStatusCode.BadRequest, "User does not exist") return@post } @@ -119,7 +119,7 @@ fun Routing.apiCommandRoutes() { return@delete } - if(!user.managers.any { it.naverId == session?.id } && user.naverId != session?.id) { + if(!user.managers?.any { it.naverId == session?.id }!! ?: true && user.naverId != session?.id) { call.respond(HttpStatusCode.BadRequest, "User does not exist") return@delete } diff --git a/webserver/src/main/kotlin/space/mori/chzzk_bot/webserver/routes/ApiDiscordRoutes.kt b/webserver/src/main/kotlin/space/mori/chzzk_bot/webserver/routes/ApiDiscordRoutes.kt index e225a31..f1ddb57 100644 --- a/webserver/src/main/kotlin/space/mori/chzzk_bot/webserver/routes/ApiDiscordRoutes.kt +++ b/webserver/src/main/kotlin/space/mori/chzzk_bot/webserver/routes/ApiDiscordRoutes.kt @@ -29,7 +29,7 @@ fun Route.apiDiscordRoutes() { call.respond(HttpStatusCode.BadRequest, "User does not exist") return@get } - if(!user.managers.any { it.naverId == session?.id } && user.naverId != session?.id) { + if(!user.managers?.any { it.naverId == session?.id }!! ?: true && user.naverId != session?.id) { call.respond(HttpStatusCode.BadRequest, "User does not exist") return@get } @@ -58,7 +58,7 @@ fun Route.apiDiscordRoutes() { call.respond(HttpStatusCode.BadRequest, "User does not exist") return@post } - if(!user.managers.any { it.naverId == session?.id } && user.naverId != session?.id) { + if(!user.managers?.any { it.naverId == session?.id }!! ?: true && user.naverId != session?.id) { call.respond(HttpStatusCode.BadRequest, "User does not exist") return@post } diff --git a/webserver/src/main/kotlin/space/mori/chzzk_bot/webserver/routes/ApiRoutes.kt b/webserver/src/main/kotlin/space/mori/chzzk_bot/webserver/routes/ApiRoutes.kt index 939a06f..c3a8829 100644 --- a/webserver/src/main/kotlin/space/mori/chzzk_bot/webserver/routes/ApiRoutes.kt +++ b/webserver/src/main/kotlin/space/mori/chzzk_bot/webserver/routes/ApiRoutes.kt @@ -116,8 +116,8 @@ fun Routing.apiRoutes() { songConfig.streamerOnly, songConfig.disabled )) - - returnUsers.addAll(user.subordinates.map { + val subordinates = user.subordinates ?: emptyList() + returnUsers.addAll(subordinates.map { val subStatus = user.token?.let { it1 -> getStreamInfo(it1) } return@map if (it.token == null || subStatus?.content == null) { null diff --git a/webserver/src/main/kotlin/space/mori/chzzk_bot/webserver/routes/ApiTimerRoutes.kt b/webserver/src/main/kotlin/space/mori/chzzk_bot/webserver/routes/ApiTimerRoutes.kt index c39c898..26fbe86 100644 --- a/webserver/src/main/kotlin/space/mori/chzzk_bot/webserver/routes/ApiTimerRoutes.kt +++ b/webserver/src/main/kotlin/space/mori/chzzk_bot/webserver/routes/ApiTimerRoutes.kt @@ -27,7 +27,7 @@ fun Routing.apiTimerRoutes() { return@get } - if(!user.managers.any { it.naverId == session?.id } && user.naverId != session?.id) { + if(!user.managers?.any { it.naverId == session?.id }!! ?: true && user.naverId != session?.id) { call.respond(HttpStatusCode.BadRequest, "User does not exist") return@get } @@ -51,7 +51,7 @@ fun Routing.apiTimerRoutes() { return@put } - if(!user.managers.any { it.naverId == session?.id } && user.naverId != session?.id) { + if(!user.managers?.any { it.naverId == session?.id }!! ?: true && user.naverId != session?.id) { call.respond(HttpStatusCode.BadRequest, "User does not exist") return@put }