mirror of https://github.com/usbharu/Hideout.git
feat: 未実装だったものを実装
This commit is contained in:
parent
5fad278b0b
commit
7848a5da29
|
@ -54,7 +54,7 @@ interface RelationshipRepository {
|
||||||
|
|
||||||
suspend fun countByTargetIdAndFollowing(targetId: Long, following: Boolean): Int
|
suspend fun countByTargetIdAndFollowing(targetId: Long, following: Boolean): Int
|
||||||
|
|
||||||
suspend fun countByUserIdAndFollowing(targetId: Long, following: Boolean): Int
|
suspend fun countByUserIdAndFollowing(userId: Long, following: Boolean): Int
|
||||||
|
|
||||||
@Suppress("FunctionMaxLength")
|
@Suppress("FunctionMaxLength")
|
||||||
suspend fun findByTargetIdAndFollowRequestAndIgnoreFollowRequest(
|
suspend fun findByTargetIdAndFollowRequestAndIgnoreFollowRequest(
|
||||||
|
|
|
@ -92,11 +92,31 @@ class RelationshipRepositoryImpl : RelationshipRepository, AbstractRepository()
|
||||||
.map { it.toRelationships() }
|
.map { it.toRelationships() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun countByTargetIdAndFollowing(targetId: Long, following: Boolean): Int = query {
|
||||||
|
return@query Relationships
|
||||||
|
.selectAll()
|
||||||
|
.where {
|
||||||
|
Relationships.targetActorId eq targetId and (Relationships.following eq following)
|
||||||
|
}
|
||||||
|
.count()
|
||||||
|
.toInt()
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun countByUserIdAndFollowing(userId: Long, following: Boolean): Int = query {
|
||||||
|
return@query Relationships
|
||||||
|
.selectAll()
|
||||||
|
.where {
|
||||||
|
Relationships.actorId eq userId and (Relationships.following eq following)
|
||||||
|
}
|
||||||
|
.count()
|
||||||
|
.toInt()
|
||||||
|
}
|
||||||
|
|
||||||
override suspend fun findByTargetIdAndFollowRequestAndIgnoreFollowRequest(
|
override suspend fun findByTargetIdAndFollowRequestAndIgnoreFollowRequest(
|
||||||
targetId: Long,
|
targetId: Long,
|
||||||
followRequest: Boolean,
|
followRequest: Boolean,
|
||||||
ignoreFollowRequest: Boolean,
|
ignoreFollowRequest: Boolean,
|
||||||
page: Page.PageByMaxId
|
page: Page.PageByMaxId,
|
||||||
): PaginationList<Relationship, Long> = query {
|
): PaginationList<Relationship, Long> = query {
|
||||||
val query = Relationships.selectAll().where {
|
val query = Relationships.selectAll().where {
|
||||||
Relationships.targetActorId.eq(targetId).and(Relationships.followRequest.eq(followRequest))
|
Relationships.targetActorId.eq(targetId).and(Relationships.followRequest.eq(followRequest))
|
||||||
|
@ -115,7 +135,7 @@ class RelationshipRepositoryImpl : RelationshipRepository, AbstractRepository()
|
||||||
override suspend fun findByActorIdAndMuting(
|
override suspend fun findByActorIdAndMuting(
|
||||||
actorId: Long,
|
actorId: Long,
|
||||||
muting: Boolean,
|
muting: Boolean,
|
||||||
page: Page.PageByMaxId
|
page: Page.PageByMaxId,
|
||||||
): PaginationList<Relationship, Long> = query {
|
): PaginationList<Relationship, Long> = query {
|
||||||
val query =
|
val query =
|
||||||
Relationships.selectAll().where { Relationships.actorId.eq(actorId).and(Relationships.muting.eq(muting)) }
|
Relationships.selectAll().where { Relationships.actorId.eq(actorId).and(Relationships.muting.eq(muting)) }
|
||||||
|
|
|
@ -133,6 +133,14 @@ class PostRepositoryImpl(
|
||||||
.selectAll().where { Posts.actorId eq actorId }.let(postQueryMapper::map)
|
.selectAll().where { Posts.actorId eq actorId }.let(postQueryMapper::map)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun countByActorId(actorId: Long): Int = query {
|
||||||
|
return@query Posts
|
||||||
|
.selectAll()
|
||||||
|
.where { Posts.actorId eq actorId }
|
||||||
|
.count()
|
||||||
|
.toInt()
|
||||||
|
}
|
||||||
|
|
||||||
override suspend fun delete(id: Long): Unit = query {
|
override suspend fun delete(id: Long): Unit = query {
|
||||||
Posts.deleteWhere { Posts.id eq id }
|
Posts.deleteWhere { Posts.id eq id }
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,8 @@ class ActorServiceTest {
|
||||||
reactionRepository = mock(),
|
reactionRepository = mock(),
|
||||||
relationshipRepository = mock(),
|
relationshipRepository = mock(),
|
||||||
postService = mock(),
|
postService = mock(),
|
||||||
apSendDeleteService = mock()
|
apSendDeleteService = mock(),
|
||||||
|
postRepository = mock()
|
||||||
)
|
)
|
||||||
userService.createLocalUser(UserCreateDto("test", "testUser", "XXXXXXXXXXXXX", "test"))
|
userService.createLocalUser(UserCreateDto("test", "testUser", "XXXXXXXXXXXXX", "test"))
|
||||||
verify(actorRepository, times(1)).save(any())
|
verify(actorRepository, times(1)).save(any())
|
||||||
|
@ -100,7 +101,8 @@ class ActorServiceTest {
|
||||||
reactionRepository = mock(),
|
reactionRepository = mock(),
|
||||||
relationshipRepository = mock(),
|
relationshipRepository = mock(),
|
||||||
postService = mock(),
|
postService = mock(),
|
||||||
apSendDeleteService = mock()
|
apSendDeleteService = mock(),
|
||||||
|
postRepository = mock()
|
||||||
)
|
)
|
||||||
val user = RemoteUserCreateDto(
|
val user = RemoteUserCreateDto(
|
||||||
name = "test",
|
name = "test",
|
||||||
|
|
Loading…
Reference in New Issue