From 4361fb2db51aff07bc10ed7dc8eb375771dbf8f2 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Tue, 19 Sep 2023 13:05:40 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20Ktor=E3=82=92=E9=9D=9E=E6=8E=A8?= =?UTF-8?q?=E5=A5=A8=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/dev/usbharu/hideout/Application.kt | 3 +++ .../dev/usbharu/hideout/config/Config.kt | 7 ++++++ .../usbharu/hideout/plugins/Compression.kt | 1 + .../dev/usbharu/hideout/plugins/HTTP.kt | 1 + .../dev/usbharu/hideout/plugins/Koin.kt | 1 + .../dev/usbharu/hideout/plugins/Monitoring.kt | 1 + .../dev/usbharu/hideout/plugins/Routing.kt | 1 + .../dev/usbharu/hideout/plugins/Security.kt | 1 + .../usbharu/hideout/plugins/Serialization.kt | 1 + .../usbharu/hideout/plugins/StaticRouting.kt | 1 + .../usbharu/hideout/plugins/StatusPages.kt | 1 + .../hideout/routing/RegisterRouting.kt | 1 + .../routing/activitypub/InboxRouting.kt | 1 + .../routing/activitypub/OutboxRouting.kt | 1 + .../routing/activitypub/UserRouting.kt | 2 ++ .../hideout/routing/api/internal/v1/Auth.kt | 1 + .../hideout/routing/api/internal/v1/Posts.kt | 1 + .../hideout/routing/api/internal/v1/Users.kt | 1 + .../routing/wellknown/WebfingerRouting.kt | 1 + src/main/resources/openapi/mastodon.yaml | 22 +++++++++++++++++++ 20 files changed, 50 insertions(+) create mode 100644 src/main/resources/openapi/mastodon.yaml diff --git a/src/main/kotlin/dev/usbharu/hideout/Application.kt b/src/main/kotlin/dev/usbharu/hideout/Application.kt index 6a745122..5b1530a4 100644 --- a/src/main/kotlin/dev/usbharu/hideout/Application.kt +++ b/src/main/kotlin/dev/usbharu/hideout/Application.kt @@ -39,6 +39,7 @@ import org.koin.ksp.generated.module import org.koin.ktor.ext.inject import java.util.concurrent.TimeUnit +@Deprecated("Ktor is deprecated") fun main(args: Array): Unit = io.ktor.server.cio.EngineMain.main(args) val Application.property: Application.(propertyName: String) -> String @@ -52,6 +53,7 @@ val Application.propertyOrNull: Application.(propertyName: String) -> String? } // application.conf references the main function. This annotation prevents the IDE from marking it as unused. +@Deprecated("Ktor is deprecated") @Suppress("unused", "LongMethod") fun Application.parent() { Config.configData = ConfigData( @@ -136,6 +138,7 @@ fun Application.parent() { ) } +@Deprecated("Ktor is deprecated") @Suppress("unused") fun Application.worker() { val kJob = kjob(ExposedKJob) { diff --git a/src/main/kotlin/dev/usbharu/hideout/config/Config.kt b/src/main/kotlin/dev/usbharu/hideout/config/Config.kt index 8acf1113..1623ff25 100644 --- a/src/main/kotlin/dev/usbharu/hideout/config/Config.kt +++ b/src/main/kotlin/dev/usbharu/hideout/config/Config.kt @@ -3,10 +3,12 @@ package dev.usbharu.hideout.config import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +@Deprecated("Config is deprecated") object Config { var configData: ConfigData = ConfigData() } +@Deprecated("Config is deprecated") data class ConfigData( val url: String = "", val domain: String = url.substringAfter("://").substringBeforeLast(":"), @@ -14,12 +16,14 @@ data class ConfigData( val characterLimit: CharacterLimit = CharacterLimit() ) +@Deprecated("Config is deprecated") data class CharacterLimit( val general: General = General.of(), val post: Post = Post(), val account: Account = Account(), val instance: Instance = Instance() ) { + @Deprecated("Config is deprecated") data class General private constructor( val url: Int, val domain: Int, @@ -39,17 +43,20 @@ data class CharacterLimit( } } + @Deprecated("Config is deprecated") data class Post( val text: Int = 3000, val overview: Int = 3000 ) + @Deprecated("Config is deprecated") data class Account( val id: Int = 300, val name: Int = 300, val description: Int = 10000 ) + @Deprecated("Config is deprecated") data class Instance( val name: Int = 600, val description: Int = 10000 diff --git a/src/main/kotlin/dev/usbharu/hideout/plugins/Compression.kt b/src/main/kotlin/dev/usbharu/hideout/plugins/Compression.kt index e13fa4c9..d1387d28 100644 --- a/src/main/kotlin/dev/usbharu/hideout/plugins/Compression.kt +++ b/src/main/kotlin/dev/usbharu/hideout/plugins/Compression.kt @@ -4,6 +4,7 @@ import io.ktor.http.* import io.ktor.server.application.* import io.ktor.server.plugins.compression.* +@Deprecated("Ktor is deprecated") fun Application.configureCompression() { install(Compression) { gzip { diff --git a/src/main/kotlin/dev/usbharu/hideout/plugins/HTTP.kt b/src/main/kotlin/dev/usbharu/hideout/plugins/HTTP.kt index 98e5e259..44f88bbd 100644 --- a/src/main/kotlin/dev/usbharu/hideout/plugins/HTTP.kt +++ b/src/main/kotlin/dev/usbharu/hideout/plugins/HTTP.kt @@ -4,6 +4,7 @@ import io.ktor.server.application.* import io.ktor.server.plugins.defaultheaders.* import io.ktor.server.plugins.forwardedheaders.* +@Deprecated("Ktor is deprecated") fun Application.configureHTTP() { // install(CORS) { // allowMethod(HttpMethod.Options) diff --git a/src/main/kotlin/dev/usbharu/hideout/plugins/Koin.kt b/src/main/kotlin/dev/usbharu/hideout/plugins/Koin.kt index e7a9e249..a7b1ed16 100644 --- a/src/main/kotlin/dev/usbharu/hideout/plugins/Koin.kt +++ b/src/main/kotlin/dev/usbharu/hideout/plugins/Koin.kt @@ -5,6 +5,7 @@ import org.koin.core.module.Module import org.koin.ktor.plugin.Koin import org.koin.logger.slf4jLogger +@Deprecated("Ktor is deprecated") fun Application.configureKoin(vararg module: Module) { install(Koin) { slf4jLogger() diff --git a/src/main/kotlin/dev/usbharu/hideout/plugins/Monitoring.kt b/src/main/kotlin/dev/usbharu/hideout/plugins/Monitoring.kt index 2f33df7a..a2345312 100644 --- a/src/main/kotlin/dev/usbharu/hideout/plugins/Monitoring.kt +++ b/src/main/kotlin/dev/usbharu/hideout/plugins/Monitoring.kt @@ -4,6 +4,7 @@ import io.ktor.server.application.* import io.ktor.server.plugins.callloging.* import org.slf4j.event.Level +@Deprecated("Ktor is deprecated") fun Application.configureMonitoring() { install(CallLogging) { level = Level.INFO diff --git a/src/main/kotlin/dev/usbharu/hideout/plugins/Routing.kt b/src/main/kotlin/dev/usbharu/hideout/plugins/Routing.kt index 178127b5..7a11e3be 100644 --- a/src/main/kotlin/dev/usbharu/hideout/plugins/Routing.kt +++ b/src/main/kotlin/dev/usbharu/hideout/plugins/Routing.kt @@ -22,6 +22,7 @@ import io.ktor.server.application.* import io.ktor.server.plugins.autohead.* import io.ktor.server.routing.* +@Deprecated("Ktor is deprecated") @Suppress("LongParameterList") fun Application.configureRouting( httpSignatureVerifyService: HttpSignatureVerifyService, diff --git a/src/main/kotlin/dev/usbharu/hideout/plugins/Security.kt b/src/main/kotlin/dev/usbharu/hideout/plugins/Security.kt index a4d7d34d..104c5844 100644 --- a/src/main/kotlin/dev/usbharu/hideout/plugins/Security.kt +++ b/src/main/kotlin/dev/usbharu/hideout/plugins/Security.kt @@ -13,6 +13,7 @@ import io.ktor.server.routing.* const val TOKEN_AUTH = "jwt-auth" +@Deprecated("Ktor is deprecated") @Suppress("MagicNumber") fun Application.configureSecurity( jwkProvider: JwkProvider, diff --git a/src/main/kotlin/dev/usbharu/hideout/plugins/Serialization.kt b/src/main/kotlin/dev/usbharu/hideout/plugins/Serialization.kt index 09edfe72..1e81e2e7 100644 --- a/src/main/kotlin/dev/usbharu/hideout/plugins/Serialization.kt +++ b/src/main/kotlin/dev/usbharu/hideout/plugins/Serialization.kt @@ -8,6 +8,7 @@ import io.ktor.serialization.jackson.* import io.ktor.server.application.* import io.ktor.server.plugins.contentnegotiation.* +@Deprecated("Ktor is deprecated") fun Application.configureSerialization() { install(ContentNegotiation) { jackson { diff --git a/src/main/kotlin/dev/usbharu/hideout/plugins/StaticRouting.kt b/src/main/kotlin/dev/usbharu/hideout/plugins/StaticRouting.kt index 58888b99..c4cc37d6 100644 --- a/src/main/kotlin/dev/usbharu/hideout/plugins/StaticRouting.kt +++ b/src/main/kotlin/dev/usbharu/hideout/plugins/StaticRouting.kt @@ -6,6 +6,7 @@ import io.ktor.server.http.content.* import io.ktor.server.response.* import io.ktor.server.routing.* +@Deprecated("Ktor is deprecated") fun Application.configureStaticRouting() { routing { get("/") { diff --git a/src/main/kotlin/dev/usbharu/hideout/plugins/StatusPages.kt b/src/main/kotlin/dev/usbharu/hideout/plugins/StatusPages.kt index e0305692..9a9ea5ac 100644 --- a/src/main/kotlin/dev/usbharu/hideout/plugins/StatusPages.kt +++ b/src/main/kotlin/dev/usbharu/hideout/plugins/StatusPages.kt @@ -6,6 +6,7 @@ import io.ktor.server.application.* import io.ktor.server.plugins.statuspages.* import io.ktor.server.response.* +@Deprecated("Ktor is deprecated") fun Application.configureStatusPages() { install(StatusPages) { exception { call, cause -> diff --git a/src/main/kotlin/dev/usbharu/hideout/routing/RegisterRouting.kt b/src/main/kotlin/dev/usbharu/hideout/routing/RegisterRouting.kt index 8628f340..232ee918 100644 --- a/src/main/kotlin/dev/usbharu/hideout/routing/RegisterRouting.kt +++ b/src/main/kotlin/dev/usbharu/hideout/routing/RegisterRouting.kt @@ -8,6 +8,7 @@ import io.ktor.server.request.* import io.ktor.server.response.* import io.ktor.server.routing.* +@Deprecated("Ktor is deprecated") fun Application.register(userApiService: UserApiService) { routing { get("/register") { diff --git a/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/InboxRouting.kt b/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/InboxRouting.kt index dbdcd666..e1204f39 100644 --- a/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/InboxRouting.kt +++ b/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/InboxRouting.kt @@ -11,6 +11,7 @@ import io.ktor.server.request.* import io.ktor.server.response.* import io.ktor.server.routing.* +@Deprecated("Ktor is deprecated") fun Routing.inbox( httpSignatureVerifyService: HttpSignatureVerifyService, apService: dev.usbharu.hideout.service.ap.APService diff --git a/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/OutboxRouting.kt b/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/OutboxRouting.kt index 3ad07137..9f6c2689 100644 --- a/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/OutboxRouting.kt +++ b/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/OutboxRouting.kt @@ -5,6 +5,7 @@ import io.ktor.server.application.* import io.ktor.server.response.* import io.ktor.server.routing.* +@Deprecated("Ktor is deprecated") fun Routing.outbox() { route("/outbox") { get { diff --git a/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/UserRouting.kt b/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/UserRouting.kt index 0d0dbea5..39d7a299 100644 --- a/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/UserRouting.kt +++ b/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/UserRouting.kt @@ -15,6 +15,7 @@ import io.ktor.server.request.* import io.ktor.server.response.* import io.ktor.server.routing.* +@Deprecated("Ktor is deprecated") fun Routing.usersAP( apUserService: APUserService, userQueryService: UserQueryService, @@ -50,6 +51,7 @@ fun Routing.usersAP( } } +@Deprecated("Ktor is deprecated") class ContentTypeRouteSelector(private vararg val contentType: ContentType) : RouteSelector() { override fun evaluate(context: RoutingResolveContext, segmentIndex: Int): RouteSelectorEvaluation { context.call.application.log.debug("Accept: ${context.call.request.accept()}") diff --git a/src/main/kotlin/dev/usbharu/hideout/routing/api/internal/v1/Auth.kt b/src/main/kotlin/dev/usbharu/hideout/routing/api/internal/v1/Auth.kt index 610d39b4..4a70ab5b 100644 --- a/src/main/kotlin/dev/usbharu/hideout/routing/api/internal/v1/Auth.kt +++ b/src/main/kotlin/dev/usbharu/hideout/routing/api/internal/v1/Auth.kt @@ -11,6 +11,7 @@ import io.ktor.server.request.* import io.ktor.server.response.* import io.ktor.server.routing.* +@Deprecated("Ktor is deprecated") fun Route.auth(userAuthApiService: UserAuthApiService) { post("/login") { val loginUser = call.receive() diff --git a/src/main/kotlin/dev/usbharu/hideout/routing/api/internal/v1/Posts.kt b/src/main/kotlin/dev/usbharu/hideout/routing/api/internal/v1/Posts.kt index a3c3cd23..3137bc6c 100644 --- a/src/main/kotlin/dev/usbharu/hideout/routing/api/internal/v1/Posts.kt +++ b/src/main/kotlin/dev/usbharu/hideout/routing/api/internal/v1/Posts.kt @@ -14,6 +14,7 @@ import io.ktor.server.request.* import io.ktor.server.response.* import io.ktor.server.routing.* +@Deprecated("Ktor is deprecated") @Suppress("LongMethod") fun Route.posts(postApiService: PostApiService) { route("/posts") { diff --git a/src/main/kotlin/dev/usbharu/hideout/routing/api/internal/v1/Users.kt b/src/main/kotlin/dev/usbharu/hideout/routing/api/internal/v1/Users.kt index dd7b64f9..96f4f198 100644 --- a/src/main/kotlin/dev/usbharu/hideout/routing/api/internal/v1/Users.kt +++ b/src/main/kotlin/dev/usbharu/hideout/routing/api/internal/v1/Users.kt @@ -16,6 +16,7 @@ import io.ktor.server.request.* import io.ktor.server.response.* import io.ktor.server.routing.* +@Deprecated("Ktor is deprecated") @Suppress("LongMethod", "CognitiveComplexMethod") fun Route.users(userService: UserService, userApiService: UserApiService) { route("/users") { diff --git a/src/main/kotlin/dev/usbharu/hideout/routing/wellknown/WebfingerRouting.kt b/src/main/kotlin/dev/usbharu/hideout/routing/wellknown/WebfingerRouting.kt index 9642afd0..efa782c9 100644 --- a/src/main/kotlin/dev/usbharu/hideout/routing/wellknown/WebfingerRouting.kt +++ b/src/main/kotlin/dev/usbharu/hideout/routing/wellknown/WebfingerRouting.kt @@ -11,6 +11,7 @@ import io.ktor.server.application.* import io.ktor.server.response.* import io.ktor.server.routing.* +@Deprecated("Ktor is deprecated") fun Routing.webfinger(webFingerApiService: WebFingerApiService) { route("/.well-known/webfinger") { get { diff --git a/src/main/resources/openapi/mastodon.yaml b/src/main/resources/openapi/mastodon.yaml new file mode 100644 index 00000000..dbcf6195 --- /dev/null +++ b/src/main/resources/openapi/mastodon.yaml @@ -0,0 +1,22 @@ +openapi: 3.0.3 +info: + title: Hideout Mastodon Compatible API + description: Hideout Mastodon Compatible API + version: 1.0.0 +servers: + - url: 'https://test-hideout.usbharu.dev' +paths: + +components: + schemas: + Account: + type: object + properties: + id: + type: string + username: + type: string + acct: + type: string + url: + type: string