From ddaf630ed31d5c4e231c02d43d0877f3e0fabe6d Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Tue, 12 Dec 2023 13:02:19 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=83=95=E3=82=A9=E3=83=AD=E3=83=BC?= =?UTF-8?q?=E3=83=AA=E3=82=AF=E3=82=A8=E3=82=B9=E3=83=88API=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/e2eTest/resources/oauth2/user.sql | 4 +- .../domain/model/relationship/Relationship.kt | 4 +- .../RelationshipRepositoryImpl.kt | 6 +- .../RelationshipQueryServiceImpl.kt | 14 ++++ .../core/query/RelationshipQueryService.kt | 5 ++ .../relationship/RelationshipServiceImpl.kt | 22 ++--- .../service/account/AccountApiService.kt | 31 ++++++- .../service/account/AccountService.kt | 9 +++ src/main/resources/openapi/mastodon.yaml | 80 +++++++++++++++++++ .../RelationshipServiceImplTest.kt | 70 ++++++++-------- .../account/AccountApiServiceImplTest.kt | 10 ++- 11 files changed, 196 insertions(+), 59 deletions(-) diff --git a/src/e2eTest/resources/oauth2/user.sql b/src/e2eTest/resources/oauth2/user.sql index 001f51a7..34ac640f 100644 --- a/src/e2eTest/resources/oauth2/user.sql +++ b/src/e2eTest/resources/oauth2/user.sql @@ -45,6 +45,6 @@ Ja15+ZWbOA4vJA9pOh3x4XM= 'http://localhost/users/test-user#pubkey', 'http://localhost/users/test-user/following', 'http://localhost/users/test-users/followers', null, false); -insert into user_details (actor_id, password, auto_accept_follow_request, auto_accept_followee_follow_request) +insert into user_details (actor_id, password, auto_accept_followee_follow_request) values ( 1730415786666758144 - , '$2a$10$/mWC/n7nC7X3l9qCEOKnredxne2zewoqEsJWTOdlKfg2zXKJ0F9Em', true, true) + , '$2a$10$/mWC/n7nC7X3l9qCEOKnredxne2zewoqEsJWTOdlKfg2zXKJ0F9Em', true) diff --git a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/relationship/Relationship.kt b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/relationship/Relationship.kt index 0090a43a..ad9b9635 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/relationship/Relationship.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/relationship/Relationship.kt @@ -9,7 +9,7 @@ package dev.usbharu.hideout.core.domain.model.relationship * @property blocking ブロックしているか * @property muting ミュートしているか * @property followRequest フォローリクエストを送っているか - * @property ignoreFollowRequestFromTarget フォローリクエストを無視しているか + * @property ignoreFollowRequestToTarget フォローリクエストを無視しているか */ data class Relationship( val actorId: Long, @@ -18,5 +18,5 @@ data class Relationship( val blocking: Boolean, val muting: Boolean, val followRequest: Boolean, - val ignoreFollowRequestFromTarget: Boolean + val ignoreFollowRequestToTarget: Boolean ) diff --git a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/relationship/RelationshipRepositoryImpl.kt b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/relationship/RelationshipRepositoryImpl.kt index 6deef1bf..09be85c8 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/relationship/RelationshipRepositoryImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/relationship/RelationshipRepositoryImpl.kt @@ -25,7 +25,7 @@ class RelationshipRepositoryImpl : RelationshipRepository { it[blocking] = relationship.blocking it[muting] = relationship.muting it[followRequest] = relationship.followRequest - it[ignoreFollowRequestFromTarget] = relationship.ignoreFollowRequestFromTarget + it[ignoreFollowRequestFromTarget] = relationship.ignoreFollowRequestToTarget } } else { Relationships @@ -37,7 +37,7 @@ class RelationshipRepositoryImpl : RelationshipRepository { it[blocking] = relationship.blocking it[muting] = relationship.muting it[followRequest] = relationship.followRequest - it[ignoreFollowRequestFromTarget] = relationship.ignoreFollowRequestFromTarget + it[ignoreFollowRequestFromTarget] = relationship.ignoreFollowRequestToTarget } } return relationship @@ -66,7 +66,7 @@ fun ResultRow.toRelationships(): Relationship = Relationship( blocking = this[Relationships.blocking], muting = this[Relationships.muting], followRequest = this[Relationships.followRequest], - ignoreFollowRequestFromTarget = this[Relationships.ignoreFollowRequestFromTarget] + ignoreFollowRequestToTarget = this[Relationships.ignoreFollowRequestFromTarget] ) object Relationships : LongIdTable("relationships") { diff --git a/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedquery/RelationshipQueryServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedquery/RelationshipQueryServiceImpl.kt index f4f31633..5a5127e5 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedquery/RelationshipQueryServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedquery/RelationshipQueryServiceImpl.kt @@ -13,4 +13,18 @@ class RelationshipQueryServiceImpl : RelationshipQueryService { override suspend fun findByTargetIdAndFollowing(targetId: Long, following: Boolean): List = Relationships.select { Relationships.targetActorId eq targetId and (Relationships.following eq following) } .map { it.toRelationships() } + + override suspend fun findByTargetIdAndFollowRequestAndIgnoreFollowRequest( + targetId: Long, + followRequest: Boolean, + ignoreFollowRequest: Boolean + ): List { + return Relationships + .select { + Relationships.targetActorId.eq(targetId) + .and(Relationships.followRequest.eq(followRequest)) + .and(Relationships.ignoreFollowRequestFromTarget.eq(ignoreFollowRequest)) + } + .map { it.toRelationships() } + } } diff --git a/src/main/kotlin/dev/usbharu/hideout/core/query/RelationshipQueryService.kt b/src/main/kotlin/dev/usbharu/hideout/core/query/RelationshipQueryService.kt index 5f051397..324dc171 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/query/RelationshipQueryService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/query/RelationshipQueryService.kt @@ -5,4 +5,9 @@ import dev.usbharu.hideout.core.domain.model.relationship.Relationship interface RelationshipQueryService { suspend fun findByTargetIdAndFollowing(targetId: Long, following: Boolean): List + suspend fun findByTargetIdAndFollowRequestAndIgnoreFollowRequest( + targetId: Long, + followRequest: Boolean, + ignoreFollowRequest: Boolean + ): List } diff --git a/src/main/kotlin/dev/usbharu/hideout/core/service/relationship/RelationshipServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/core/service/relationship/RelationshipServiceImpl.kt index 9bddbb1a..67bd1bfe 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/service/relationship/RelationshipServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/service/relationship/RelationshipServiceImpl.kt @@ -38,7 +38,7 @@ class RelationshipServiceImpl( blocking = false, muting = false, followRequest = true, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) val inverseRelationship = relationshipRepository.findByUserIdAndTargetUserId(targetId, actorId) ?: Relationship( @@ -48,7 +48,7 @@ class RelationshipServiceImpl( blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) if (inverseRelationship.blocking) { @@ -60,7 +60,7 @@ class RelationshipServiceImpl( logger.debug("FAILED Blocking user. userId: {} targetId: {}", actorId, targetId) return } - if (inverseRelationship.ignoreFollowRequestFromTarget) { + if (relationship.ignoreFollowRequestToTarget) { logger.debug("SUCCESS Ignore Follow Request. userId: {} targetId: {}", actorId, targetId) return } @@ -95,7 +95,7 @@ class RelationshipServiceImpl( blocking = true, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) val inverseRelationship = relationshipRepository.findByUserIdAndTargetUserId(targetId, actorId) @@ -126,7 +126,7 @@ class RelationshipServiceImpl( blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) if (relationship == null) { @@ -191,16 +191,16 @@ class RelationshipServiceImpl( } override suspend fun ignoreFollowRequest(actorId: Long, targetId: Long) { - val relationship = relationshipRepository.findByUserIdAndTargetUserId(actorId, targetId) - ?.copy(ignoreFollowRequestFromTarget = true) + val relationship = relationshipRepository.findByUserIdAndTargetUserId(targetId, actorId) + ?.copy(ignoreFollowRequestToTarget = true) ?: Relationship( - actorId = actorId, - targetActorId = targetId, + actorId = targetId, + targetActorId = actorId, following = false, blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = true + ignoreFollowRequestToTarget = true ) relationshipRepository.save(relationship) @@ -263,7 +263,7 @@ class RelationshipServiceImpl( blocking = false, muting = true, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) relationshipRepository.save(relationship) diff --git a/src/main/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountApiService.kt b/src/main/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountApiService.kt index d94df813..8bb262c2 100644 --- a/src/main/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountApiService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountApiService.kt @@ -2,6 +2,7 @@ package dev.usbharu.hideout.mastodon.service.account import dev.usbharu.hideout.application.external.Transaction import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository +import dev.usbharu.hideout.core.query.RelationshipQueryService import dev.usbharu.hideout.core.service.media.MediaService import dev.usbharu.hideout.core.service.relationship.RelationshipService import dev.usbharu.hideout.core.service.user.UpdateUserDto @@ -49,6 +50,9 @@ interface AccountApiService { suspend fun unfollow(userid: Long, target: Long): Relationship suspend fun removeFromFollowers(userid: Long, target: Long): Relationship suspend fun updateProfile(userid: Long, updateCredentials: UpdateCredentials?): Account + suspend fun followRequests(loginUser: Long): List + suspend fun acceptFollowRequest(loginUser: Long, target: Long): Relationship + suspend fun rejectFollowRequest(loginUser: Long, target: Long): Relationship } @Service @@ -59,7 +63,8 @@ class AccountApiServiceImpl( private val statusQueryService: StatusQueryService, private val relationshipService: RelationshipService, private val relationshipRepository: RelationshipRepository, - private val mediaService: MediaService + private val mediaService: MediaService, + private val relationshipQueryService: RelationshipQueryService ) : AccountApiService { override suspend fun accountsStatuses( @@ -203,6 +208,26 @@ class AccountApiServiceImpl( accountService.findById(userid) } + override suspend fun followRequests(loginUser: Long): List = transaction.transaction { + val actorIdList = relationshipQueryService + .findByTargetIdAndFollowRequestAndIgnoreFollowRequest(loginUser, true, true) + .map { it.actorId } + + return@transaction accountService.findByIds(actorIdList) + } + + override suspend fun acceptFollowRequest(loginUser: Long, target: Long): Relationship = transaction.transaction { + relationshipService.acceptFollowRequest(loginUser, target) + + return@transaction fetchRelationship(loginUser, target) + } + + override suspend fun rejectFollowRequest(loginUser: Long, target: Long): Relationship = transaction.transaction { + relationshipService.rejectFollowRequest(loginUser, target) + + return@transaction fetchRelationship(loginUser, target) + } + private fun from(account: Account): CredentialAccount { return CredentialAccount( id = account.id, @@ -250,7 +275,7 @@ class AccountApiServiceImpl( blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) val inverseRelationship = relationshipRepository.findByUserIdAndTargetUserId(targetId, userid) @@ -261,7 +286,7 @@ class AccountApiServiceImpl( blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) return Relationship( diff --git a/src/main/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountService.kt b/src/main/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountService.kt index 0cdc4c2a..330ea164 100644 --- a/src/main/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountService.kt @@ -1,6 +1,7 @@ package dev.usbharu.hideout.mastodon.service.account import dev.usbharu.hideout.application.config.ApplicationConfig +import dev.usbharu.hideout.core.domain.model.actor.Actor import dev.usbharu.hideout.core.query.ActorQueryService import dev.usbharu.hideout.domain.mastodon.model.generated.Account import org.springframework.stereotype.Service @@ -8,6 +9,7 @@ import org.springframework.stereotype.Service @Service interface AccountService { suspend fun findById(id: Long): Account + suspend fun findByIds(ids: List): List } @Service @@ -17,6 +19,10 @@ class AccountServiceImpl( ) : AccountService { override suspend fun findById(id: Long): Account { val findById = actorQueryService.findById(id) + return toAccount(findById) + } + + private fun toAccount(findById: Actor): Account { val userUrl = applicationConfig.url.toString() + "/users/" + findById.id.toString() return Account( @@ -42,4 +48,7 @@ class AccountServiceImpl( followersCount = 0, ) } + + override suspend fun findByIds(ids: List): List = + actorQueryService.findByIds(ids).map { toAccount(it) } } diff --git a/src/main/resources/openapi/mastodon.yaml b/src/main/resources/openapi/mastodon.yaml index 49e382f6..854e8f68 100644 --- a/src/main/resources/openapi/mastodon.yaml +++ b/src/main/resources/openapi/mastodon.yaml @@ -576,6 +576,86 @@ paths: schema: $ref: "#/components/schemas/MediaAttachment" + /api/v1/follow_requests: + get: + tags: + - accounts + security: + - OAuth2: + - "read:follows" + parameters: + - in: query + name: max_id + schema: + type: integer + required: false + - in: query + name: since_id + schema: + type: integer + required: false + - in: query + name: limit + schema: + type: integer + required: false + responses: + 200: + description: 成功 + headers: + Link: + schema: + type: string + description: ページネーション + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/Account" + + /api/v1/follow_requests/{account_id}/authorize: + post: + tags: + - accounts + security: + - OAuth2: + - "write:follows" + parameters: + - in: path + name: account_id + schema: + type: string + required: true + responses: + 200: + description: 成功 + content: + application/json: + schema: + $ref: "#/components/schemas/Relationship" + + /api/v1/follow_requests/{account_id}/reject: + post: + tags: + - accounts + security: + - OAuth2: + - "write:follows" + parameters: + - in: path + name: account_id + schema: + type: string + required: true + responses: + 200: + description: 成功 + content: + application/json: + schema: + $ref: "#/components/schemas/Relationship" + components: schemas: V1MediaRequest: diff --git a/src/test/kotlin/dev/usbharu/hideout/core/service/relationship/RelationshipServiceImplTest.kt b/src/test/kotlin/dev/usbharu/hideout/core/service/relationship/RelationshipServiceImplTest.kt index 8598aae1..93c4216d 100644 --- a/src/test/kotlin/dev/usbharu/hideout/core/service/relationship/RelationshipServiceImplTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/core/service/relationship/RelationshipServiceImplTest.kt @@ -67,7 +67,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = true, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) ) @@ -91,7 +91,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = true, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) ) @@ -110,7 +110,7 @@ class RelationshipServiceImplTest { blocking = true, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) @@ -129,7 +129,7 @@ class RelationshipServiceImplTest { blocking = true, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) @@ -152,7 +152,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) @@ -167,7 +167,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) ) @@ -186,7 +186,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = true ) ) @@ -198,7 +198,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = true + ignoreFollowRequestToTarget = false ) ) @@ -222,7 +222,7 @@ class RelationshipServiceImplTest { blocking = true, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) ) @@ -246,7 +246,7 @@ class RelationshipServiceImplTest { blocking = true, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) ) @@ -266,7 +266,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = true, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) @@ -280,7 +280,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) @@ -302,7 +302,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = true, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) @@ -317,7 +317,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) ) @@ -366,7 +366,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) ) @@ -420,7 +420,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = true, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) @@ -435,7 +435,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) ) @@ -459,7 +459,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = true, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) @@ -474,7 +474,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) ) @@ -500,7 +500,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) @@ -516,13 +516,13 @@ class RelationshipServiceImplTest { verify(relationshipRepository, times(1)).save( eq( Relationship( - actorId = 1234, - targetActorId = 5678, + actorId = 5678, + targetActorId = 1234, following = false, blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = true + ignoreFollowRequestToTarget = true ) ) ) @@ -539,7 +539,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) @@ -554,7 +554,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) ) @@ -578,7 +578,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) @@ -593,7 +593,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) ) @@ -618,7 +618,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) @@ -638,7 +638,7 @@ class RelationshipServiceImplTest { blocking = true, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) @@ -653,7 +653,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) ) @@ -677,7 +677,7 @@ class RelationshipServiceImplTest { blocking = true, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) @@ -717,7 +717,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) @@ -739,7 +739,7 @@ class RelationshipServiceImplTest { blocking = false, muting = true, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) ) @@ -756,7 +756,7 @@ class RelationshipServiceImplTest { blocking = false, muting = true, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) @@ -771,7 +771,7 @@ class RelationshipServiceImplTest { blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) ) diff --git a/src/test/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountApiServiceImplTest.kt b/src/test/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountApiServiceImplTest.kt index 5beffa32..652997c5 100644 --- a/src/test/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountApiServiceImplTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountApiServiceImplTest.kt @@ -4,6 +4,7 @@ import dev.usbharu.hideout.application.external.Transaction import dev.usbharu.hideout.core.domain.model.actor.ActorRepository import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository import dev.usbharu.hideout.core.query.FollowerQueryService +import dev.usbharu.hideout.core.query.RelationshipQueryService import dev.usbharu.hideout.core.service.media.MediaService import dev.usbharu.hideout.core.service.relationship.RelationshipService import dev.usbharu.hideout.core.service.user.UserService @@ -49,6 +50,9 @@ class AccountApiServiceImplTest { @Mock private lateinit var relationshipRepository: RelationshipRepository + @Mock + private lateinit var relationshipQueryService: RelationshipQueryService + @Mock private lateinit var mediaService: MediaService @@ -214,7 +218,7 @@ class AccountApiServiceImplTest { blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) @@ -249,7 +253,7 @@ class AccountApiServiceImplTest { blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) ) whenever(relationshipRepository.findByUserIdAndTargetUserId(eq(userId), eq(followeeId))).doReturn( @@ -260,7 +264,7 @@ class AccountApiServiceImplTest { blocking = false, muting = false, followRequest = false, - ignoreFollowRequestFromTarget = false + ignoreFollowRequestToTarget = false ) )