mirror of https://github.com/usbharu/Hideout.git
style: コードを整形
This commit is contained in:
parent
5e11b70d22
commit
cabecd4fce
|
@ -29,7 +29,7 @@ data class Post(
|
|||
|
||||
data class PostEntity(
|
||||
val id: Long,
|
||||
val userId:Long,
|
||||
val userId: Long,
|
||||
val overview: String? = null,
|
||||
val text: String,
|
||||
val createdAt: Long,
|
||||
|
@ -39,7 +39,7 @@ data class PostEntity(
|
|||
val replyId: Long? = null
|
||||
)
|
||||
|
||||
fun ResultRow.toPost():PostEntity{
|
||||
fun ResultRow.toPost(): PostEntity {
|
||||
return PostEntity(
|
||||
id = this[Posts.id],
|
||||
userId = this[Posts.userId],
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.jetbrains.exposed.dao.id.LongIdTable
|
|||
object UsersFollowers : LongIdTable("users_followers") {
|
||||
val userId = long("user_id").references(Users.id).index()
|
||||
val followerId = long("follower_id").references(Users.id)
|
||||
|
||||
init {
|
||||
uniqueIndex(userId, followerId)
|
||||
}
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
package dev.usbharu.hideout.domain.model.ap
|
||||
|
||||
open class Accept : Object {
|
||||
public var `object`: Object? = null
|
||||
public var actor:String? = null
|
||||
var `object`: Object? = null
|
||||
var actor: String? = null
|
||||
|
||||
protected constructor() : super()
|
||||
constructor(
|
||||
type: List<String> = emptyList(),
|
||||
name: String,
|
||||
`object`: Object?,
|
||||
actor: String?
|
||||
) : super(add(type,"Accept"), name) {
|
||||
) : super(add(type, "Accept"), name) {
|
||||
this.`object` = `object`
|
||||
this.actor = actor
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package dev.usbharu.hideout.domain.model.ap
|
||||
|
||||
open class Create : Object {
|
||||
var `object` : Object? = null
|
||||
var `object`: Object? = null
|
||||
|
||||
protected constructor() : super()
|
||||
constructor(type: List<String> = emptyList(), name: String, `object`: Object?) : super(add(type,"Create"), name) {
|
||||
constructor(type: List<String> = emptyList(), name: String, `object`: Object?) : super(add(type, "Create"), name) {
|
||||
this.`object` = `object`
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
package dev.usbharu.hideout.domain.model.ap
|
||||
|
||||
open class Follow : Object {
|
||||
public var `object`:String? = null
|
||||
public var actor:String? = null
|
||||
var `object`: String? = null
|
||||
var actor: String? = null
|
||||
|
||||
protected constructor() : super()
|
||||
constructor(
|
||||
type: List<String> = emptyList(),
|
||||
name: String,
|
||||
`object`: String?,
|
||||
actor: String?
|
||||
) : super(add(type,"Follow"), name) {
|
||||
) : super(add(type, "Follow"), name) {
|
||||
this.`object` = `object`
|
||||
this.actor = actor
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ open class Image : Object {
|
|||
|
||||
protected constructor() : super()
|
||||
constructor(type: List<String> = emptyList(), name: String, mediaType: String?, url: String?) : super(
|
||||
add(type,"Image"),
|
||||
add(type, "Image"),
|
||||
name
|
||||
) {
|
||||
this.mediaType = mediaType
|
||||
|
|
|
@ -16,10 +16,10 @@ open class JsonLd {
|
|||
@JsonProperty("@context")
|
||||
@JsonDeserialize(contentUsing = ContextDeserializer::class)
|
||||
@JsonSerialize(using = ContextSerializer::class)
|
||||
var context:List<String> = emptyList()
|
||||
var context: List<String> = emptyList()
|
||||
|
||||
@JsonCreator
|
||||
constructor(context:List<String>){
|
||||
constructor(context: List<String>) {
|
||||
this.context = context
|
||||
}
|
||||
|
||||
|
@ -43,9 +43,12 @@ open class JsonLd {
|
|||
|
||||
}
|
||||
|
||||
public class ContextDeserializer : JsonDeserializer<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 ""
|
||||
class ContextDeserializer : JsonDeserializer<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 ""
|
||||
if (readTree.isObject) {
|
||||
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?) {
|
||||
if (value.isNullOrEmpty()) {
|
||||
gen?.writeNull()
|
||||
return
|
||||
}
|
||||
if (value?.size == 1) {
|
||||
if (value.size == 1) {
|
||||
gen?.writeString(value[0])
|
||||
} else {
|
||||
gen?.writeStartArray()
|
||||
value?.forEach {
|
||||
value.forEach {
|
||||
gen?.writeString(it)
|
||||
}
|
||||
gen?.writeEndArray()
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package dev.usbharu.hideout.domain.model.ap
|
||||
|
||||
open class Key : Object {
|
||||
var id:String? = null
|
||||
var owner:String? = null
|
||||
var publicKeyPem:String? = null
|
||||
var id: String? = null
|
||||
var owner: String? = null
|
||||
var publicKeyPem: String? = null
|
||||
|
||||
protected constructor() : super()
|
||||
constructor(
|
||||
type: List<String>,
|
||||
|
@ -11,7 +12,7 @@ open class Key : Object {
|
|||
id: String?,
|
||||
owner: String?,
|
||||
publicKeyPem: String?
|
||||
) : super(add(type,"Key"), name) {
|
||||
) : super(add(type, "Key"), name) {
|
||||
this.id = id
|
||||
this.owner = owner
|
||||
this.publicKeyPem = publicKeyPem
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package dev.usbharu.hideout.domain.model.ap
|
||||
|
||||
open class Note : Object {
|
||||
var id:String? = null
|
||||
var attributedTo:String? = null
|
||||
var content:String? = null
|
||||
var published:String? = null
|
||||
var to:List<String> = emptyList()
|
||||
var id: String? = null
|
||||
var attributedTo: String? = null
|
||||
var content: String? = null
|
||||
var published: String? = null
|
||||
var to: List<String> = emptyList()
|
||||
|
||||
protected constructor() : super()
|
||||
constructor(
|
||||
type: List<String> = emptyList(),
|
||||
|
@ -15,7 +16,7 @@ open class Note : Object {
|
|||
content: String?,
|
||||
published: String?,
|
||||
to: List<String> = emptyList()
|
||||
) : super(add(type,"Note"), name) {
|
||||
) : super(add(type, "Note"), name) {
|
||||
this.id = id
|
||||
this.attributedTo = attributedTo
|
||||
this.content = content
|
||||
|
|
|
@ -18,7 +18,7 @@ open class Object : JsonLd {
|
|||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
protected fun add(list:List<String>,type:String):List<String> {
|
||||
protected fun add(list: List<String>, type: String): List<String> {
|
||||
val toMutableList = list.toMutableList()
|
||||
toMutableList.add(type)
|
||||
return toMutableList.distinct()
|
||||
|
@ -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?) {
|
||||
println(value)
|
||||
if (value?.size == 1) {
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
package dev.usbharu.hideout.domain.model.ap
|
||||
|
||||
open class Person : Object {
|
||||
private var id:String? = null
|
||||
var preferredUsername:String? = null
|
||||
var summary:String? = null
|
||||
var inbox:String? = null
|
||||
var outbox:String? = null
|
||||
private var url:String? = null
|
||||
private var id: String? = null
|
||||
var preferredUsername: String? = null
|
||||
var summary: String? = null
|
||||
var inbox: String? = null
|
||||
var outbox: String? = null
|
||||
private var url: String? = null
|
||||
private var icon: Image? = null
|
||||
var publicKey: Key? = null
|
||||
|
||||
protected constructor() : super()
|
||||
constructor(
|
||||
type: List<String> = emptyList(),
|
||||
|
@ -21,7 +22,7 @@ open class Person : Object {
|
|||
url: String?,
|
||||
icon: Image?,
|
||||
publicKey: Key?
|
||||
) : super(add(type,"Person"), name) {
|
||||
) : super(add(type, "Person"), name) {
|
||||
this.id = id
|
||||
this.preferredUsername = preferredUsername
|
||||
this.summary = summary
|
||||
|
@ -29,7 +30,7 @@ open class Person : Object {
|
|||
this.outbox = outbox
|
||||
this.url = url
|
||||
this.icon = icon
|
||||
this.publicKey = publicKey
|
||||
this.publicKey = publicKey
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package dev.usbharu.hideout.domain.model.api
|
||||
|
||||
data class StatusForPost(
|
||||
val status:String,
|
||||
val userId:Long
|
||||
val status: String,
|
||||
val userId: Long
|
||||
)
|
||||
|
|
|
@ -4,13 +4,13 @@ import kjob.core.Job
|
|||
|
||||
sealed class HideoutJob(name: String = "") : Job(name)
|
||||
|
||||
object ReceiveFollowJob : HideoutJob("ReceiveFollowJob"){
|
||||
object ReceiveFollowJob : HideoutJob("ReceiveFollowJob") {
|
||||
val actor = string("actor")
|
||||
val follow = string("follow")
|
||||
val targetActor = string("targetActor")
|
||||
}
|
||||
|
||||
object DeliverPostJob : HideoutJob("DeliverPostJob"){
|
||||
object DeliverPostJob : HideoutJob("DeliverPostJob") {
|
||||
val post = string("post")
|
||||
val actor = string("actor")
|
||||
val inbox = string("inbox")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package dev.usbharu.hideout.domain.model.wellknown
|
||||
|
||||
data class WebFinger(val subject:String,val links:List<Link>){
|
||||
data class Link(val rel:String,val type:String,val href:String)
|
||||
data class WebFinger(val subject: String, val links: List<Link>) {
|
||||
data class Link(val rel: String, val type: String, val href: String)
|
||||
}
|
||||
|
|
|
@ -63,8 +63,8 @@ val httpSignaturePlugin = createClientPlugin("HttpSign", ::HttpSignaturePluginCo
|
|||
println("Digest !!")
|
||||
// UserAuthService.sha256.reset()
|
||||
val digest =
|
||||
Base64.getEncoder().encodeToString(UserAuthService.sha256.digest(body.toByteArray(Charsets.UTF_8)))
|
||||
request.headers.append("Digest", "sha-256="+digest)
|
||||
Base64.getEncoder().encodeToString(UserAuthService.sha256.digest(body.toByteArray(Charsets.UTF_8)))
|
||||
request.headers.append("Digest", "sha-256=" + digest)
|
||||
}
|
||||
|
||||
if (request.headers.contains("Signature")) {
|
||||
|
@ -126,7 +126,7 @@ val httpSignaturePlugin = createClientPlugin("HttpSign", ::HttpSignaturePluginCo
|
|||
|
||||
override fun addHeader(name: String?, value: String?) {
|
||||
val split = value?.split("=").orEmpty()
|
||||
name?.let { request.header(it, split.get(0)+"=\""+split.get(1).trim('"')+"\"") }
|
||||
name?.let { request.header(it, split.get(0) + "=\"" + split.get(1).trim('"') + "\"") }
|
||||
}
|
||||
|
||||
override fun method(): String {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package dev.usbharu.hideout.plugins
|
||||
|
||||
import io.ktor.http.*
|
||||
import io.ktor.server.application.*
|
||||
import io.ktor.server.plugins.cors.routing.*
|
||||
import io.ktor.server.plugins.defaultheaders.*
|
||||
import io.ktor.server.plugins.forwardedheaders.*
|
||||
import io.ktor.server.application.*
|
||||
|
||||
fun Application.configureHTTP() {
|
||||
install(CORS) {
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
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.plugins.callloging.*
|
||||
import org.slf4j.event.Level
|
||||
|
||||
fun Application.configureMonitoring() {
|
||||
install(CallLogging) {
|
||||
|
|
|
@ -25,7 +25,7 @@ fun Application.configureRouting(
|
|||
routing {
|
||||
inbox(httpSignatureVerifyService, activityPubService)
|
||||
outbox()
|
||||
usersAP(activityPubUserService,userService)
|
||||
usersAP(activityPubUserService, userService)
|
||||
webfinger(userService)
|
||||
|
||||
route("/api/v1") {
|
||||
|
|
|
@ -3,8 +3,6 @@ package dev.usbharu.hideout.plugins
|
|||
import dev.usbharu.hideout.service.IUserAuthService
|
||||
import io.ktor.server.application.*
|
||||
import io.ktor.server.auth.*
|
||||
import io.ktor.server.sessions.*
|
||||
import kotlin.collections.set
|
||||
|
||||
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.Nulls
|
||||
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.server.application.*
|
||||
import io.ktor.server.plugins.contentnegotiation.*
|
||||
import io.ktor.server.response.*
|
||||
import io.ktor.server.routing.*
|
||||
|
||||
fun Application.configureSerialization() {
|
||||
install(ContentNegotiation) {
|
||||
|
|
|
@ -33,7 +33,7 @@ class ActivityPubServiceImpl(
|
|||
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) {
|
||||
ActivityType.Accept -> TODO()
|
||||
ActivityType.Add -> TODO()
|
||||
|
|
|
@ -10,7 +10,7 @@ import tech.barbero.http.message.signing.SignatureHeaderVerifier
|
|||
class HttpSignatureVerifyServiceImpl(private val userAuthService: IUserRepository) : HttpSignatureVerifyService {
|
||||
override fun verify(headers: Headers): Boolean {
|
||||
val build = SignatureHeaderVerifier.builder().keyMap(KtorKeyMap(userAuthService)).build()
|
||||
return true;
|
||||
return true
|
||||
build.verify(object : HttpMessage {
|
||||
override fun headerValues(name: String?): MutableList<String> {
|
||||
return name?.let { headers.getAll(it) }?.toMutableList() ?: mutableListOf()
|
||||
|
|
|
@ -30,6 +30,10 @@ object HttpUtil {
|
|||
get() = ContentType("application", "activity+json")
|
||||
|
||||
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
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.jetbrains.exposed.dao.id.LongIdTable
|
|||
import org.jetbrains.exposed.sql.*
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||
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.transactions.experimental.newSuspendedTransaction
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {Component} from "solid-js";
|
||||
|
||||
export const App:Component = () => {
|
||||
export const App: Component = () => {
|
||||
return (<p>aaa</p>)
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<title>Solid App</title>
|
||||
<meta charset="utf-8"/>
|
||||
<meta content="width=device-width, initial-scale=1" name="viewport"/>
|
||||
<meta content="#000000" name="theme-color"/>
|
||||
<title>Solid App</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
|
|
Loading…
Reference in New Issue