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 countByUserIdAndFollowing(targetId: Long, following: Boolean): Int
|
||||
suspend fun countByUserIdAndFollowing(userId: Long, following: Boolean): Int
|
||||
|
||||
@Suppress("FunctionMaxLength")
|
||||
suspend fun findByTargetIdAndFollowRequestAndIgnoreFollowRequest(
|
||||
|
|
|
@ -92,11 +92,31 @@ class RelationshipRepositoryImpl : RelationshipRepository, AbstractRepository()
|
|||
.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(
|
||||
targetId: Long,
|
||||
followRequest: Boolean,
|
||||
ignoreFollowRequest: Boolean,
|
||||
page: Page.PageByMaxId
|
||||
page: Page.PageByMaxId,
|
||||
): PaginationList<Relationship, Long> = query {
|
||||
val query = Relationships.selectAll().where {
|
||||
Relationships.targetActorId.eq(targetId).and(Relationships.followRequest.eq(followRequest))
|
||||
|
@ -115,7 +135,7 @@ class RelationshipRepositoryImpl : RelationshipRepository, AbstractRepository()
|
|||
override suspend fun findByActorIdAndMuting(
|
||||
actorId: Long,
|
||||
muting: Boolean,
|
||||
page: Page.PageByMaxId
|
||||
page: Page.PageByMaxId,
|
||||
): PaginationList<Relationship, Long> = query {
|
||||
val query =
|
||||
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)
|
||||
}
|
||||
|
||||
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 {
|
||||
Posts.deleteWhere { Posts.id eq id }
|
||||
}
|
||||
|
|
|
@ -62,7 +62,8 @@ class ActorServiceTest {
|
|||
reactionRepository = mock(),
|
||||
relationshipRepository = mock(),
|
||||
postService = mock(),
|
||||
apSendDeleteService = mock()
|
||||
apSendDeleteService = mock(),
|
||||
postRepository = mock()
|
||||
)
|
||||
userService.createLocalUser(UserCreateDto("test", "testUser", "XXXXXXXXXXXXX", "test"))
|
||||
verify(actorRepository, times(1)).save(any())
|
||||
|
@ -100,7 +101,8 @@ class ActorServiceTest {
|
|||
reactionRepository = mock(),
|
||||
relationshipRepository = mock(),
|
||||
postService = mock(),
|
||||
apSendDeleteService = mock()
|
||||
apSendDeleteService = mock(),
|
||||
postRepository = mock()
|
||||
)
|
||||
val user = RemoteUserCreateDto(
|
||||
name = "test",
|
||||
|
|
Loading…
Reference in New Issue