Apply suggestions from code review

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
usbharu 2024-01-29 21:01:59 +09:00 committed by GitHub
parent 942d5d71e3
commit 71a14c65c8
3 changed files with 24 additions and 9 deletions

View File

@ -31,11 +31,15 @@ sealed class Page {
): Page = ): Page =
if (minId != null) { if (minId != null) {
PageByMinId( PageByMinId(
maxId, minId, limit maxId,
minId,
limit
) )
} else { } else {
PageByMaxId( PageByMaxId(
maxId, sinceId, limit maxId,
sinceId,
limit
) )
} }
} }

View File

@ -27,7 +27,8 @@ class MastodonAccountApiController(
) : AccountApi { ) : AccountApi {
override suspend fun apiV1AccountsIdFollowPost( override suspend fun apiV1AccountsIdFollowPost(
id: String, followRequestBody: FollowRequestBody? id: String,
followRequestBody: FollowRequestBody?
): ResponseEntity<Relationship> { ): ResponseEntity<Relationship> {
val userid = loginUserContextHolder.getLoginUserId() val userid = loginUserContextHolder.getLoginUserId()
@ -38,11 +39,17 @@ class MastodonAccountApiController(
ResponseEntity.ok(accountApiService.account(id.toLong())) ResponseEntity.ok(accountApiService.account(id.toLong()))
override suspend fun apiV1AccountsVerifyCredentialsGet(): ResponseEntity<CredentialAccount> = ResponseEntity( override suspend fun apiV1AccountsVerifyCredentialsGet(): ResponseEntity<CredentialAccount> = ResponseEntity(
accountApiService.verifyCredentials(loginUserContextHolder.getLoginUserId()), HttpStatus.OK accountApiService.verifyCredentials(loginUserContextHolder.getLoginUserId()),
HttpStatus.OK
) )
override suspend fun apiV1AccountsPost( override suspend fun apiV1AccountsPost(
username: String, password: String, email: String?, agreement: Boolean?, locale: Boolean?, reason: String? username: String,
password: String,
email: String?,
agreement: Boolean?,
locale: Boolean?,
reason: String?
): ResponseEntity<Unit> { ): ResponseEntity<Unit> {
transaction.transaction { transaction.transaction {
accountApiService.registerAccount(UserCreateDto(username, username, "", password)) accountApiService.registerAccount(UserCreateDto(username, username, "", password))
@ -93,7 +100,8 @@ class MastodonAccountApiController(
} }
override fun apiV1AccountsRelationshipsGet( override fun apiV1AccountsRelationshipsGet(
id: List<String>?, withSuspended: Boolean id: List<String>?,
withSuspended: Boolean
): ResponseEntity<Flow<Relationship>> = runBlocking { ): ResponseEntity<Flow<Relationship>> = runBlocking {
val userid = loginUserContextHolder.getLoginUserId() val userid = loginUserContextHolder.getLoginUserId()
@ -164,8 +172,12 @@ class MastodonAccountApiController(
val userid = loginUserContextHolder.getLoginUserId() val userid = loginUserContextHolder.getLoginUserId()
val followRequests = accountApiService.followRequests( val followRequests = accountApiService.followRequests(
userid, false, Page.PageByMaxId( userid,
maxId?.toLongOrNull(), sinceId?.toLongOrNull(), limit?.coerceIn(0, 80) ?: 40 false,
Page.PageByMaxId(
maxId?.toLongOrNull(),
sinceId?.toLongOrNull(),
limit?.coerceIn(0, 80) ?: 40
) )
) )

View File

@ -55,7 +55,6 @@ class MastodonNotificationApiController(
) )
ResponseEntity.ok().header("Link", httpHeader).body(notifications.asFlow()) ResponseEntity.ok().header("Link", httpHeader).body(notifications.asFlow())
} }
override suspend fun apiV1NotificationsIdDismissPost(id: String): ResponseEntity<Any> { override suspend fun apiV1NotificationsIdDismissPost(id: String): ResponseEntity<Any> {