mirror of https://github.com/usbharu/Hideout.git
style: スタイルを修正
This commit is contained in:
parent
e2150c3a07
commit
5f01ccab63
|
@ -20,7 +20,6 @@ open class Key : Object {
|
|||
this.publicKeyPem = publicKeyPem
|
||||
}
|
||||
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is Key) return false
|
||||
|
|
|
@ -20,7 +20,6 @@ open class Object : JsonLd {
|
|||
this.id = id
|
||||
}
|
||||
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is Object) return false
|
||||
|
|
|
@ -52,8 +52,10 @@ fun Route.posts(postService: IPostService) {
|
|||
val userId = call.principal<JWTPrincipal>()?.payload?.getClaim("uid")?.asLong()
|
||||
val id = call.parameters["id"]?.toLong()
|
||||
?: throw ParameterNotExistException("Parameter(id='postsId') does not exist.")
|
||||
val post = (postService.findByIdForUser(id, userId)
|
||||
?: throw PostNotFoundException("$id was not found or is not authorized."))
|
||||
val post = (
|
||||
postService.findByIdForUser(id, userId)
|
||||
?: throw PostNotFoundException("$id was not found or is not authorized.")
|
||||
)
|
||||
call.respond(post)
|
||||
}
|
||||
}
|
||||
|
@ -76,14 +78,15 @@ fun Route.posts(postService: IPostService) {
|
|||
postService.findByUserIdForUser(targetUserId, forUserId = userId)
|
||||
}
|
||||
call.respond(posts)
|
||||
|
||||
}
|
||||
get("/{id}") {
|
||||
val userId = call.principal<JWTPrincipal>()?.payload?.getClaim("uid")?.asLong()
|
||||
val id = call.parameters["id"]?.toLong()
|
||||
?: throw ParameterNotExistException("Parameter(name='postsId' does not exist.")
|
||||
val post = (postService.findByIdForUser(id, userId)
|
||||
?: throw PostNotFoundException("$id was not found or is not authorized."))
|
||||
val post = (
|
||||
postService.findByIdForUser(id, userId)
|
||||
?: throw PostNotFoundException("$id was not found or is not authorized.")
|
||||
)
|
||||
call.respond(post)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,11 +38,12 @@ fun Route.users(userService: IUserService, userApiService: IUserApiService) {
|
|||
call.respond(HttpStatusCode.Created)
|
||||
}
|
||||
route("/{name}") {
|
||||
|
||||
authenticate(TOKEN_AUTH, optional = true) {
|
||||
get {
|
||||
val userParameter = (call.parameters["name"]
|
||||
?: throw ParameterNotExistException("Parameter(name='userName@domain') does not exist."))
|
||||
val userParameter = (
|
||||
call.parameters["name"]
|
||||
?: throw ParameterNotExistException("Parameter(name='userName@domain') does not exist.")
|
||||
)
|
||||
if (userParameter.toLongOrNull() != null) {
|
||||
return@get call.respond(userApiService.findById(userParameter.toLong()))
|
||||
} else {
|
||||
|
@ -63,7 +64,6 @@ fun Route.users(userService: IUserService, userApiService: IUserApiService) {
|
|||
return@get call.respond(userApiService.findFollowersByAcct(acct))
|
||||
}
|
||||
authenticate(TOKEN_AUTH) {
|
||||
|
||||
post {
|
||||
val userId = call.principal<JWTPrincipal>()?.payload?.getClaim("uid")?.asLong()
|
||||
?: throw IllegalStateException("no principal")
|
||||
|
@ -88,8 +88,10 @@ fun Route.users(userService: IUserService, userApiService: IUserApiService) {
|
|||
}
|
||||
route("/following") {
|
||||
get {
|
||||
val userParameter = (call.parameters["name"]
|
||||
?: throw ParameterNotExistException("Parameter(name='userName@domain') does not exist."))
|
||||
val userParameter = (
|
||||
call.parameters["name"]
|
||||
?: throw ParameterNotExistException("Parameter(name='userName@domain') does not exist.")
|
||||
)
|
||||
if (userParameter.toLongOrNull() != null) {
|
||||
return@get call.respond(userApiService.findFollowings(userParameter.toLong()))
|
||||
}
|
||||
|
@ -98,6 +100,5 @@ fun Route.users(userService: IUserService, userApiService: IUserApiService) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ class UserService(private val userRepository: IUserRepository, private val userA
|
|||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
//TODO APのフォロー処理を作る
|
||||
// TODO APのフォロー処理を作る
|
||||
override suspend fun addFollowers(id: Long, follower: Long): Boolean {
|
||||
userRepository.createFollower(id, follower)
|
||||
return false
|
||||
|
|
|
@ -26,7 +26,8 @@ object AcctUtil {
|
|||
val userName = substring.substringBefore("@")
|
||||
val domain = substring.substringAfter("@")
|
||||
Acct(
|
||||
userName, domain.ifBlank { null }
|
||||
userName,
|
||||
domain.ifBlank { null }
|
||||
)
|
||||
} else {
|
||||
throw IllegalArgumentException("Invalid acct.(@ are in the wrong position)")
|
||||
|
|
Loading…
Reference in New Issue