style: fix lint

This commit is contained in:
usbharu 2024-08-23 23:56:47 +09:00
parent da1235f95c
commit de56fa0547
Signed by: usbharu
GPG Key ID: 6556747BF94EEBC8
20 changed files with 128 additions and 139 deletions

View File

@ -31,7 +31,8 @@ class GetAccountApplicationService(private val accountQueryService: AccountQuery
logger logger
) { ) {
override suspend fun internalExecute(command: GetAccount, principal: LocalUser): Account { 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 { companion object {

View File

@ -28,7 +28,8 @@ import org.springframework.stereotype.Service
@Service @Service
class DeleteFilterV1ApplicationService(private val filterRepository: FilterRepository, transaction: Transaction) : class DeleteFilterV1ApplicationService(private val filterRepository: FilterRepository, transaction: Transaction) :
LocalUserAbstractApplicationService<DeleteFilterV1, Unit>( LocalUserAbstractApplicationService<DeleteFilterV1, Unit>(
transaction, logger transaction,
logger
) { ) {
override suspend fun internalExecute(command: DeleteFilterV1, principal: LocalUser) { override suspend fun internalExecute(command: DeleteFilterV1, principal: LocalUser) {
val filter = filterRepository.findByFilterKeywordId(FilterKeywordId(command.filterKeywordId)) val filter = filterRepository.findByFilterKeywordId(FilterKeywordId(command.filterKeywordId))

View File

@ -31,7 +31,8 @@ import org.springframework.stereotype.Repository
@Repository @Repository
class GetFilterV1ApplicationService(private val filterRepository: FilterRepository, transaction: Transaction) : class GetFilterV1ApplicationService(private val filterRepository: FilterRepository, transaction: Transaction) :
AbstractApplicationService<GetFilterV1, V1Filter>( AbstractApplicationService<GetFilterV1, V1Filter>(
transaction, logger transaction,
logger
) { ) {
override suspend fun internalExecute(command: GetFilterV1, principal: Principal): V1Filter { override suspend fun internalExecute(command: GetFilterV1, principal: Principal): V1Filter {
val filter = filterRepository.findByFilterKeywordId(FilterKeywordId(command.filterKeywordId)) val filter = filterRepository.findByFilterKeywordId(FilterKeywordId(command.filterKeywordId))

View File

@ -32,13 +32,12 @@ class GetStatusApplicationService(
transaction, transaction,
logger logger
) { ) {
companion object {
val logger = LoggerFactory.getLogger(GetStatusApplicationService::class.java)!!
}
override suspend fun internalExecute(command: GetStatus, principal: Principal): Status { override suspend fun internalExecute(command: GetStatus, principal: Principal): Status {
return statusQueryService.findByPostId(command.id.toLong(), principal) return statusQueryService.findByPostId(command.id.toLong(), principal)
?: throw IllegalArgumentException("Post ${command.id} not found.") ?: throw IllegalArgumentException("Post ${command.id} not found.")
}
companion object {
val logger = LoggerFactory.getLogger(GetStatusApplicationService::class.java)!!
} }
} }

View File

@ -25,7 +25,7 @@ import org.jetbrains.exposed.sql.selectAll
import org.springframework.stereotype.Repository import org.springframework.stereotype.Repository
@Repository @Repository
class AccountQueryServiceImpl(private val applicationConfig: ApplicationConfig) : AccountQueryService { class ExposedAccountQueryServiceImpl(private val applicationConfig: ApplicationConfig) : AccountQueryService {
override suspend fun findById(accountId: Long): Account? { override suspend fun findById(accountId: Long): Account? {
val query = Actors.selectAll().where { Actors.id eq accountId } val query = Actors.selectAll().where { Actors.id eq accountId }

View File

@ -55,7 +55,8 @@ class StatusQueryServiceImpl : StatusQueryService {
.leftJoin( .leftJoin(
relationshipsAlias, relationshipsAlias,
onColumn = { Posts.actorId }, onColumn = { Posts.actorId },
otherColumn = { relationshipsAlias[Relationships.targetActorId] }) otherColumn = { relationshipsAlias[Relationships.targetActorId] }
)
.select(Posts.columns) .select(Posts.columns)
.where { .where {
Posts.visibility eq Visibility.PUBLIC.name or Posts.visibility eq Visibility.PUBLIC.name or

View File

@ -48,6 +48,7 @@ import org.springframework.http.ResponseEntity
import org.springframework.stereotype.Controller import org.springframework.stereotype.Controller
@Controller @Controller
@Suppress("LongParameterList")
class SpringAccountApi( class SpringAccountApi(
private val getUserDetailApplicationService: GetUserDetailApplicationService, private val getUserDetailApplicationService: GetUserDetailApplicationService,
private val getAccountApplicationService: GetAccountApplicationService, private val getAccountApplicationService: GetAccountApplicationService,
@ -64,7 +65,6 @@ class SpringAccountApi(
private val principalContextHolder: SpringSecurityOauth2PrincipalContextHolder private val principalContextHolder: SpringSecurityOauth2PrincipalContextHolder
) : AccountApi { ) : AccountApi {
override suspend fun apiV1AccountsIdBlockPost(id: String): ResponseEntity<Relationship> { override suspend fun apiV1AccountsIdBlockPost(id: String): ResponseEntity<Relationship> {
userBlockApplicationService.execute(Block(id.toLong()), principalContextHolder.getPrincipal()) userBlockApplicationService.execute(Block(id.toLong()), principalContextHolder.getPrincipal())
return fetchRelationship(id) return fetchRelationship(id)
@ -74,9 +74,9 @@ class SpringAccountApi(
id: String, id: String,
followRequestBody: FollowRequestBody?, followRequestBody: FollowRequestBody?,
): ResponseEntity<Relationship> { ): ResponseEntity<Relationship> {
userFollowRequestApplicationService.execute( userFollowRequestApplicationService.execute(
FollowRequest(id.toLong()), principalContextHolder.getPrincipal() FollowRequest(id.toLong()),
principalContextHolder.getPrincipal()
) )
return fetchRelationship(id) return fetchRelationship(id)
} }
@ -110,53 +110,57 @@ class SpringAccountApi(
override suspend fun apiV1AccountsIdGet(id: String): ResponseEntity<Account> { override suspend fun apiV1AccountsIdGet(id: String): ResponseEntity<Account> {
return ResponseEntity.ok( return ResponseEntity.ok(
getAccountApplicationService.execute( getAccountApplicationService.execute(
GetAccount(id), principalContextHolder.getPrincipal() GetAccount(id),
principalContextHolder.getPrincipal()
) )
) )
} }
override suspend fun apiV1AccountsIdMutePost(id: String): ResponseEntity<Relationship> { override suspend fun apiV1AccountsIdMutePost(id: String): ResponseEntity<Relationship> {
userMuteApplicationService.execute( userMuteApplicationService.execute(
Mute(id.toLong()), principalContextHolder.getPrincipal() Mute(id.toLong()),
principalContextHolder.getPrincipal()
) )
return fetchRelationship(id) return fetchRelationship(id)
} }
override suspend fun apiV1AccountsIdRemoveFromFollowersPost(id: String): ResponseEntity<Relationship> { override suspend fun apiV1AccountsIdRemoveFromFollowersPost(id: String): ResponseEntity<Relationship> {
userRemoveFromFollowersApplicationService.execute( userRemoveFromFollowersApplicationService.execute(
RemoveFromFollowers(id.toLong()), principalContextHolder.getPrincipal() RemoveFromFollowers(id.toLong()),
principalContextHolder.getPrincipal()
) )
return fetchRelationship(id) return fetchRelationship(id)
} }
override suspend fun apiV1AccountsIdUnblockPost(id: String): ResponseEntity<Relationship> { override suspend fun apiV1AccountsIdUnblockPost(id: String): ResponseEntity<Relationship> {
userUnblockApplicationService.execute( userUnblockApplicationService.execute(
Unblock(id.toLong()), principalContextHolder.getPrincipal() Unblock(id.toLong()),
principalContextHolder.getPrincipal()
) )
return fetchRelationship(id) return fetchRelationship(id)
} }
override suspend fun apiV1AccountsIdUnfollowPost(id: String): ResponseEntity<Relationship> { override suspend fun apiV1AccountsIdUnfollowPost(id: String): ResponseEntity<Relationship> {
userUnfollowApplicationService.execute( userUnfollowApplicationService.execute(
Unfollow(id.toLong()), principalContextHolder.getPrincipal() Unfollow(id.toLong()),
principalContextHolder.getPrincipal()
) )
return fetchRelationship(id) return fetchRelationship(id)
} }
override suspend fun apiV1AccountsIdUnmutePost(id: String): ResponseEntity<Relationship> { override suspend fun apiV1AccountsIdUnmutePost(id: String): ResponseEntity<Relationship> {
userUnmuteApplicationService.execute( userUnmuteApplicationService.execute(
Unmute(id.toLong()), principalContextHolder.getPrincipal() Unmute(id.toLong()),
principalContextHolder.getPrincipal()
) )
return fetchRelationship(id) return fetchRelationship(id)
} }
override suspend fun apiV1AccountsPost(accountsCreateRequest: AccountsCreateRequest): ResponseEntity<Unit> { override suspend fun apiV1AccountsPost(accountsCreateRequest: AccountsCreateRequest): ResponseEntity<Unit> =
return super.apiV1AccountsPost(accountsCreateRequest) super.apiV1AccountsPost(accountsCreateRequest)
}
override suspend fun apiV1AccountsUpdateCredentialsPatch(updateCredentials: UpdateCredentials?): ResponseEntity<Account> { override suspend fun apiV1AccountsUpdateCredentialsPatch(updateCredentials: UpdateCredentials?): ResponseEntity<Account> =
return super.apiV1AccountsUpdateCredentialsPatch(updateCredentials) super.apiV1AccountsUpdateCredentialsPatch(updateCredentials)
}
override suspend fun apiV1AccountsVerifyCredentialsGet(): ResponseEntity<CredentialAccount> { override suspend fun apiV1AccountsVerifyCredentialsGet(): ResponseEntity<CredentialAccount> {
val principal = principalContextHolder.getPrincipal() val principal = principalContextHolder.getPrincipal()
@ -164,7 +168,8 @@ class SpringAccountApi(
getUserDetailApplicationService.execute( getUserDetailApplicationService.execute(
GetUserDetail( GetUserDetail(
principal.userDetailId?.id ?: throw PermissionDeniedException() principal.userDetailId?.id ?: throw PermissionDeniedException()
), principal ),
principal
) )
return ResponseEntity.ok( return ResponseEntity.ok(
@ -215,19 +220,18 @@ class SpringAccountApi(
} }
override suspend fun apiV1FollowRequestsAccountIdAuthorizePost(accountId: String): ResponseEntity<Relationship> { override suspend fun apiV1FollowRequestsAccountIdAuthorizePost(accountId: String): ResponseEntity<Relationship> {
userAcceptFollowRequestApplicationService.execute( userAcceptFollowRequestApplicationService.execute(
AcceptFollowRequest(accountId.toLong()), principalContextHolder.getPrincipal() AcceptFollowRequest(accountId.toLong()),
principalContextHolder.getPrincipal()
) )
return fetchRelationship(accountId) return fetchRelationship(accountId)
} }
override suspend fun apiV1FollowRequestsAccountIdRejectPost(accountId: String): ResponseEntity<Relationship> { override suspend fun apiV1FollowRequestsAccountIdRejectPost(accountId: String): ResponseEntity<Relationship> {
userRejectFollowRequestApplicationService.execute( userRejectFollowRequestApplicationService.execute(
RejectFollowRequest(accountId.toLong()), principalContextHolder.getPrincipal() RejectFollowRequest(accountId.toLong()),
principalContextHolder.getPrincipal()
) )
return fetchRelationship(accountId) return fetchRelationship(accountId)
} }
} }

View File

@ -29,7 +29,6 @@ import java.net.URI
@Controller @Controller
class SpringAppApi(private val registerApplicationApplicationService: RegisterApplicationApplicationService) : AppApi { class SpringAppApi(private val registerApplicationApplicationService: RegisterApplicationApplicationService) : AppApi {
override suspend fun apiV1AppsPost(appsRequest: AppsRequest): ResponseEntity<Application> { override suspend fun apiV1AppsPost(appsRequest: AppsRequest): ResponseEntity<Application> {
val registerApplication = RegisterApplication( val registerApplication = RegisterApplication(
appsRequest.clientName, appsRequest.clientName,
setOf(URI.create(appsRequest.redirectUris)), setOf(URI.create(appsRequest.redirectUris)),
@ -39,12 +38,12 @@ class SpringAppApi(private val registerApplicationApplicationService: RegisterAp
val registeredApplication = registerApplicationApplicationService.execute(registerApplication, Anonymous) val registeredApplication = registerApplicationApplicationService.execute(registerApplication, Anonymous)
return ResponseEntity.ok( return ResponseEntity.ok(
Application( Application(
registeredApplication.name, name = registeredApplication.name,
"invalid-vapid-key", vapidKey = "invalid-vapid-key",
null, website = null,
registeredApplication.clientId, clientId = registeredApplication.clientId,
registeredApplication.clientSecret, clientSecret = registeredApplication.clientSecret,
appsRequest.redirectUris redirectUri = appsRequest.redirectUris
) )
) )
} }

View File

@ -47,7 +47,8 @@ class SpringFilterApi(
override suspend fun apiV1FiltersIdDelete(id: String): ResponseEntity<Any> { override suspend fun apiV1FiltersIdDelete(id: String): ResponseEntity<Any> {
return ResponseEntity.ok( return ResponseEntity.ok(
deleteFilterV1ApplicationService.execute( 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<V1Filter> { override suspend fun apiV1FiltersIdGet(id: String): ResponseEntity<V1Filter> {
return ResponseEntity.ok( return ResponseEntity.ok(
getFilterV1ApplicationService.execute( getFilterV1ApplicationService.execute(
GetFilterV1(id.toLong()), principalContextHolder.getPrincipal() GetFilterV1(id.toLong()),
principalContextHolder.getPrincipal()
) )
) )
} }
@ -67,12 +69,9 @@ class SpringFilterApi(
irreversible: Boolean?, irreversible: Boolean?,
wholeWord: Boolean?, wholeWord: Boolean?,
expiresIn: Int?, expiresIn: Int?,
): ResponseEntity<V1Filter> { ): ResponseEntity<V1Filter> = super.apiV1FiltersIdPut(id, phrase, context, irreversible, wholeWord, expiresIn)
return super.apiV1FiltersIdPut(id, phrase, context, irreversible, wholeWord, expiresIn)
}
override suspend fun apiV1FiltersPost(v1FilterPostRequest: V1FilterPostRequest): ResponseEntity<V1Filter> { override suspend fun apiV1FiltersPost(v1FilterPostRequest: V1FilterPostRequest): ResponseEntity<V1Filter> {
val filterMode = if (v1FilterPostRequest.wholeWord == true) { val filterMode = if (v1FilterPostRequest.wholeWord == true) {
FilterMode.WHOLE_WORD FilterMode.WHOLE_WORD
} else { } else {
@ -89,13 +88,17 @@ class SpringFilterApi(
}.toSet() }.toSet()
val filter = userRegisterFilterApplicationService.execute( val filter = userRegisterFilterApplicationService.execute(
RegisterFilter( RegisterFilter(
v1FilterPostRequest.phrase, filterContext, FilterAction.WARN, v1FilterPostRequest.phrase,
filterContext,
FilterAction.WARN,
setOf(RegisterFilterKeyword(v1FilterPostRequest.phrase, filterMode)) setOf(RegisterFilterKeyword(v1FilterPostRequest.phrase, filterMode))
), principalContextHolder.getPrincipal() ),
principalContextHolder.getPrincipal()
) )
return ResponseEntity.ok( return ResponseEntity.ok(
getFilterV1ApplicationService.execute( 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( override suspend fun apiV2FiltersFilterIdKeywordsPost(
filterId: String, filterId: String,
filterKeywordsPostRequest: FilterKeywordsPostRequest, filterKeywordsPostRequest: FilterKeywordsPostRequest,
): ResponseEntity<FilterKeyword> { ): ResponseEntity<FilterKeyword> = super.apiV2FiltersFilterIdKeywordsPost(filterId, filterKeywordsPostRequest)
return super.apiV2FiltersFilterIdKeywordsPost(filterId, filterKeywordsPostRequest)
}
override suspend fun apiV2FiltersFilterIdStatusesPost( override suspend fun apiV2FiltersFilterIdStatusesPost(
filterId: String, filterId: String,
filterStatusRequest: FilterStatusRequest, filterStatusRequest: FilterStatusRequest,
): ResponseEntity<FilterStatus> { ): ResponseEntity<FilterStatus> = super.apiV2FiltersFilterIdStatusesPost(filterId, filterStatusRequest)
return super.apiV2FiltersFilterIdStatusesPost(filterId, filterStatusRequest)
}
override suspend fun apiV2FiltersIdDelete(id: String): ResponseEntity<Any> { override suspend fun apiV2FiltersIdDelete(id: String): ResponseEntity<Any> {
userDeleteFilterApplicationService.execute( userDeleteFilterApplicationService.execute(
DeleteFilter(id.toLong()), principalContextHolder.getPrincipal() DeleteFilter(id.toLong()),
principalContextHolder.getPrincipal()
) )
return ResponseEntity.ok(Unit) return ResponseEntity.ok(Unit)
} }
override suspend fun apiV2FiltersIdGet(id: String): ResponseEntity<Filter> { override suspend fun apiV2FiltersIdGet(id: String): ResponseEntity<Filter> {
val filter = userGetFilterApplicationService.execute( val filter = userGetFilterApplicationService.execute(
GetFilter(id.toLong()), principalContextHolder.getPrincipal() GetFilter(id.toLong()),
principalContextHolder.getPrincipal()
) )
return ResponseEntity.ok( return ResponseEntity.ok(
filter(filter) filter(filter)
@ -146,7 +147,6 @@ class SpringFilterApi(
filterAction = when (filter.filterAction) { filterAction = when (filter.filterAction) {
FilterAction.WARN -> Filter.FilterAction.warn FilterAction.WARN -> Filter.FilterAction.warn
FilterAction.HIDE -> Filter.FilterAction.hide FilterAction.HIDE -> Filter.FilterAction.hide
}, },
keywords = filter.filterKeywords.map { keywords = filter.filterKeywords.map {
FilterKeyword( FilterKeyword(
@ -154,7 +154,8 @@ class SpringFilterApi(
it.keyword, it.keyword,
it.filterMode == FilterMode.WHOLE_WORD it.filterMode == FilterMode.WHOLE_WORD
) )
}, statuses = null },
statuses = null
) )
override suspend fun apiV2FiltersIdPut( override suspend fun apiV2FiltersIdPut(
@ -164,29 +165,23 @@ class SpringFilterApi(
filterAction: String?, filterAction: String?,
expiresIn: Int?, expiresIn: Int?,
keywordsAttributes: List<FilterPubRequestKeyword>?, keywordsAttributes: List<FilterPubRequestKeyword>?,
): ResponseEntity<Filter> { ): ResponseEntity<Filter> =
return super.apiV2FiltersIdPut(id, title, context, filterAction, expiresIn, keywordsAttributes) super.apiV2FiltersIdPut(id, title, context, filterAction, expiresIn, keywordsAttributes)
}
override suspend fun apiV2FiltersKeywordsIdDelete(id: String): ResponseEntity<Any> { override suspend fun apiV2FiltersKeywordsIdDelete(id: String): ResponseEntity<Any> =
return super.apiV2FiltersKeywordsIdDelete(id) super.apiV2FiltersKeywordsIdDelete(id)
}
override suspend fun apiV2FiltersKeywordsIdGet(id: String): ResponseEntity<FilterKeyword> { override suspend fun apiV2FiltersKeywordsIdGet(id: String): ResponseEntity<FilterKeyword> =
return super.apiV2FiltersKeywordsIdGet(id) super.apiV2FiltersKeywordsIdGet(id)
}
override suspend fun apiV2FiltersKeywordsIdPut( override suspend fun apiV2FiltersKeywordsIdPut(
id: String, id: String,
keyword: String?, keyword: String?,
wholeWord: Boolean?, wholeWord: Boolean?,
regex: Boolean?, regex: Boolean?,
): ResponseEntity<FilterKeyword> { ): ResponseEntity<FilterKeyword> = super.apiV2FiltersKeywordsIdPut(id, keyword, wholeWord, regex)
return super.apiV2FiltersKeywordsIdPut(id, keyword, wholeWord, regex)
}
override suspend fun apiV2FiltersPost(filterPostRequest: FilterPostRequest): ResponseEntity<Filter> { override suspend fun apiV2FiltersPost(filterPostRequest: FilterPostRequest): ResponseEntity<Filter> {
val filter = userRegisterFilterApplicationService.execute( val filter = userRegisterFilterApplicationService.execute(
RegisterFilter( RegisterFilter(
filterName = filterPostRequest.title, filterName = filterPostRequest.title,
@ -216,16 +211,15 @@ class SpringFilterApi(
} }
) )
}.toSet() }.toSet()
), principalContextHolder.getPrincipal() ),
principalContextHolder.getPrincipal()
) )
return ResponseEntity.ok(filter(filter)) return ResponseEntity.ok(filter(filter))
} }
override suspend fun apiV2FiltersStatusesIdDelete(id: String): ResponseEntity<Any> { override suspend fun apiV2FiltersStatusesIdDelete(id: String): ResponseEntity<Any> =
return ResponseEntity.notFound().build() ResponseEntity.notFound().build()
}
override suspend fun apiV2FiltersStatusesIdGet(id: String): ResponseEntity<FilterStatus> { override suspend fun apiV2FiltersStatusesIdGet(id: String): ResponseEntity<FilterStatus> =
return ResponseEntity.notFound().build() ResponseEntity.notFound().build()
}
} }

View File

@ -17,23 +17,19 @@
package dev.usbharu.hideout.mastodon.interfaces.api package dev.usbharu.hideout.mastodon.interfaces.api
import dev.usbharu.hideout.mastodon.interfaces.api.generated.InstanceApi import dev.usbharu.hideout.mastodon.interfaces.api.generated.InstanceApi
import dev.usbharu.hideout.mastodon.interfaces.api.generated.model.* import dev.usbharu.hideout.mastodon.interfaces.api.generated.model.ExtendedDescription
import kotlinx.coroutines.flow.Flow 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.http.ResponseEntity
import org.springframework.stereotype.Controller import org.springframework.stereotype.Controller
@Controller @Controller
class SpringInstanceApi : InstanceApi { class SpringInstanceApi : InstanceApi {
override suspend fun apiV1InstanceExtendedDescriptionGet(): ResponseEntity<ExtendedDescription> { override suspend fun apiV1InstanceExtendedDescriptionGet(): ResponseEntity<ExtendedDescription> =
return super.apiV1InstanceExtendedDescriptionGet() super.apiV1InstanceExtendedDescriptionGet()
}
override suspend fun apiV1InstanceGet(): ResponseEntity<V1Instance> { override suspend fun apiV1InstanceGet(): ResponseEntity<V1Instance> = super.apiV1InstanceGet()
return super.apiV1InstanceGet()
}
override suspend fun apiV2InstanceGet(): ResponseEntity<Instance> { override suspend fun apiV2InstanceGet(): ResponseEntity<Instance> = super.apiV2InstanceGet()
return super.apiV2InstanceGet()
}
} }

View File

@ -52,24 +52,25 @@ class SpringMediaApi(
file.originalFilename ?: file.name, file.originalFilename ?: file.name,
null, null,
description description
), principalContextHolder.getPrincipal() ),
principalContextHolder.getPrincipal()
) )
return ResponseEntity.ok( return ResponseEntity.ok(
MediaAttachment( MediaAttachment(
media.id.toString(), id = media.id.toString(),
when (media.type) { type = when (media.type) {
Image -> MediaAttachment.Type.image Image -> MediaAttachment.Type.image
Video -> MediaAttachment.Type.video Video -> MediaAttachment.Type.video
Audio -> MediaAttachment.Type.audio Audio -> MediaAttachment.Type.audio
Unknown -> MediaAttachment.Type.unknown Unknown -> MediaAttachment.Type.unknown
}, },
media.url.toString(), url = media.url.toString(),
media.thumbprintURI?.toString(), previewUrl = media.thumbprintURI?.toString(),
media.remoteURL?.toString(), remoteUrl = media.remoteURL?.toString(),
media.description, description = media.description,
media.blurHash, blurhash = media.blurHash,
media.url.toASCIIString() textUrl = media.url.toASCIIString()
) )
) )
} }

View File

@ -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.NotificationsApi
import dev.usbharu.hideout.mastodon.interfaces.api.generated.model.Notification import dev.usbharu.hideout.mastodon.interfaces.api.generated.model.Notification
import kotlinx.coroutines.flow.Flow
import org.springframework.http.ResponseEntity import org.springframework.http.ResponseEntity
import org.springframework.stereotype.Controller import org.springframework.stereotype.Controller
@Controller @Controller
class SpringNotificationApi : NotificationsApi { class SpringNotificationApi : NotificationsApi {
override suspend fun apiV1NotificationsClearPost(): ResponseEntity<Any> { override suspend fun apiV1NotificationsClearPost(): ResponseEntity<Any> = super.apiV1NotificationsClearPost()
return super.apiV1NotificationsClearPost()
}
override suspend fun apiV1NotificationsIdDismissPost(id: String): ResponseEntity<Any> { override suspend fun apiV1NotificationsIdDismissPost(id: String): ResponseEntity<Any> =
return super.apiV1NotificationsIdDismissPost(id) super.apiV1NotificationsIdDismissPost(id)
}
override suspend fun apiV1NotificationsIdGet(id: String): ResponseEntity<Notification> { override suspend fun apiV1NotificationsIdGet(id: String): ResponseEntity<Notification> =
return super.apiV1NotificationsIdGet(id) super.apiV1NotificationsIdGet(id)
}
} }

View File

@ -34,25 +34,22 @@ class SpringStatusApi(
private val getStatusApplicationService: GetStatusApplicationService, private val getStatusApplicationService: GetStatusApplicationService,
private val principalContextHolder: SpringSecurityOauth2PrincipalContextHolder private val principalContextHolder: SpringSecurityOauth2PrincipalContextHolder
) : StatusApi { ) : StatusApi {
override suspend fun apiV1StatusesIdEmojiReactionsEmojiDelete(id: String, emoji: String): ResponseEntity<Status> { override suspend fun apiV1StatusesIdEmojiReactionsEmojiDelete(id: String, emoji: String): ResponseEntity<Status> =
return super.apiV1StatusesIdEmojiReactionsEmojiDelete(id, emoji) super.apiV1StatusesIdEmojiReactionsEmojiDelete(id, emoji)
}
override suspend fun apiV1StatusesIdEmojiReactionsEmojiPut(id: String, emoji: String): ResponseEntity<Status> { override suspend fun apiV1StatusesIdEmojiReactionsEmojiPut(id: String, emoji: String): ResponseEntity<Status> =
return super.apiV1StatusesIdEmojiReactionsEmojiPut(id, emoji) super.apiV1StatusesIdEmojiReactionsEmojiPut(id, emoji)
}
override suspend fun apiV1StatusesIdGet(id: String): ResponseEntity<Status> { override suspend fun apiV1StatusesIdGet(id: String): ResponseEntity<Status> {
return ResponseEntity.ok( return ResponseEntity.ok(
getStatusApplicationService.execute( getStatusApplicationService.execute(
GetStatus(id), principalContextHolder.getPrincipal() GetStatus(id),
principalContextHolder.getPrincipal()
) )
) )
} }
override suspend fun apiV1StatusesPost(statusesRequest: dev.usbharu.hideout.mastodon.interfaces.api.StatusesRequest): ResponseEntity<Status> { override suspend fun apiV1StatusesPost(statusesRequest: StatusesRequest): ResponseEntity<Status> {
val principal = principalContextHolder.getPrincipal() val principal = principalContextHolder.getPrincipal()
val execute = registerLocalPostApplicationService.execute( val execute = registerLocalPostApplicationService.execute(
RegisterLocalPost( RegisterLocalPost(
@ -69,10 +66,10 @@ class SpringStatusApi(
replyId = statusesRequest.in_reply_to_id?.toLong(), replyId = statusesRequest.in_reply_to_id?.toLong(),
sensitive = statusesRequest.sensitive == true, sensitive = statusesRequest.sensitive == true,
mediaIds = statusesRequest.media_ids.map { it.toLong() } mediaIds = statusesRequest.media_ids.map { it.toLong() }
), principal ),
principal
) )
val status = val status =
getStatusApplicationService.execute(GetStatus(execute.toString()), principal) getStatusApplicationService.execute(GetStatus(execute.toString()), principal)
return ResponseEntity.ok( return ResponseEntity.ok(