diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/accounts/GetAccountApplicationService.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/accounts/GetAccountApplicationService.kt index 27f861c7..0696b53a 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/accounts/GetAccountApplicationService.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/accounts/GetAccountApplicationService.kt @@ -31,10 +31,11 @@ class GetAccountApplicationService(private val accountQueryService: AccountQuery logger ) { override suspend fun internalExecute(command: GetAccount, principal: LocalUser): Account { - return accountQueryService.findById(command.accountId.toLong()) ?: throw Exception("Account not found") + return accountQueryService.findById(command.accountId.toLong()) + ?: throw IllegalArgumentException("Account ${command.accountId} not found") } companion object { private val logger = LoggerFactory.getLogger(GetAccountApplicationService::class.java) } -} \ No newline at end of file +} diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/filter/DeleteFilterV1ApplicationService.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/filter/DeleteFilterV1ApplicationService.kt index dd48a024..4961d383 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/filter/DeleteFilterV1ApplicationService.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/filter/DeleteFilterV1ApplicationService.kt @@ -28,7 +28,8 @@ import org.springframework.stereotype.Service @Service class DeleteFilterV1ApplicationService(private val filterRepository: FilterRepository, transaction: Transaction) : LocalUserAbstractApplicationService( - transaction, logger + transaction, + logger ) { override suspend fun internalExecute(command: DeleteFilterV1, principal: LocalUser) { val filter = filterRepository.findByFilterKeywordId(FilterKeywordId(command.filterKeywordId)) @@ -42,4 +43,4 @@ class DeleteFilterV1ApplicationService(private val filterRepository: FilterRepos companion object { private val logger = LoggerFactory.getLogger(DeleteFilterV1ApplicationService::class.java) } -} \ No newline at end of file +} diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/filter/GetFilterV1.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/filter/GetFilterV1.kt index e6d1c26c..04c93530 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/filter/GetFilterV1.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/filter/GetFilterV1.kt @@ -16,4 +16,4 @@ package dev.usbharu.hideout.mastodon.application.filter -data class GetFilterV1(val filterKeywordId: Long) \ No newline at end of file +data class GetFilterV1(val filterKeywordId: Long) diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/filter/GetFilterV1ApplicationService.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/filter/GetFilterV1ApplicationService.kt index e79c8513..6f485361 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/filter/GetFilterV1ApplicationService.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/filter/GetFilterV1ApplicationService.kt @@ -31,7 +31,8 @@ import org.springframework.stereotype.Repository @Repository class GetFilterV1ApplicationService(private val filterRepository: FilterRepository, transaction: Transaction) : AbstractApplicationService( - transaction, logger + transaction, + logger ) { override suspend fun internalExecute(command: GetFilterV1, principal: Principal): V1Filter { val filter = filterRepository.findByFilterKeywordId(FilterKeywordId(command.filterKeywordId)) @@ -63,4 +64,4 @@ class GetFilterV1ApplicationService(private val filterRepository: FilterReposito companion object { private val logger = LoggerFactory.getLogger(GetFilterV1ApplicationService::class.java) } -} \ No newline at end of file +} diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/status/GetStatusApplicationService.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/status/GetStatusApplicationService.kt index f5139192..5331369e 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/status/GetStatusApplicationService.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/status/GetStatusApplicationService.kt @@ -32,13 +32,12 @@ class GetStatusApplicationService( transaction, logger ) { - companion object { - val logger = LoggerFactory.getLogger(GetStatusApplicationService::class.java)!! - } - override suspend fun internalExecute(command: GetStatus, principal: Principal): Status { return statusQueryService.findByPostId(command.id.toLong(), principal) ?: throw IllegalArgumentException("Post ${command.id} not found.") - } -} \ No newline at end of file + + companion object { + val logger = LoggerFactory.getLogger(GetStatusApplicationService::class.java)!! + } +} diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/config/MastodonSecurityConfig.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/config/MastodonSecurityConfig.kt index 513994b1..b67cc7a5 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/config/MastodonSecurityConfig.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/config/MastodonSecurityConfig.kt @@ -109,4 +109,4 @@ class MastodonSecurityConfig { return http.build() } -} \ No newline at end of file +} diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/external/RoleHierarchyAuthorizationManagerFactory.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/external/RoleHierarchyAuthorizationManagerFactory.kt index 66395c20..6b60111b 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/external/RoleHierarchyAuthorizationManagerFactory.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/external/RoleHierarchyAuthorizationManagerFactory.kt @@ -29,4 +29,4 @@ class RoleHierarchyAuthorizationManagerFactory(private val roleHierarchy: RoleHi hasAuthority.setRoleHierarchy(roleHierarchy) return hasAuthority } -} \ No newline at end of file +} diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/exposedquery/ExposedAccountQueryService.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/exposedquery/ExposedAccountQueryServiceImpl.kt similarity index 96% rename from hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/exposedquery/ExposedAccountQueryService.kt rename to hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/exposedquery/ExposedAccountQueryServiceImpl.kt index 41ca4ab2..f4332cc9 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/exposedquery/ExposedAccountQueryService.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/exposedquery/ExposedAccountQueryServiceImpl.kt @@ -25,7 +25,7 @@ import org.jetbrains.exposed.sql.selectAll import org.springframework.stereotype.Repository @Repository -class AccountQueryServiceImpl(private val applicationConfig: ApplicationConfig) : AccountQueryService { +class ExposedAccountQueryServiceImpl(private val applicationConfig: ApplicationConfig) : AccountQueryService { override suspend fun findById(accountId: Long): Account? { val query = Actors.selectAll().where { Actors.id eq accountId } @@ -70,4 +70,4 @@ class AccountQueryServiceImpl(private val applicationConfig: ApplicationConfig) followingCount = resultRow[Actors.followingCount], ) } -} \ No newline at end of file +} diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/exposedquery/ExposedStatusQueryService.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/exposedquery/ExposedStatusQueryService.kt index 8208256d..23ea2914 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/exposedquery/ExposedStatusQueryService.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/exposedquery/ExposedStatusQueryService.kt @@ -55,7 +55,8 @@ class StatusQueryServiceImpl : StatusQueryService { .leftJoin( relationshipsAlias, onColumn = { Posts.actorId }, - otherColumn = { relationshipsAlias[Relationships.targetActorId] }) + otherColumn = { relationshipsAlias[Relationships.targetActorId] } + ) .select(Posts.columns) .where { Posts.visibility eq Visibility.PUBLIC.name or @@ -318,4 +319,4 @@ fun EntityMedia.toMediaAttachments(): MediaAttachment = MediaAttachment( description = description?.description, blurhash = blurHash?.hash, textUrl = url.toString() -) \ No newline at end of file +) diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringAccountApi.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringAccountApi.kt index 15b9226b..6723e9ec 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringAccountApi.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringAccountApi.kt @@ -48,6 +48,7 @@ import org.springframework.http.ResponseEntity import org.springframework.stereotype.Controller @Controller +@Suppress("LongParameterList") class SpringAccountApi( private val getUserDetailApplicationService: GetUserDetailApplicationService, private val getAccountApplicationService: GetAccountApplicationService, @@ -64,7 +65,6 @@ class SpringAccountApi( private val principalContextHolder: SpringSecurityOauth2PrincipalContextHolder ) : AccountApi { - override suspend fun apiV1AccountsIdBlockPost(id: String): ResponseEntity { userBlockApplicationService.execute(Block(id.toLong()), principalContextHolder.getPrincipal()) return fetchRelationship(id) @@ -74,9 +74,9 @@ class SpringAccountApi( id: String, followRequestBody: FollowRequestBody?, ): ResponseEntity { - userFollowRequestApplicationService.execute( - FollowRequest(id.toLong()), principalContextHolder.getPrincipal() + FollowRequest(id.toLong()), + principalContextHolder.getPrincipal() ) return fetchRelationship(id) } @@ -110,53 +110,57 @@ class SpringAccountApi( override suspend fun apiV1AccountsIdGet(id: String): ResponseEntity { return ResponseEntity.ok( getAccountApplicationService.execute( - GetAccount(id), principalContextHolder.getPrincipal() + GetAccount(id), + principalContextHolder.getPrincipal() ) ) } override suspend fun apiV1AccountsIdMutePost(id: String): ResponseEntity { userMuteApplicationService.execute( - Mute(id.toLong()), principalContextHolder.getPrincipal() + Mute(id.toLong()), + principalContextHolder.getPrincipal() ) return fetchRelationship(id) } override suspend fun apiV1AccountsIdRemoveFromFollowersPost(id: String): ResponseEntity { userRemoveFromFollowersApplicationService.execute( - RemoveFromFollowers(id.toLong()), principalContextHolder.getPrincipal() + RemoveFromFollowers(id.toLong()), + principalContextHolder.getPrincipal() ) return fetchRelationship(id) } override suspend fun apiV1AccountsIdUnblockPost(id: String): ResponseEntity { userUnblockApplicationService.execute( - Unblock(id.toLong()), principalContextHolder.getPrincipal() + Unblock(id.toLong()), + principalContextHolder.getPrincipal() ) return fetchRelationship(id) } override suspend fun apiV1AccountsIdUnfollowPost(id: String): ResponseEntity { userUnfollowApplicationService.execute( - Unfollow(id.toLong()), principalContextHolder.getPrincipal() + Unfollow(id.toLong()), + principalContextHolder.getPrincipal() ) return fetchRelationship(id) } override suspend fun apiV1AccountsIdUnmutePost(id: String): ResponseEntity { userUnmuteApplicationService.execute( - Unmute(id.toLong()), principalContextHolder.getPrincipal() + Unmute(id.toLong()), + principalContextHolder.getPrincipal() ) return fetchRelationship(id) } - override suspend fun apiV1AccountsPost(accountsCreateRequest: AccountsCreateRequest): ResponseEntity { - return super.apiV1AccountsPost(accountsCreateRequest) - } + override suspend fun apiV1AccountsPost(accountsCreateRequest: AccountsCreateRequest): ResponseEntity = + super.apiV1AccountsPost(accountsCreateRequest) - override suspend fun apiV1AccountsUpdateCredentialsPatch(updateCredentials: UpdateCredentials?): ResponseEntity { - return super.apiV1AccountsUpdateCredentialsPatch(updateCredentials) - } + override suspend fun apiV1AccountsUpdateCredentialsPatch(updateCredentials: UpdateCredentials?): ResponseEntity = + super.apiV1AccountsUpdateCredentialsPatch(updateCredentials) override suspend fun apiV1AccountsVerifyCredentialsGet(): ResponseEntity { val principal = principalContextHolder.getPrincipal() @@ -164,7 +168,8 @@ class SpringAccountApi( getUserDetailApplicationService.execute( GetUserDetail( principal.userDetailId?.id ?: throw PermissionDeniedException() - ), principal + ), + principal ) return ResponseEntity.ok( @@ -215,19 +220,18 @@ class SpringAccountApi( } override suspend fun apiV1FollowRequestsAccountIdAuthorizePost(accountId: String): ResponseEntity { - userAcceptFollowRequestApplicationService.execute( - AcceptFollowRequest(accountId.toLong()), principalContextHolder.getPrincipal() + AcceptFollowRequest(accountId.toLong()), + principalContextHolder.getPrincipal() ) return fetchRelationship(accountId) } override suspend fun apiV1FollowRequestsAccountIdRejectPost(accountId: String): ResponseEntity { - userRejectFollowRequestApplicationService.execute( - RejectFollowRequest(accountId.toLong()), principalContextHolder.getPrincipal() + RejectFollowRequest(accountId.toLong()), + principalContextHolder.getPrincipal() ) return fetchRelationship(accountId) } - -} \ No newline at end of file +} diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringAppApi.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringAppApi.kt index af17a724..8972ed46 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringAppApi.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringAppApi.kt @@ -29,7 +29,6 @@ import java.net.URI @Controller class SpringAppApi(private val registerApplicationApplicationService: RegisterApplicationApplicationService) : AppApi { override suspend fun apiV1AppsPost(appsRequest: AppsRequest): ResponseEntity { - val registerApplication = RegisterApplication( appsRequest.clientName, setOf(URI.create(appsRequest.redirectUris)), @@ -39,13 +38,13 @@ class SpringAppApi(private val registerApplicationApplicationService: RegisterAp val registeredApplication = registerApplicationApplicationService.execute(registerApplication, Anonymous) return ResponseEntity.ok( Application( - registeredApplication.name, - "invalid-vapid-key", - null, - registeredApplication.clientId, - registeredApplication.clientSecret, - appsRequest.redirectUris + name = registeredApplication.name, + vapidKey = "invalid-vapid-key", + website = null, + clientId = registeredApplication.clientId, + clientSecret = registeredApplication.clientSecret, + redirectUri = appsRequest.redirectUris ) ) } -} \ No newline at end of file +} diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringFilterApi.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringFilterApi.kt index 18e72dbb..788a4c29 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringFilterApi.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringFilterApi.kt @@ -47,7 +47,8 @@ class SpringFilterApi( override suspend fun apiV1FiltersIdDelete(id: String): ResponseEntity { return ResponseEntity.ok( deleteFilterV1ApplicationService.execute( - DeleteFilterV1(id.toLong()), principalContextHolder.getPrincipal() + DeleteFilterV1(id.toLong()), + principalContextHolder.getPrincipal() ) ) } @@ -55,7 +56,8 @@ class SpringFilterApi( override suspend fun apiV1FiltersIdGet(id: String): ResponseEntity { return ResponseEntity.ok( getFilterV1ApplicationService.execute( - GetFilterV1(id.toLong()), principalContextHolder.getPrincipal() + GetFilterV1(id.toLong()), + principalContextHolder.getPrincipal() ) ) } @@ -67,12 +69,9 @@ class SpringFilterApi( irreversible: Boolean?, wholeWord: Boolean?, expiresIn: Int?, - ): ResponseEntity { - return super.apiV1FiltersIdPut(id, phrase, context, irreversible, wholeWord, expiresIn) - } + ): ResponseEntity = super.apiV1FiltersIdPut(id, phrase, context, irreversible, wholeWord, expiresIn) override suspend fun apiV1FiltersPost(v1FilterPostRequest: V1FilterPostRequest): ResponseEntity { - val filterMode = if (v1FilterPostRequest.wholeWord == true) { FilterMode.WHOLE_WORD } else { @@ -89,13 +88,17 @@ class SpringFilterApi( }.toSet() val filter = userRegisterFilterApplicationService.execute( RegisterFilter( - v1FilterPostRequest.phrase, filterContext, FilterAction.WARN, + v1FilterPostRequest.phrase, + filterContext, + FilterAction.WARN, setOf(RegisterFilterKeyword(v1FilterPostRequest.phrase, filterMode)) - ), principalContextHolder.getPrincipal() + ), + principalContextHolder.getPrincipal() ) return ResponseEntity.ok( getFilterV1ApplicationService.execute( - GetFilterV1(filter.filterKeywords.first().id), principalContextHolder.getPrincipal() + GetFilterV1(filter.filterKeywords.first().id), + principalContextHolder.getPrincipal() ) ) } @@ -103,27 +106,25 @@ class SpringFilterApi( override suspend fun apiV2FiltersFilterIdKeywordsPost( filterId: String, filterKeywordsPostRequest: FilterKeywordsPostRequest, - ): ResponseEntity { - return super.apiV2FiltersFilterIdKeywordsPost(filterId, filterKeywordsPostRequest) - } + ): ResponseEntity = super.apiV2FiltersFilterIdKeywordsPost(filterId, filterKeywordsPostRequest) override suspend fun apiV2FiltersFilterIdStatusesPost( filterId: String, filterStatusRequest: FilterStatusRequest, - ): ResponseEntity { - return super.apiV2FiltersFilterIdStatusesPost(filterId, filterStatusRequest) - } + ): ResponseEntity = super.apiV2FiltersFilterIdStatusesPost(filterId, filterStatusRequest) override suspend fun apiV2FiltersIdDelete(id: String): ResponseEntity { userDeleteFilterApplicationService.execute( - DeleteFilter(id.toLong()), principalContextHolder.getPrincipal() + DeleteFilter(id.toLong()), + principalContextHolder.getPrincipal() ) return ResponseEntity.ok(Unit) } override suspend fun apiV2FiltersIdGet(id: String): ResponseEntity { val filter = userGetFilterApplicationService.execute( - GetFilter(id.toLong()), principalContextHolder.getPrincipal() + GetFilter(id.toLong()), + principalContextHolder.getPrincipal() ) return ResponseEntity.ok( filter(filter) @@ -146,7 +147,6 @@ class SpringFilterApi( filterAction = when (filter.filterAction) { FilterAction.WARN -> Filter.FilterAction.warn FilterAction.HIDE -> Filter.FilterAction.hide - }, keywords = filter.filterKeywords.map { FilterKeyword( @@ -154,7 +154,8 @@ class SpringFilterApi( it.keyword, it.filterMode == FilterMode.WHOLE_WORD ) - }, statuses = null + }, + statuses = null ) override suspend fun apiV2FiltersIdPut( @@ -164,29 +165,23 @@ class SpringFilterApi( filterAction: String?, expiresIn: Int?, keywordsAttributes: List?, - ): ResponseEntity { - return super.apiV2FiltersIdPut(id, title, context, filterAction, expiresIn, keywordsAttributes) - } + ): ResponseEntity = + super.apiV2FiltersIdPut(id, title, context, filterAction, expiresIn, keywordsAttributes) - override suspend fun apiV2FiltersKeywordsIdDelete(id: String): ResponseEntity { - return super.apiV2FiltersKeywordsIdDelete(id) - } + override suspend fun apiV2FiltersKeywordsIdDelete(id: String): ResponseEntity = + super.apiV2FiltersKeywordsIdDelete(id) - override suspend fun apiV2FiltersKeywordsIdGet(id: String): ResponseEntity { - return super.apiV2FiltersKeywordsIdGet(id) - } + override suspend fun apiV2FiltersKeywordsIdGet(id: String): ResponseEntity = + super.apiV2FiltersKeywordsIdGet(id) override suspend fun apiV2FiltersKeywordsIdPut( id: String, keyword: String?, wholeWord: Boolean?, regex: Boolean?, - ): ResponseEntity { - return super.apiV2FiltersKeywordsIdPut(id, keyword, wholeWord, regex) - } + ): ResponseEntity = super.apiV2FiltersKeywordsIdPut(id, keyword, wholeWord, regex) override suspend fun apiV2FiltersPost(filterPostRequest: FilterPostRequest): ResponseEntity { - val filter = userRegisterFilterApplicationService.execute( RegisterFilter( filterName = filterPostRequest.title, @@ -216,16 +211,15 @@ class SpringFilterApi( } ) }.toSet() - ), principalContextHolder.getPrincipal() + ), + principalContextHolder.getPrincipal() ) return ResponseEntity.ok(filter(filter)) } - override suspend fun apiV2FiltersStatusesIdDelete(id: String): ResponseEntity { - return ResponseEntity.notFound().build() - } + override suspend fun apiV2FiltersStatusesIdDelete(id: String): ResponseEntity = + ResponseEntity.notFound().build() - override suspend fun apiV2FiltersStatusesIdGet(id: String): ResponseEntity { - return ResponseEntity.notFound().build() - } -} \ No newline at end of file + override suspend fun apiV2FiltersStatusesIdGet(id: String): ResponseEntity = + ResponseEntity.notFound().build() +} diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringInstanceApi.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringInstanceApi.kt index b4aa3cf8..0841057f 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringInstanceApi.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringInstanceApi.kt @@ -17,23 +17,19 @@ package dev.usbharu.hideout.mastodon.interfaces.api import dev.usbharu.hideout.mastodon.interfaces.api.generated.InstanceApi -import dev.usbharu.hideout.mastodon.interfaces.api.generated.model.* -import kotlinx.coroutines.flow.Flow +import dev.usbharu.hideout.mastodon.interfaces.api.generated.model.ExtendedDescription +import dev.usbharu.hideout.mastodon.interfaces.api.generated.model.Instance +import dev.usbharu.hideout.mastodon.interfaces.api.generated.model.V1Instance import org.springframework.http.ResponseEntity import org.springframework.stereotype.Controller @Controller class SpringInstanceApi : InstanceApi { - override suspend fun apiV1InstanceExtendedDescriptionGet(): ResponseEntity { - return super.apiV1InstanceExtendedDescriptionGet() - } + override suspend fun apiV1InstanceExtendedDescriptionGet(): ResponseEntity = + super.apiV1InstanceExtendedDescriptionGet() - override suspend fun apiV1InstanceGet(): ResponseEntity { - return super.apiV1InstanceGet() - } + override suspend fun apiV1InstanceGet(): ResponseEntity = super.apiV1InstanceGet() - override suspend fun apiV2InstanceGet(): ResponseEntity { - return super.apiV2InstanceGet() - } -} \ No newline at end of file + override suspend fun apiV2InstanceGet(): ResponseEntity = super.apiV2InstanceGet() +} diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringMediaApi.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringMediaApi.kt index 0dff1da7..16fbe9cb 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringMediaApi.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringMediaApi.kt @@ -52,25 +52,26 @@ class SpringMediaApi( file.originalFilename ?: file.name, null, description - ), principalContextHolder.getPrincipal() + ), + principalContextHolder.getPrincipal() ) return ResponseEntity.ok( MediaAttachment( - media.id.toString(), - when (media.type) { + id = media.id.toString(), + type = when (media.type) { Image -> MediaAttachment.Type.image Video -> MediaAttachment.Type.video Audio -> MediaAttachment.Type.audio Unknown -> MediaAttachment.Type.unknown }, - media.url.toString(), - media.thumbprintURI?.toString(), - media.remoteURL?.toString(), - media.description, - media.blurHash, - media.url.toASCIIString() + url = media.url.toString(), + previewUrl = media.thumbprintURI?.toString(), + remoteUrl = media.remoteURL?.toString(), + description = media.description, + blurhash = media.blurHash, + textUrl = media.url.toASCIIString() ) ) } -} \ No newline at end of file +} diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringNotificationApi.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringNotificationApi.kt index cd196658..6f0746d0 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringNotificationApi.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringNotificationApi.kt @@ -18,21 +18,16 @@ package dev.usbharu.hideout.mastodon.interfaces.api import dev.usbharu.hideout.mastodon.interfaces.api.generated.NotificationsApi import dev.usbharu.hideout.mastodon.interfaces.api.generated.model.Notification -import kotlinx.coroutines.flow.Flow import org.springframework.http.ResponseEntity import org.springframework.stereotype.Controller @Controller class SpringNotificationApi : NotificationsApi { - override suspend fun apiV1NotificationsClearPost(): ResponseEntity { - return super.apiV1NotificationsClearPost() - } + override suspend fun apiV1NotificationsClearPost(): ResponseEntity = super.apiV1NotificationsClearPost() - override suspend fun apiV1NotificationsIdDismissPost(id: String): ResponseEntity { - return super.apiV1NotificationsIdDismissPost(id) - } + override suspend fun apiV1NotificationsIdDismissPost(id: String): ResponseEntity = + super.apiV1NotificationsIdDismissPost(id) - override suspend fun apiV1NotificationsIdGet(id: String): ResponseEntity { - return super.apiV1NotificationsIdGet(id) - } -} \ No newline at end of file + override suspend fun apiV1NotificationsIdGet(id: String): ResponseEntity = + super.apiV1NotificationsIdGet(id) +} diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringStatusApi.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringStatusApi.kt index 92b0e18a..5e045a59 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringStatusApi.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringStatusApi.kt @@ -34,25 +34,22 @@ class SpringStatusApi( private val getStatusApplicationService: GetStatusApplicationService, private val principalContextHolder: SpringSecurityOauth2PrincipalContextHolder ) : StatusApi { - override suspend fun apiV1StatusesIdEmojiReactionsEmojiDelete(id: String, emoji: String): ResponseEntity { - return super.apiV1StatusesIdEmojiReactionsEmojiDelete(id, emoji) - } + override suspend fun apiV1StatusesIdEmojiReactionsEmojiDelete(id: String, emoji: String): ResponseEntity = + super.apiV1StatusesIdEmojiReactionsEmojiDelete(id, emoji) - override suspend fun apiV1StatusesIdEmojiReactionsEmojiPut(id: String, emoji: String): ResponseEntity { - return super.apiV1StatusesIdEmojiReactionsEmojiPut(id, emoji) - } + override suspend fun apiV1StatusesIdEmojiReactionsEmojiPut(id: String, emoji: String): ResponseEntity = + super.apiV1StatusesIdEmojiReactionsEmojiPut(id, emoji) override suspend fun apiV1StatusesIdGet(id: String): ResponseEntity { - return ResponseEntity.ok( getStatusApplicationService.execute( - GetStatus(id), principalContextHolder.getPrincipal() + GetStatus(id), + principalContextHolder.getPrincipal() ) ) } - override suspend fun apiV1StatusesPost(statusesRequest: dev.usbharu.hideout.mastodon.interfaces.api.StatusesRequest): ResponseEntity { - + override suspend fun apiV1StatusesPost(statusesRequest: StatusesRequest): ResponseEntity { val principal = principalContextHolder.getPrincipal() val execute = registerLocalPostApplicationService.execute( RegisterLocalPost( @@ -69,14 +66,14 @@ class SpringStatusApi( replyId = statusesRequest.in_reply_to_id?.toLong(), sensitive = statusesRequest.sensitive == true, mediaIds = statusesRequest.media_ids.map { it.toLong() } - ), principal + ), + principal ) - val status = getStatusApplicationService.execute(GetStatus(execute.toString()), principal) return ResponseEntity.ok( status ) } -} \ No newline at end of file +} diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringTimelineApi.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringTimelineApi.kt index 2f631d70..2a27d263 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringTimelineApi.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringTimelineApi.kt @@ -20,4 +20,4 @@ import dev.usbharu.hideout.mastodon.interfaces.api.generated.TimelineApi import org.springframework.stereotype.Controller @Controller -class SpringTimelineApi : TimelineApi \ No newline at end of file +class SpringTimelineApi : TimelineApi diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/StatusesRequest.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/StatusesRequest.kt index 74c6cbd1..3e4e0b02 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/StatusesRequest.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/StatusesRequest.kt @@ -97,4 +97,4 @@ fun StatusesRequest.Visibility?.toStatusVisibility(): Status.Visibility { direct -> Status.Visibility.direct null -> Status.Visibility.public } -} \ No newline at end of file +} diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/query/AccountQueryService.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/query/AccountQueryService.kt index 61de616c..8596af18 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/query/AccountQueryService.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/query/AccountQueryService.kt @@ -21,4 +21,4 @@ import dev.usbharu.hideout.mastodon.interfaces.api.generated.model.Account interface AccountQueryService { suspend fun findById(accountId: Long): Account? suspend fun findByIds(accountIds: List): List -} \ No newline at end of file +} diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/query/StatusQueryService.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/query/StatusQueryService.kt index 34bf05da..8cd1fc02 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/query/StatusQueryService.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/query/StatusQueryService.kt @@ -43,4 +43,4 @@ data class StatusQuery( val repostId: Long?, val mediaIds: List, val emojiIds: List, -) \ No newline at end of file +)