mirror of https://github.com/usbharu/Hideout.git
style: コードを整形
This commit is contained in:
parent
5e11b70d22
commit
cabecd4fce
|
@ -6,6 +6,7 @@ import org.jetbrains.exposed.dao.id.LongIdTable
|
||||||
object UsersFollowers : LongIdTable("users_followers") {
|
object UsersFollowers : LongIdTable("users_followers") {
|
||||||
val userId = long("user_id").references(Users.id).index()
|
val userId = long("user_id").references(Users.id).index()
|
||||||
val followerId = long("follower_id").references(Users.id)
|
val followerId = long("follower_id").references(Users.id)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
uniqueIndex(userId, followerId)
|
uniqueIndex(userId, followerId)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package dev.usbharu.hideout.domain.model.ap
|
package dev.usbharu.hideout.domain.model.ap
|
||||||
|
|
||||||
open class Accept : Object {
|
open class Accept : Object {
|
||||||
public var `object`: Object? = null
|
var `object`: Object? = null
|
||||||
public var actor:String? = null
|
var actor: String? = null
|
||||||
|
|
||||||
protected constructor() : super()
|
protected constructor() : super()
|
||||||
constructor(
|
constructor(
|
||||||
type: List<String> = emptyList(),
|
type: List<String> = emptyList(),
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package dev.usbharu.hideout.domain.model.ap
|
package dev.usbharu.hideout.domain.model.ap
|
||||||
|
|
||||||
open class Follow : Object {
|
open class Follow : Object {
|
||||||
public var `object`:String? = null
|
var `object`: String? = null
|
||||||
public var actor:String? = null
|
var actor: String? = null
|
||||||
|
|
||||||
protected constructor() : super()
|
protected constructor() : super()
|
||||||
constructor(
|
constructor(
|
||||||
type: List<String> = emptyList(),
|
type: List<String> = emptyList(),
|
||||||
|
|
|
@ -43,8 +43,11 @@ open class JsonLd {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ContextDeserializer : JsonDeserializer<String>() {
|
class ContextDeserializer : JsonDeserializer<String>() {
|
||||||
override fun deserialize(p0: com.fasterxml.jackson.core.JsonParser?, p1: com.fasterxml.jackson.databind.DeserializationContext?): String {
|
override fun deserialize(
|
||||||
|
p0: com.fasterxml.jackson.core.JsonParser?,
|
||||||
|
p1: com.fasterxml.jackson.databind.DeserializationContext?
|
||||||
|
): String {
|
||||||
val readTree: JsonNode = p0?.codec?.readTree(p0) ?: return ""
|
val readTree: JsonNode = p0?.codec?.readTree(p0) ?: return ""
|
||||||
if (readTree.isObject) {
|
if (readTree.isObject) {
|
||||||
return ""
|
return ""
|
||||||
|
@ -53,17 +56,17 @@ public class ContextDeserializer : JsonDeserializer<String>() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ContextSerializer : JsonSerializer<List<String>>() {
|
class ContextSerializer : JsonSerializer<List<String>>() {
|
||||||
override fun serialize(value: List<String>?, gen: JsonGenerator?, serializers: SerializerProvider?) {
|
override fun serialize(value: List<String>?, gen: JsonGenerator?, serializers: SerializerProvider?) {
|
||||||
if (value.isNullOrEmpty()) {
|
if (value.isNullOrEmpty()) {
|
||||||
gen?.writeNull()
|
gen?.writeNull()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (value?.size == 1) {
|
if (value.size == 1) {
|
||||||
gen?.writeString(value[0])
|
gen?.writeString(value[0])
|
||||||
} else {
|
} else {
|
||||||
gen?.writeStartArray()
|
gen?.writeStartArray()
|
||||||
value?.forEach {
|
value.forEach {
|
||||||
gen?.writeString(it)
|
gen?.writeString(it)
|
||||||
}
|
}
|
||||||
gen?.writeEndArray()
|
gen?.writeEndArray()
|
||||||
|
|
|
@ -4,6 +4,7 @@ open class Key : Object {
|
||||||
var id: String? = null
|
var id: String? = null
|
||||||
var owner: String? = null
|
var owner: String? = null
|
||||||
var publicKeyPem: String? = null
|
var publicKeyPem: String? = null
|
||||||
|
|
||||||
protected constructor() : super()
|
protected constructor() : super()
|
||||||
constructor(
|
constructor(
|
||||||
type: List<String>,
|
type: List<String>,
|
||||||
|
|
|
@ -6,6 +6,7 @@ open class Note : Object {
|
||||||
var content: String? = null
|
var content: String? = null
|
||||||
var published: String? = null
|
var published: String? = null
|
||||||
var to: List<String> = emptyList()
|
var to: List<String> = emptyList()
|
||||||
|
|
||||||
protected constructor() : super()
|
protected constructor() : super()
|
||||||
constructor(
|
constructor(
|
||||||
type: List<String> = emptyList(),
|
type: List<String> = emptyList(),
|
||||||
|
|
|
@ -46,7 +46,7 @@ open class Object : JsonLd {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TypeSerializer : JsonSerializer<List<String>>() {
|
class TypeSerializer : JsonSerializer<List<String>>() {
|
||||||
override fun serialize(value: List<String>?, gen: JsonGenerator?, serializers: SerializerProvider?) {
|
override fun serialize(value: List<String>?, gen: JsonGenerator?, serializers: SerializerProvider?) {
|
||||||
println(value)
|
println(value)
|
||||||
if (value?.size == 1) {
|
if (value?.size == 1) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ open class Person : Object {
|
||||||
private var url: String? = null
|
private var url: String? = null
|
||||||
private var icon: Image? = null
|
private var icon: Image? = null
|
||||||
var publicKey: Key? = null
|
var publicKey: Key? = null
|
||||||
|
|
||||||
protected constructor() : super()
|
protected constructor() : super()
|
||||||
constructor(
|
constructor(
|
||||||
type: List<String> = emptyList(),
|
type: List<String> = emptyList(),
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package dev.usbharu.hideout.plugins
|
package dev.usbharu.hideout.plugins
|
||||||
|
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
|
import io.ktor.server.application.*
|
||||||
import io.ktor.server.plugins.cors.routing.*
|
import io.ktor.server.plugins.cors.routing.*
|
||||||
import io.ktor.server.plugins.defaultheaders.*
|
import io.ktor.server.plugins.defaultheaders.*
|
||||||
import io.ktor.server.plugins.forwardedheaders.*
|
import io.ktor.server.plugins.forwardedheaders.*
|
||||||
import io.ktor.server.application.*
|
|
||||||
|
|
||||||
fun Application.configureHTTP() {
|
fun Application.configureHTTP() {
|
||||||
install(CORS) {
|
install(CORS) {
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package dev.usbharu.hideout.plugins
|
package dev.usbharu.hideout.plugins
|
||||||
|
|
||||||
import io.ktor.server.plugins.callloging.*
|
|
||||||
import org.slf4j.event.*
|
|
||||||
import io.ktor.server.request.*
|
|
||||||
import io.ktor.server.application.*
|
import io.ktor.server.application.*
|
||||||
|
import io.ktor.server.plugins.callloging.*
|
||||||
|
import org.slf4j.event.Level
|
||||||
|
|
||||||
fun Application.configureMonitoring() {
|
fun Application.configureMonitoring() {
|
||||||
install(CallLogging) {
|
install(CallLogging) {
|
||||||
|
|
|
@ -3,8 +3,6 @@ package dev.usbharu.hideout.plugins
|
||||||
import dev.usbharu.hideout.service.IUserAuthService
|
import dev.usbharu.hideout.service.IUserAuthService
|
||||||
import io.ktor.server.application.*
|
import io.ktor.server.application.*
|
||||||
import io.ktor.server.auth.*
|
import io.ktor.server.auth.*
|
||||||
import io.ktor.server.sessions.*
|
|
||||||
import kotlin.collections.set
|
|
||||||
|
|
||||||
data class UserSession(val username: String) : Principal
|
data class UserSession(val username: String) : Principal
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,9 @@ import com.fasterxml.jackson.annotation.JsonInclude
|
||||||
import com.fasterxml.jackson.annotation.JsonSetter
|
import com.fasterxml.jackson.annotation.JsonSetter
|
||||||
import com.fasterxml.jackson.annotation.Nulls
|
import com.fasterxml.jackson.annotation.Nulls
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature
|
import com.fasterxml.jackson.databind.DeserializationFeature
|
||||||
import dev.usbharu.hideout.util.HttpUtil.Activity
|
|
||||||
import io.ktor.http.*
|
|
||||||
import io.ktor.serialization.jackson.*
|
import io.ktor.serialization.jackson.*
|
||||||
import io.ktor.server.application.*
|
import io.ktor.server.application.*
|
||||||
import io.ktor.server.plugins.contentnegotiation.*
|
import io.ktor.server.plugins.contentnegotiation.*
|
||||||
import io.ktor.server.response.*
|
|
||||||
import io.ktor.server.routing.*
|
|
||||||
|
|
||||||
fun Application.configureSerialization() {
|
fun Application.configureSerialization() {
|
||||||
install(ContentNegotiation) {
|
install(ContentNegotiation) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ class ActivityPubServiceImpl(
|
||||||
return ActivityType.values().first { it.name.equals(type.asText(), true) }
|
return ActivityType.values().first { it.name.equals(type.asText(), true) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun processActivity(json: String, type: ActivityType): ActivityPubResponse? {
|
override suspend fun processActivity(json: String, type: ActivityType): ActivityPubResponse {
|
||||||
return when (type) {
|
return when (type) {
|
||||||
ActivityType.Accept -> TODO()
|
ActivityType.Accept -> TODO()
|
||||||
ActivityType.Add -> TODO()
|
ActivityType.Add -> TODO()
|
||||||
|
|
|
@ -10,7 +10,7 @@ import tech.barbero.http.message.signing.SignatureHeaderVerifier
|
||||||
class HttpSignatureVerifyServiceImpl(private val userAuthService: IUserRepository) : HttpSignatureVerifyService {
|
class HttpSignatureVerifyServiceImpl(private val userAuthService: IUserRepository) : HttpSignatureVerifyService {
|
||||||
override fun verify(headers: Headers): Boolean {
|
override fun verify(headers: Headers): Boolean {
|
||||||
val build = SignatureHeaderVerifier.builder().keyMap(KtorKeyMap(userAuthService)).build()
|
val build = SignatureHeaderVerifier.builder().keyMap(KtorKeyMap(userAuthService)).build()
|
||||||
return true;
|
return true
|
||||||
build.verify(object : HttpMessage {
|
build.verify(object : HttpMessage {
|
||||||
override fun headerValues(name: String?): MutableList<String> {
|
override fun headerValues(name: String?): MutableList<String> {
|
||||||
return name?.let { headers.getAll(it) }?.toMutableList() ?: mutableListOf()
|
return name?.let { headers.getAll(it) }?.toMutableList() ?: mutableListOf()
|
||||||
|
|
|
@ -30,6 +30,10 @@ object HttpUtil {
|
||||||
get() = ContentType("application", "activity+json")
|
get() = ContentType("application", "activity+json")
|
||||||
|
|
||||||
val ContentType.Application.JsonLd: ContentType
|
val ContentType.Application.JsonLd: ContentType
|
||||||
get() = ContentType("application", "ld+json", listOf(HeaderValueParam("profile", "https://www.w3.org/ns/activitystreams")))
|
get() = ContentType(
|
||||||
|
"application",
|
||||||
|
"ld+json",
|
||||||
|
listOf(HeaderValueParam("profile", "https://www.w3.org/ns/activitystreams"))
|
||||||
|
)
|
||||||
// fun
|
// fun
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ import org.jetbrains.exposed.dao.id.LongIdTable
|
||||||
import org.jetbrains.exposed.sql.*
|
import org.jetbrains.exposed.sql.*
|
||||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.inList
|
import org.jetbrains.exposed.sql.SqlExpressionBuilder.inList
|
||||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.isNull
|
|
||||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.plus
|
import org.jetbrains.exposed.sql.SqlExpressionBuilder.plus
|
||||||
import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction
|
import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta content="width=device-width, initial-scale=1" name="viewport"/>
|
||||||
<meta name="theme-color" content="#000000" />
|
<meta content="#000000" name="theme-color"/>
|
||||||
<title>Solid App</title>
|
<title>Solid App</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
Loading…
Reference in New Issue