feat: 未実装項目を実装

This commit is contained in:
usbharu 2023-12-21 11:27:46 +09:00
parent fddc29bdfd
commit e3a819f94d
3 changed files with 56 additions and 0 deletions

View File

@ -63,6 +63,36 @@ class RelationshipRepositoryImpl : RelationshipRepository {
Relationships.actorId.eq(actorId).or(Relationships.targetActorId.eq(targetActorId))
}
}
override suspend fun findByTargetIdAndFollowing(targetId: Long, following: Boolean): List<Relationship> {
return Relationships.select { Relationships.targetActorId eq targetId and (Relationships.following eq following) }
.map { it.toRelationships() }
}
override suspend fun findByTargetIdAndFollowRequestAndIgnoreFollowRequest(
maxId: Long?,
sinceId: Long?,
limit: Int,
targetId: Long,
followRequest: Boolean,
ignoreFollowRequest: Boolean
): List<Relationship> {
val query = Relationships.select {
Relationships.targetActorId.eq(targetId)
.and(Relationships.followRequest.eq(followRequest))
.and(Relationships.ignoreFollowRequestFromTarget.eq(ignoreFollowRequest))
}.limit(limit)
if (maxId != null) {
query.andWhere { Relationships.id lessEq maxId }
}
if (sinceId != null) {
query.andWhere { Relationships.id greaterEq sinceId }
}
return query.map { it.toRelationships() }
}
}
fun ResultRow.toRelationships(): Relationship = Relationship(

View File

@ -89,6 +89,10 @@ class PostRepositoryImpl(
return@query Posts.select { Posts.apId eq apId }.forUpdate().empty().not()
}
override suspend fun findByActorId(actorId: Long): List<Post> = query {
return@query Posts.select { Posts.actorId eq actorId }.let(postQueryMapper::map)
}
override suspend fun delete(id: Long): Unit = query {
Posts.deleteWhere { Posts.id eq id }
}

View File

@ -54,6 +54,28 @@ class ReactionRepositoryImpl(
Reactions.actorId eq actorId
}
}
override suspend fun findByPostId(postId: Long): List<Reaction> {
return Reactions.select { Reactions.postId eq postId }.map { it.toReaction() }
}
override suspend fun findByPostIdAndActorIdAndEmojiId(postId: Long, actorId: Long, emojiId: Long): Reaction? {
return Reactions.select {
Reactions.postId eq postId and (Reactions.actorId eq actorId).and(
Reactions.emojiId.eq(
emojiId
)
)
}.singleOrNull()?.toReaction()
}
override suspend fun existByPostIdAndActorIdAndEmojiId(postId: Long, actorId: Long, emojiId: Long): Boolean {
TODO("Not yet implemented")
}
override suspend fun findByPostIdAndActorId(postId: Long, actorId: Long): List<Reaction> {
TODO("Not yet implemented")
}
}
fun ResultRow.toReaction(): Reaction {