From c612cb182255dc66be52e257f1fe8b658db08029 Mon Sep 17 00:00:00 2001 From: powercas_gamer Date: Sun, 12 Nov 2023 16:09:06 +0100 Subject: [PATCH] fix: spotless --- app/src/main/kotlin/dev/mizule/imagery/app/App.kt | 4 ---- .../main/kotlin/dev/mizule/imagery/app/auth/AuthHandler.kt | 5 ++--- .../main/kotlin/dev/mizule/imagery/app/auth/UserConfig.kt | 5 ++--- app/src/main/kotlin/dev/mizule/imagery/app/config/Config.kt | 3 +-- .../main/kotlin/dev/mizule/imagery/app/launcher/Launcher.kt | 2 -- app/src/main/kotlin/dev/mizule/imagery/app/model/Roles.kt | 4 ++-- 6 files changed, 7 insertions(+), 16 deletions(-) diff --git a/app/src/main/kotlin/dev/mizule/imagery/app/App.kt b/app/src/main/kotlin/dev/mizule/imagery/app/App.kt index 11b22bf..a67f262 100644 --- a/app/src/main/kotlin/dev/mizule/imagery/app/App.kt +++ b/app/src/main/kotlin/dev/mizule/imagery/app/App.kt @@ -28,7 +28,6 @@ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import com.github.benmanes.caffeine.cache.Cache import com.github.benmanes.caffeine.cache.Caffeine import dev.mizule.imagery.app.auth.AuthHandler -import dev.mizule.imagery.app.auth.UserConfig import dev.mizule.imagery.app.config.Config import dev.mizule.imagery.app.model.ImageLookupResult import dev.mizule.imagery.app.model.Roles @@ -100,9 +99,7 @@ class App(private val config: Config, usersConfigOption: String) { throw io.javalin.http.ForbiddenResponse() } else { logger.info { "Token: $token Authorized" } - } - } } javalin.post("/upload", ::handleFileUpload, Roles.PRIVATE) @@ -123,7 +120,6 @@ class App(private val config: Config, usersConfigOption: String) { } val token = ctx.header("Authorization") ?: throw io.javalin.http.ForbiddenResponse() - val uploadedFile = UploadedFile( id, authHandler.getUserByToken(token)?.username ?: "Unknown", diff --git a/app/src/main/kotlin/dev/mizule/imagery/app/auth/AuthHandler.kt b/app/src/main/kotlin/dev/mizule/imagery/app/auth/AuthHandler.kt index f778f54..4e7b1e8 100644 --- a/app/src/main/kotlin/dev/mizule/imagery/app/auth/AuthHandler.kt +++ b/app/src/main/kotlin/dev/mizule/imagery/app/auth/AuthHandler.kt @@ -5,7 +5,6 @@ import org.spongepowered.configurate.kotlin.extensions.get import org.spongepowered.configurate.kotlin.objectMapperFactory import java.security.SecureRandom import java.util.Base64 -import java.util.HashMap import kotlin.io.path.Path import kotlin.io.path.exists @@ -46,7 +45,7 @@ class AuthHandler(userConfigPath: String) { fun createUser(name: String): User { val secret = ByteArray(48) SecureRandom().nextBytes(secret) - return createUser(name, Base64.getEncoder().encodeToString(secret)); + return createUser(name, Base64.getEncoder().encodeToString(secret)) } fun isAuthorized(token: String): Boolean { @@ -65,4 +64,4 @@ class AuthHandler(userConfigPath: String) { usersLoader.save(usersNode) return user } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/dev/mizule/imagery/app/auth/UserConfig.kt b/app/src/main/kotlin/dev/mizule/imagery/app/auth/UserConfig.kt index 95f5956..17384fd 100644 --- a/app/src/main/kotlin/dev/mizule/imagery/app/auth/UserConfig.kt +++ b/app/src/main/kotlin/dev/mizule/imagery/app/auth/UserConfig.kt @@ -1,10 +1,9 @@ package dev.mizule.imagery.app.auth import org.spongepowered.configurate.objectmapping.ConfigSerializable -import org.spongepowered.configurate.objectmapping.meta.Comment @ConfigSerializable data class UserConfig( - val users: MutableList = mutableListOf() -) \ No newline at end of file + val users: MutableList = mutableListOf(), +) diff --git a/app/src/main/kotlin/dev/mizule/imagery/app/config/Config.kt b/app/src/main/kotlin/dev/mizule/imagery/app/config/Config.kt index 50341c5..03bc228 100644 --- a/app/src/main/kotlin/dev/mizule/imagery/app/config/Config.kt +++ b/app/src/main/kotlin/dev/mizule/imagery/app/config/Config.kt @@ -24,7 +24,6 @@ */ package dev.mizule.imagery.app.config -import dev.mizule.imagery.app.App import org.spongepowered.configurate.objectmapping.ConfigSerializable import org.spongepowered.configurate.objectmapping.meta.Comment @@ -41,4 +40,4 @@ data class Config( @Comment("The path to the uploaded file storage directory.") val storagePath: String = "./storage", -) \ No newline at end of file +) diff --git a/app/src/main/kotlin/dev/mizule/imagery/app/launcher/Launcher.kt b/app/src/main/kotlin/dev/mizule/imagery/app/launcher/Launcher.kt index 1bb54f5..5455db4 100644 --- a/app/src/main/kotlin/dev/mizule/imagery/app/launcher/Launcher.kt +++ b/app/src/main/kotlin/dev/mizule/imagery/app/launcher/Launcher.kt @@ -27,13 +27,11 @@ package dev.mizule.imagery.app.launcher import dev.mizule.imagery.app.App -import dev.mizule.imagery.app.auth.UserConfig import dev.mizule.imagery.app.config.Config import kotlinx.cli.ArgParser import kotlinx.cli.ArgType import kotlinx.cli.default import org.spongepowered.configurate.hocon.HoconConfigurationLoader -import org.spongepowered.configurate.jackson.JacksonConfigurationLoader import org.spongepowered.configurate.kotlin.extensions.get import org.spongepowered.configurate.kotlin.objectMapperFactory import kotlin.io.path.Path diff --git a/app/src/main/kotlin/dev/mizule/imagery/app/model/Roles.kt b/app/src/main/kotlin/dev/mizule/imagery/app/model/Roles.kt index aba845c..9f28774 100644 --- a/app/src/main/kotlin/dev/mizule/imagery/app/model/Roles.kt +++ b/app/src/main/kotlin/dev/mizule/imagery/app/model/Roles.kt @@ -5,5 +5,5 @@ import io.javalin.security.RouteRole enum class Roles : RouteRole { PUBLIC, - PRIVATE -} \ No newline at end of file + PRIVATE, +}