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