mirror of https://github.com/usbharu/Hideout.git
Apply suggestions from code review
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
55783fefa2
commit
e9e96508ba
|
@ -40,6 +40,4 @@ open class Block(
|
||||||
")" +
|
")" +
|
||||||
" ${super.toString()}"
|
" ${super.toString()}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,4 @@ open class Reject(
|
||||||
")" +
|
")" +
|
||||||
" ${super.toString()}"
|
" ${super.toString()}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,5 +32,4 @@ class ApSendAcceptServiceImpl(
|
||||||
|
|
||||||
jobQueueParentService.scheduleTypeSafe(deliverAcceptJob, deliverAcceptJobParam)
|
jobQueueParentService.scheduleTypeSafe(deliverAcceptJob, deliverAcceptJobParam)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ class APDeliverBlockJobProcessor(
|
||||||
private val deliverBlockJob: DeliverBlockJob
|
private val deliverBlockJob: DeliverBlockJob
|
||||||
) : JobProcessor<DeliverBlockJobParam, DeliverBlockJob> {
|
) : JobProcessor<DeliverBlockJobParam, DeliverBlockJob> {
|
||||||
override suspend fun process(param: DeliverBlockJobParam): Unit = transaction.transaction {
|
override suspend fun process(param: DeliverBlockJobParam): Unit = transaction.transaction {
|
||||||
|
|
||||||
val signer = userRepository.findById(param.signer)
|
val signer = userRepository.findById(param.signer)
|
||||||
apRequestService.apPost(
|
apRequestService.apPost(
|
||||||
param.inbox,
|
param.inbox,
|
||||||
|
|
|
@ -9,7 +9,6 @@ import dev.usbharu.hideout.core.query.UserQueryService
|
||||||
import dev.usbharu.hideout.core.service.relationship.RelationshipService
|
import dev.usbharu.hideout.core.service.relationship.RelationshipService
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ブロックアクティビティを処理します
|
* ブロックアクティビティを処理します
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -16,7 +16,6 @@ class ApSendRejectServiceImpl(
|
||||||
private val deliverRejectJob: DeliverRejectJob
|
private val deliverRejectJob: DeliverRejectJob
|
||||||
) : ApSendRejectService {
|
) : ApSendRejectService {
|
||||||
override suspend fun sendRejectFollow(user: User, target: User) {
|
override suspend fun sendRejectFollow(user: User, target: User) {
|
||||||
|
|
||||||
val deliverRejectJobParam = DeliverRejectJobParam(
|
val deliverRejectJobParam = DeliverRejectJobParam(
|
||||||
Reject(
|
Reject(
|
||||||
user.url,
|
user.url,
|
||||||
|
|
|
@ -57,7 +57,6 @@ class RelationshipRepositoryImpl : RelationshipRepository {
|
||||||
}.singleOrNull()
|
}.singleOrNull()
|
||||||
?.toRelationships()
|
?.toRelationships()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ResultRow.toRelationships(): Relationship = Relationship(
|
fun ResultRow.toRelationships(): Relationship = Relationship(
|
||||||
|
|
|
@ -49,6 +49,4 @@ class DeliverBlockJob(@Qualifier("activitypub") private val objectMapper: Object
|
||||||
objectMapper.readValue(props[reject]),
|
objectMapper.readValue(props[reject]),
|
||||||
props[inbox]
|
props[inbox]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,8 @@ class FollowerQueryServiceImpl(
|
||||||
) : FollowerQueryService {
|
) : FollowerQueryService {
|
||||||
override suspend fun findFollowersById(id: Long): List<User> {
|
override suspend fun findFollowersById(id: Long): List<User> {
|
||||||
return userQueryService.findByIds(
|
return userQueryService.findByIds(
|
||||||
relationshipQueryService.findByTargetIdAndFollowing(id, true).map { it.userId })
|
relationshipQueryService.findByTargetIdAndFollowing(id, true).map { it.userId }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun alreadyFollow(userId: Long, followerId: Long): Boolean =
|
override suspend fun alreadyFollow(userId: Long, followerId: Long): Boolean =
|
||||||
|
|
|
@ -19,5 +19,4 @@ interface RelationshipService {
|
||||||
suspend fun unblock(userId: Long, targetId: Long)
|
suspend fun unblock(userId: Long, targetId: Long)
|
||||||
suspend fun mute(userId: Long, targetId: Long)
|
suspend fun mute(userId: Long, targetId: Long)
|
||||||
suspend fun unmute(userId: Long, targetId: Long)
|
suspend fun unmute(userId: Long, targetId: Long)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ class RelationshipServiceImpl(
|
||||||
val user = userQueryService.findById(userId)
|
val user = userQueryService.findById(userId)
|
||||||
apSendFollowService.sendFollow(SendFollowDto(user, remoteUser))
|
apSendFollowService.sendFollow(SendFollowDto(user, remoteUser))
|
||||||
} else {
|
} else {
|
||||||
//TODO: フォロー許可制ユーザーを実装したら消す
|
// TODO: フォロー許可制ユーザーを実装したら消す
|
||||||
acceptFollowRequest(targetId, userId)
|
acceptFollowRequest(targetId, userId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,12 +135,16 @@ class RelationshipServiceImpl(
|
||||||
|
|
||||||
if (relationship.blocking) {
|
if (relationship.blocking) {
|
||||||
logger.warn("FAILED Blocking user userId: {} targetId: {}", userId, targetId)
|
logger.warn("FAILED Blocking user userId: {} targetId: {}", userId, targetId)
|
||||||
throw IllegalStateException("Cannot accept a follow request from a blocked user. userId: $userId targetId: $targetId")
|
throw IllegalStateException(
|
||||||
|
"Cannot accept a follow request from a blocked user. userId: $userId targetId: $targetId"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inverseRelationship.blocking) {
|
if (inverseRelationship.blocking) {
|
||||||
logger.warn("FAILED BLocked by user userId: {} targetId: {}", userId, targetId)
|
logger.warn("FAILED BLocked by user userId: {} targetId: {}", userId, targetId)
|
||||||
throw IllegalStateException("Cannot accept a follow request from a blocking user. userId: $userId targetId: $targetId")
|
throw IllegalStateException(
|
||||||
|
"Cannot accept a follow request from a blocking user. userId: $userId targetId: $targetId"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val copy = relationship.copy(followRequest = false, following = true, blocking = false)
|
val copy = relationship.copy(followRequest = false, following = true, blocking = false)
|
||||||
|
@ -237,7 +241,6 @@ class RelationshipServiceImpl(
|
||||||
val copy = relationship.copy(blocking = false)
|
val copy = relationship.copy(blocking = false)
|
||||||
relationshipRepository.save(copy)
|
relationshipRepository.save(copy)
|
||||||
|
|
||||||
|
|
||||||
val remoteUser = isRemoteUser(targetId)
|
val remoteUser = isRemoteUser(targetId)
|
||||||
if (remoteUser != null) {
|
if (remoteUser != null) {
|
||||||
val user = userQueryService.findById(userId)
|
val user = userQueryService.findById(userId)
|
||||||
|
|
Loading…
Reference in New Issue