mirror of https://github.com/usbharu/Hideout.git
style: fix lint
This commit is contained in:
parent
da1235f95c
commit
de56fa0547
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,8 @@ import org.springframework.stereotype.Service
|
|||
@Service
|
||||
class DeleteFilterV1ApplicationService(private val filterRepository: FilterRepository, transaction: Transaction) :
|
||||
LocalUserAbstractApplicationService<DeleteFilterV1, Unit>(
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,4 +16,4 @@
|
|||
|
||||
package dev.usbharu.hideout.mastodon.application.filter
|
||||
|
||||
data class GetFilterV1(val filterKeywordId: Long)
|
||||
data class GetFilterV1(val filterKeywordId: Long)
|
||||
|
|
|
@ -31,7 +31,8 @@ import org.springframework.stereotype.Repository
|
|||
@Repository
|
||||
class GetFilterV1ApplicationService(private val filterRepository: FilterRepository, transaction: Transaction) :
|
||||
AbstractApplicationService<GetFilterV1, V1Filter>(
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.")
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val logger = LoggerFactory.getLogger(GetStatusApplicationService::class.java)!!
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,4 +109,4 @@ class MastodonSecurityConfig {
|
|||
|
||||
return http.build()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,4 +29,4 @@ class RoleHierarchyAuthorizationManagerFactory(private val roleHierarchy: RoleHi
|
|||
hasAuthority.setRoleHierarchy(roleHierarchy)
|
||||
return hasAuthority
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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],
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
)
|
||||
)
|
||||
|
|
|
@ -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<Relationship> {
|
||||
userBlockApplicationService.execute(Block(id.toLong()), principalContextHolder.getPrincipal())
|
||||
return fetchRelationship(id)
|
||||
|
@ -74,9 +74,9 @@ class SpringAccountApi(
|
|||
id: String,
|
||||
followRequestBody: FollowRequestBody?,
|
||||
): ResponseEntity<Relationship> {
|
||||
|
||||
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<Account> {
|
||||
return ResponseEntity.ok(
|
||||
getAccountApplicationService.execute(
|
||||
GetAccount(id), principalContextHolder.getPrincipal()
|
||||
GetAccount(id),
|
||||
principalContextHolder.getPrincipal()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override suspend fun apiV1AccountsIdMutePost(id: String): ResponseEntity<Relationship> {
|
||||
userMuteApplicationService.execute(
|
||||
Mute(id.toLong()), principalContextHolder.getPrincipal()
|
||||
Mute(id.toLong()),
|
||||
principalContextHolder.getPrincipal()
|
||||
)
|
||||
return fetchRelationship(id)
|
||||
}
|
||||
|
||||
override suspend fun apiV1AccountsIdRemoveFromFollowersPost(id: String): ResponseEntity<Relationship> {
|
||||
userRemoveFromFollowersApplicationService.execute(
|
||||
RemoveFromFollowers(id.toLong()), principalContextHolder.getPrincipal()
|
||||
RemoveFromFollowers(id.toLong()),
|
||||
principalContextHolder.getPrincipal()
|
||||
)
|
||||
return fetchRelationship(id)
|
||||
}
|
||||
|
||||
override suspend fun apiV1AccountsIdUnblockPost(id: String): ResponseEntity<Relationship> {
|
||||
userUnblockApplicationService.execute(
|
||||
Unblock(id.toLong()), principalContextHolder.getPrincipal()
|
||||
Unblock(id.toLong()),
|
||||
principalContextHolder.getPrincipal()
|
||||
)
|
||||
return fetchRelationship(id)
|
||||
}
|
||||
|
||||
override suspend fun apiV1AccountsIdUnfollowPost(id: String): ResponseEntity<Relationship> {
|
||||
userUnfollowApplicationService.execute(
|
||||
Unfollow(id.toLong()), principalContextHolder.getPrincipal()
|
||||
Unfollow(id.toLong()),
|
||||
principalContextHolder.getPrincipal()
|
||||
)
|
||||
return fetchRelationship(id)
|
||||
}
|
||||
|
||||
override suspend fun apiV1AccountsIdUnmutePost(id: String): ResponseEntity<Relationship> {
|
||||
userUnmuteApplicationService.execute(
|
||||
Unmute(id.toLong()), principalContextHolder.getPrincipal()
|
||||
Unmute(id.toLong()),
|
||||
principalContextHolder.getPrincipal()
|
||||
)
|
||||
return fetchRelationship(id)
|
||||
}
|
||||
|
||||
override suspend fun apiV1AccountsPost(accountsCreateRequest: AccountsCreateRequest): ResponseEntity<Unit> {
|
||||
return super.apiV1AccountsPost(accountsCreateRequest)
|
||||
}
|
||||
override suspend fun apiV1AccountsPost(accountsCreateRequest: AccountsCreateRequest): ResponseEntity<Unit> =
|
||||
super.apiV1AccountsPost(accountsCreateRequest)
|
||||
|
||||
override suspend fun apiV1AccountsUpdateCredentialsPatch(updateCredentials: UpdateCredentials?): ResponseEntity<Account> {
|
||||
return super.apiV1AccountsUpdateCredentialsPatch(updateCredentials)
|
||||
}
|
||||
override suspend fun apiV1AccountsUpdateCredentialsPatch(updateCredentials: UpdateCredentials?): ResponseEntity<Account> =
|
||||
super.apiV1AccountsUpdateCredentialsPatch(updateCredentials)
|
||||
|
||||
override suspend fun apiV1AccountsVerifyCredentialsGet(): ResponseEntity<CredentialAccount> {
|
||||
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<Relationship> {
|
||||
|
||||
userAcceptFollowRequestApplicationService.execute(
|
||||
AcceptFollowRequest(accountId.toLong()), principalContextHolder.getPrincipal()
|
||||
AcceptFollowRequest(accountId.toLong()),
|
||||
principalContextHolder.getPrincipal()
|
||||
)
|
||||
return fetchRelationship(accountId)
|
||||
}
|
||||
|
||||
override suspend fun apiV1FollowRequestsAccountIdRejectPost(accountId: String): ResponseEntity<Relationship> {
|
||||
|
||||
userRejectFollowRequestApplicationService.execute(
|
||||
RejectFollowRequest(accountId.toLong()), principalContextHolder.getPrincipal()
|
||||
RejectFollowRequest(accountId.toLong()),
|
||||
principalContextHolder.getPrincipal()
|
||||
)
|
||||
return fetchRelationship(accountId)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import java.net.URI
|
|||
@Controller
|
||||
class SpringAppApi(private val registerApplicationApplicationService: RegisterApplicationApplicationService) : AppApi {
|
||||
override suspend fun apiV1AppsPost(appsRequest: AppsRequest): ResponseEntity<Application> {
|
||||
|
||||
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
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,8 @@ class SpringFilterApi(
|
|||
override suspend fun apiV1FiltersIdDelete(id: String): ResponseEntity<Any> {
|
||||
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<V1Filter> {
|
||||
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<V1Filter> {
|
||||
return super.apiV1FiltersIdPut(id, phrase, context, irreversible, wholeWord, expiresIn)
|
||||
}
|
||||
): ResponseEntity<V1Filter> = super.apiV1FiltersIdPut(id, phrase, context, irreversible, wholeWord, expiresIn)
|
||||
|
||||
override suspend fun apiV1FiltersPost(v1FilterPostRequest: V1FilterPostRequest): ResponseEntity<V1Filter> {
|
||||
|
||||
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<FilterKeyword> {
|
||||
return super.apiV2FiltersFilterIdKeywordsPost(filterId, filterKeywordsPostRequest)
|
||||
}
|
||||
): ResponseEntity<FilterKeyword> = super.apiV2FiltersFilterIdKeywordsPost(filterId, filterKeywordsPostRequest)
|
||||
|
||||
override suspend fun apiV2FiltersFilterIdStatusesPost(
|
||||
filterId: String,
|
||||
filterStatusRequest: FilterStatusRequest,
|
||||
): ResponseEntity<FilterStatus> {
|
||||
return super.apiV2FiltersFilterIdStatusesPost(filterId, filterStatusRequest)
|
||||
}
|
||||
): ResponseEntity<FilterStatus> = super.apiV2FiltersFilterIdStatusesPost(filterId, filterStatusRequest)
|
||||
|
||||
override suspend fun apiV2FiltersIdDelete(id: String): ResponseEntity<Any> {
|
||||
userDeleteFilterApplicationService.execute(
|
||||
DeleteFilter(id.toLong()), principalContextHolder.getPrincipal()
|
||||
DeleteFilter(id.toLong()),
|
||||
principalContextHolder.getPrincipal()
|
||||
)
|
||||
return ResponseEntity.ok(Unit)
|
||||
}
|
||||
|
||||
override suspend fun apiV2FiltersIdGet(id: String): ResponseEntity<Filter> {
|
||||
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<FilterPubRequestKeyword>?,
|
||||
): ResponseEntity<Filter> {
|
||||
return super.apiV2FiltersIdPut(id, title, context, filterAction, expiresIn, keywordsAttributes)
|
||||
}
|
||||
): ResponseEntity<Filter> =
|
||||
super.apiV2FiltersIdPut(id, title, context, filterAction, expiresIn, keywordsAttributes)
|
||||
|
||||
override suspend fun apiV2FiltersKeywordsIdDelete(id: String): ResponseEntity<Any> {
|
||||
return super.apiV2FiltersKeywordsIdDelete(id)
|
||||
}
|
||||
override suspend fun apiV2FiltersKeywordsIdDelete(id: String): ResponseEntity<Any> =
|
||||
super.apiV2FiltersKeywordsIdDelete(id)
|
||||
|
||||
override suspend fun apiV2FiltersKeywordsIdGet(id: String): ResponseEntity<FilterKeyword> {
|
||||
return super.apiV2FiltersKeywordsIdGet(id)
|
||||
}
|
||||
override suspend fun apiV2FiltersKeywordsIdGet(id: String): ResponseEntity<FilterKeyword> =
|
||||
super.apiV2FiltersKeywordsIdGet(id)
|
||||
|
||||
override suspend fun apiV2FiltersKeywordsIdPut(
|
||||
id: String,
|
||||
keyword: String?,
|
||||
wholeWord: Boolean?,
|
||||
regex: Boolean?,
|
||||
): ResponseEntity<FilterKeyword> {
|
||||
return super.apiV2FiltersKeywordsIdPut(id, keyword, wholeWord, regex)
|
||||
}
|
||||
): ResponseEntity<FilterKeyword> = super.apiV2FiltersKeywordsIdPut(id, keyword, wholeWord, regex)
|
||||
|
||||
override suspend fun apiV2FiltersPost(filterPostRequest: FilterPostRequest): ResponseEntity<Filter> {
|
||||
|
||||
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<Any> {
|
||||
return ResponseEntity.notFound().build()
|
||||
}
|
||||
override suspend fun apiV2FiltersStatusesIdDelete(id: String): ResponseEntity<Any> =
|
||||
ResponseEntity.notFound().build()
|
||||
|
||||
override suspend fun apiV2FiltersStatusesIdGet(id: String): ResponseEntity<FilterStatus> {
|
||||
return ResponseEntity.notFound().build()
|
||||
}
|
||||
}
|
||||
override suspend fun apiV2FiltersStatusesIdGet(id: String): ResponseEntity<FilterStatus> =
|
||||
ResponseEntity.notFound().build()
|
||||
}
|
||||
|
|
|
@ -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<ExtendedDescription> {
|
||||
return super.apiV1InstanceExtendedDescriptionGet()
|
||||
}
|
||||
override suspend fun apiV1InstanceExtendedDescriptionGet(): ResponseEntity<ExtendedDescription> =
|
||||
super.apiV1InstanceExtendedDescriptionGet()
|
||||
|
||||
override suspend fun apiV1InstanceGet(): ResponseEntity<V1Instance> {
|
||||
return super.apiV1InstanceGet()
|
||||
}
|
||||
override suspend fun apiV1InstanceGet(): ResponseEntity<V1Instance> = super.apiV1InstanceGet()
|
||||
|
||||
override suspend fun apiV2InstanceGet(): ResponseEntity<Instance> {
|
||||
return super.apiV2InstanceGet()
|
||||
}
|
||||
}
|
||||
override suspend fun apiV2InstanceGet(): ResponseEntity<Instance> = super.apiV2InstanceGet()
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Any> {
|
||||
return super.apiV1NotificationsClearPost()
|
||||
}
|
||||
override suspend fun apiV1NotificationsClearPost(): ResponseEntity<Any> = super.apiV1NotificationsClearPost()
|
||||
|
||||
override suspend fun apiV1NotificationsIdDismissPost(id: String): ResponseEntity<Any> {
|
||||
return super.apiV1NotificationsIdDismissPost(id)
|
||||
}
|
||||
override suspend fun apiV1NotificationsIdDismissPost(id: String): ResponseEntity<Any> =
|
||||
super.apiV1NotificationsIdDismissPost(id)
|
||||
|
||||
override suspend fun apiV1NotificationsIdGet(id: String): ResponseEntity<Notification> {
|
||||
return super.apiV1NotificationsIdGet(id)
|
||||
}
|
||||
}
|
||||
override suspend fun apiV1NotificationsIdGet(id: String): ResponseEntity<Notification> =
|
||||
super.apiV1NotificationsIdGet(id)
|
||||
}
|
||||
|
|
|
@ -34,25 +34,22 @@ class SpringStatusApi(
|
|||
private val getStatusApplicationService: GetStatusApplicationService,
|
||||
private val principalContextHolder: SpringSecurityOauth2PrincipalContextHolder
|
||||
) : StatusApi {
|
||||
override suspend fun apiV1StatusesIdEmojiReactionsEmojiDelete(id: String, emoji: String): ResponseEntity<Status> {
|
||||
return super.apiV1StatusesIdEmojiReactionsEmojiDelete(id, emoji)
|
||||
}
|
||||
override suspend fun apiV1StatusesIdEmojiReactionsEmojiDelete(id: String, emoji: String): ResponseEntity<Status> =
|
||||
super.apiV1StatusesIdEmojiReactionsEmojiDelete(id, emoji)
|
||||
|
||||
override suspend fun apiV1StatusesIdEmojiReactionsEmojiPut(id: String, emoji: String): ResponseEntity<Status> {
|
||||
return super.apiV1StatusesIdEmojiReactionsEmojiPut(id, emoji)
|
||||
}
|
||||
override suspend fun apiV1StatusesIdEmojiReactionsEmojiPut(id: String, emoji: String): ResponseEntity<Status> =
|
||||
super.apiV1StatusesIdEmojiReactionsEmojiPut(id, emoji)
|
||||
|
||||
override suspend fun apiV1StatusesIdGet(id: String): ResponseEntity<Status> {
|
||||
|
||||
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<Status> {
|
||||
|
||||
override suspend fun apiV1StatusesPost(statusesRequest: StatusesRequest): ResponseEntity<Status> {
|
||||
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
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,4 +20,4 @@ import dev.usbharu.hideout.mastodon.interfaces.api.generated.TimelineApi
|
|||
import org.springframework.stereotype.Controller
|
||||
|
||||
@Controller
|
||||
class SpringTimelineApi : TimelineApi
|
||||
class SpringTimelineApi : TimelineApi
|
||||
|
|
|
@ -97,4 +97,4 @@ fun StatusesRequest.Visibility?.toStatusVisibility(): Status.Visibility {
|
|||
direct -> Status.Visibility.direct
|
||||
null -> Status.Visibility.public
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Long>): List<Account>
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,4 +43,4 @@ data class StatusQuery(
|
|||
val repostId: Long?,
|
||||
val mediaIds: List<Long>,
|
||||
val emojiIds: List<Long>,
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue