mirror of https://github.com/usbharu/Hideout.git
refactor: 不要な関数を削除
This commit is contained in:
parent
642912d5f3
commit
6265d0772a
|
@ -5,12 +5,16 @@ import dev.usbharu.hideout.domain.model.ActivityPubStringResponse
|
||||||
import dev.usbharu.hideout.domain.model.ap.Accept
|
import dev.usbharu.hideout.domain.model.ap.Accept
|
||||||
import dev.usbharu.hideout.domain.model.ap.Follow
|
import dev.usbharu.hideout.domain.model.ap.Follow
|
||||||
import dev.usbharu.hideout.exception.ap.IllegalActivityPubObjectException
|
import dev.usbharu.hideout.exception.ap.IllegalActivityPubObjectException
|
||||||
|
import dev.usbharu.hideout.query.UserQueryService
|
||||||
import dev.usbharu.hideout.service.user.IUserService
|
import dev.usbharu.hideout.service.user.IUserService
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import org.koin.core.annotation.Single
|
import org.koin.core.annotation.Single
|
||||||
|
|
||||||
@Single
|
@Single
|
||||||
class ActivityPubAcceptServiceImpl(private val userService: IUserService) : ActivityPubAcceptService {
|
class ActivityPubAcceptServiceImpl(
|
||||||
|
private val userService: IUserService,
|
||||||
|
private val userQueryService: UserQueryService
|
||||||
|
) : ActivityPubAcceptService {
|
||||||
override suspend fun receiveAccept(accept: Accept): ActivityPubResponse {
|
override suspend fun receiveAccept(accept: Accept): ActivityPubResponse {
|
||||||
val value = accept.`object` ?: throw IllegalActivityPubObjectException("object is null")
|
val value = accept.`object` ?: throw IllegalActivityPubObjectException("object is null")
|
||||||
if (value.type.contains("Follow").not()) {
|
if (value.type.contains("Follow").not()) {
|
||||||
|
@ -20,8 +24,8 @@ class ActivityPubAcceptServiceImpl(private val userService: IUserService) : Acti
|
||||||
val follow = value as Follow
|
val follow = value as Follow
|
||||||
val userUrl = follow.`object` ?: throw IllegalActivityPubObjectException("object is null")
|
val userUrl = follow.`object` ?: throw IllegalActivityPubObjectException("object is null")
|
||||||
val followerUrl = follow.actor ?: throw IllegalActivityPubObjectException("actor is null")
|
val followerUrl = follow.actor ?: throw IllegalActivityPubObjectException("actor is null")
|
||||||
val user = userService.findByUrl(userUrl)
|
val user = userQueryService.findByUrl(userUrl)
|
||||||
val follower = userService.findByUrl(followerUrl)
|
val follower = userQueryService.findByUrl(followerUrl)
|
||||||
userService.follow(user.id, follower.id)
|
userService.follow(user.id, follower.id)
|
||||||
return ActivityPubStringResponse(HttpStatusCode.OK, "accepted")
|
return ActivityPubStringResponse(HttpStatusCode.OK, "accepted")
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import dev.usbharu.hideout.domain.model.ActivityPubStringResponse
|
||||||
import dev.usbharu.hideout.domain.model.ap.Like
|
import dev.usbharu.hideout.domain.model.ap.Like
|
||||||
import dev.usbharu.hideout.exception.PostNotFoundException
|
import dev.usbharu.hideout.exception.PostNotFoundException
|
||||||
import dev.usbharu.hideout.exception.ap.IllegalActivityPubObjectException
|
import dev.usbharu.hideout.exception.ap.IllegalActivityPubObjectException
|
||||||
|
import dev.usbharu.hideout.query.UserQueryService
|
||||||
import dev.usbharu.hideout.repository.IPostRepository
|
import dev.usbharu.hideout.repository.IPostRepository
|
||||||
import dev.usbharu.hideout.service.reaction.IReactionService
|
import dev.usbharu.hideout.service.reaction.IReactionService
|
||||||
import dev.usbharu.hideout.service.user.IUserService
|
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import org.koin.core.annotation.Single
|
import org.koin.core.annotation.Single
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@ import org.koin.core.annotation.Single
|
||||||
class ActivityPubLikeServiceImpl(
|
class ActivityPubLikeServiceImpl(
|
||||||
private val reactionService: IReactionService,
|
private val reactionService: IReactionService,
|
||||||
private val activityPubUserService: ActivityPubUserService,
|
private val activityPubUserService: ActivityPubUserService,
|
||||||
private val userService: IUserService,
|
|
||||||
private val postService: IPostRepository,
|
private val postService: IPostRepository,
|
||||||
private val activityPubNoteService: ActivityPubNoteService
|
private val activityPubNoteService: ActivityPubNoteService,
|
||||||
|
private val userQueryService: UserQueryService
|
||||||
) : ActivityPubLikeService {
|
) : ActivityPubLikeService {
|
||||||
override suspend fun receiveLike(like: Like): ActivityPubResponse {
|
override suspend fun receiveLike(like: Like): ActivityPubResponse {
|
||||||
val actor = like.actor ?: throw IllegalActivityPubObjectException("actor is null")
|
val actor = like.actor ?: throw IllegalActivityPubObjectException("actor is null")
|
||||||
|
@ -26,7 +26,7 @@ class ActivityPubLikeServiceImpl(
|
||||||
val person = activityPubUserService.fetchPerson(actor)
|
val person = activityPubUserService.fetchPerson(actor)
|
||||||
activityPubNoteService.fetchNote(like.`object`!!)
|
activityPubNoteService.fetchNote(like.`object`!!)
|
||||||
|
|
||||||
val user = userService.findByUrl(
|
val user = userQueryService.findByUrl(
|
||||||
person.url
|
person.url
|
||||||
?: throw IllegalActivityPubObjectException("actor is not found")
|
?: throw IllegalActivityPubObjectException("actor is not found")
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,6 +4,7 @@ import dev.usbharu.hideout.domain.model.ActivityPubResponse
|
||||||
import dev.usbharu.hideout.domain.model.ActivityPubStringResponse
|
import dev.usbharu.hideout.domain.model.ActivityPubStringResponse
|
||||||
import dev.usbharu.hideout.domain.model.ap.Follow
|
import dev.usbharu.hideout.domain.model.ap.Follow
|
||||||
import dev.usbharu.hideout.domain.model.ap.Undo
|
import dev.usbharu.hideout.domain.model.ap.Undo
|
||||||
|
import dev.usbharu.hideout.query.UserQueryService
|
||||||
import dev.usbharu.hideout.service.user.IUserService
|
import dev.usbharu.hideout.service.user.IUserService
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import org.koin.core.annotation.Single
|
import org.koin.core.annotation.Single
|
||||||
|
@ -12,7 +13,8 @@ import org.koin.core.annotation.Single
|
||||||
@Suppress("UnsafeCallOnNullableType")
|
@Suppress("UnsafeCallOnNullableType")
|
||||||
class ActivityPubUndoServiceImpl(
|
class ActivityPubUndoServiceImpl(
|
||||||
private val userService: IUserService,
|
private val userService: IUserService,
|
||||||
private val activityPubUserService: ActivityPubUserService
|
private val activityPubUserService: ActivityPubUserService,
|
||||||
|
private val userQueryService: UserQueryService
|
||||||
) : ActivityPubUndoService {
|
) : ActivityPubUndoService {
|
||||||
override suspend fun receiveUndo(undo: Undo): ActivityPubResponse {
|
override suspend fun receiveUndo(undo: Undo): ActivityPubResponse {
|
||||||
if (undo.actor == null) {
|
if (undo.actor == null) {
|
||||||
|
@ -33,8 +35,8 @@ class ActivityPubUndoServiceImpl(
|
||||||
}
|
}
|
||||||
|
|
||||||
activityPubUserService.fetchPerson(undo.actor!!, follow.`object`)
|
activityPubUserService.fetchPerson(undo.actor!!, follow.`object`)
|
||||||
val follower = userService.findByUrl(undo.actor!!)
|
val follower = userQueryService.findByUrl(undo.actor!!)
|
||||||
val target = userService.findByUrl(follow.`object`!!)
|
val target = userQueryService.findByUrl(follow.`object`!!)
|
||||||
userService.unfollow(target.id, follower.id)
|
userService.unfollow(target.id, follower.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,6 @@ import dev.usbharu.hideout.domain.model.hideout.entity.User
|
||||||
@Suppress("TooManyFunctions")
|
@Suppress("TooManyFunctions")
|
||||||
interface IUserService {
|
interface IUserService {
|
||||||
|
|
||||||
suspend fun findByNameLocalUser(name: String): User
|
|
||||||
|
|
||||||
suspend fun findByUrl(url: String): User
|
|
||||||
|
|
||||||
suspend fun findByUrls(urls: List<String>): List<User>
|
suspend fun findByUrls(urls: List<String>): List<User>
|
||||||
|
|
||||||
suspend fun usernameAlreadyUse(username: String): Boolean
|
suspend fun usernameAlreadyUse(username: String): Boolean
|
||||||
|
|
Loading…
Reference in New Issue