mirror of https://github.com/usbharu/Hideout.git
style: スタイルを修正
This commit is contained in:
parent
0eb60669f5
commit
e34ef3b6f8
src/main/kotlin/dev/usbharu/hideout
domain/model/ap
repository
service
|
@ -5,16 +5,19 @@ open class Emoji : Object {
|
|||
var icon: Image? = null
|
||||
|
||||
protected constructor() : super()
|
||||
constructor(type: List<String>,
|
||||
constructor(
|
||||
type: List<String>,
|
||||
name: String?,
|
||||
actor: String?,
|
||||
id: String?,
|
||||
updated: String?,
|
||||
icon: Image?) : super(
|
||||
icon: Image?
|
||||
) : super(
|
||||
type = add(type, "Emoji"),
|
||||
name = name,
|
||||
actor = actor,
|
||||
id = id) {
|
||||
id = id
|
||||
) {
|
||||
this.updated = updated
|
||||
this.icon = icon
|
||||
}
|
||||
|
@ -36,6 +39,4 @@ open class Emoji : Object {
|
|||
}
|
||||
|
||||
override fun toString(): String = "Emoji(updated=$updated, icon=$icon) ${super.toString()}"
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,8 @@ open class Like : Object {
|
|||
var tag: List<Object> = emptyList()
|
||||
|
||||
protected constructor() : super()
|
||||
constructor(type: List<String>,
|
||||
constructor(
|
||||
type: List<String>,
|
||||
name: String?,
|
||||
actor: String?,
|
||||
id: String?,
|
||||
|
@ -21,7 +22,8 @@ open class Like : Object {
|
|||
type = add(type, "Like"),
|
||||
name = name,
|
||||
actor = actor,
|
||||
id = id) {
|
||||
id = id
|
||||
) {
|
||||
this.`object` = `object`
|
||||
this.content = content
|
||||
this.tag = tag
|
||||
|
@ -46,6 +48,4 @@ open class Like : Object {
|
|||
}
|
||||
|
||||
override fun toString(): String = "Like(`object`=$`object`, content=$content, tag=$tag) ${super.toString()}"
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,10 @@ import org.jetbrains.exposed.sql.transactions.transaction
|
|||
import org.koin.core.annotation.Single
|
||||
|
||||
@Single
|
||||
class ReactionRepositoryImpl(private val database: Database, private val idGenerateService: IdGenerateService) : ReactionRepository {
|
||||
class ReactionRepositoryImpl(
|
||||
private val database: Database,
|
||||
private val idGenerateService: IdGenerateService
|
||||
) : ReactionRepository {
|
||||
|
||||
init {
|
||||
transaction(database) {
|
||||
|
@ -19,7 +22,6 @@ class ReactionRepositoryImpl(private val database: Database, private val idGener
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Suppress("InjectDispatcher")
|
||||
suspend fun <T> query(block: suspend () -> T): T =
|
||||
newSuspendedTransaction(Dispatchers.IO) { block() }
|
||||
|
@ -40,7 +42,6 @@ class ReactionRepositoryImpl(private val database: Database, private val idGener
|
|||
it[emojiId] = reaction.emojiId
|
||||
it[postId] = reaction.postId
|
||||
it[userId] = reaction.userId
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +50,11 @@ class ReactionRepositoryImpl(private val database: Database, private val idGener
|
|||
|
||||
override suspend fun reactionAlreadyExist(postId: Long, userId: Long, emojiId: Long): Boolean {
|
||||
return query {
|
||||
Reactions.select { Reactions.postId.eq(postId).and(Reactions.userId.eq(userId)).and(Reactions.emojiId.eq(emojiId)) }.empty().not()
|
||||
Reactions.select {
|
||||
Reactions.postId.eq(postId).and(Reactions.userId.eq(userId)).and(
|
||||
Reactions.emojiId.eq(emojiId)
|
||||
)
|
||||
}.empty().not()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,13 +11,14 @@ import dev.usbharu.hideout.service.user.IUserService
|
|||
import io.ktor.http.*
|
||||
import org.koin.core.annotation.Single
|
||||
|
||||
|
||||
@Single
|
||||
class ActivityPubLikeServiceImpl(private val reactionService: IReactionService,
|
||||
class ActivityPubLikeServiceImpl(
|
||||
private val reactionService: IReactionService,
|
||||
private val activityPubUserService: ActivityPubUserService,
|
||||
private val userService: IUserService,
|
||||
private val postService: IPostRepository,
|
||||
private val activityPubNoteService: ActivityPubNoteService) : ActivityPubLikeService {
|
||||
private val activityPubNoteService: ActivityPubNoteService
|
||||
) : ActivityPubLikeService {
|
||||
override suspend fun receiveLike(like: Like): ActivityPubResponse {
|
||||
val actor = like.actor ?: throw IllegalActivityPubObjectException("actor is null")
|
||||
val content = like.content ?: throw IllegalActivityPubObjectException("content is null")
|
||||
|
@ -25,8 +26,10 @@ class ActivityPubLikeServiceImpl(private val reactionService: IReactionService,
|
|||
val person = activityPubUserService.fetchPerson(actor)
|
||||
activityPubNoteService.fetchNote(like.`object`!!)
|
||||
|
||||
val user = userService.findByUrl(person.url
|
||||
?: throw IllegalActivityPubObjectException("actor is not found"))
|
||||
val user = userService.findByUrl(
|
||||
person.url
|
||||
?: throw IllegalActivityPubObjectException("actor is not found")
|
||||
)
|
||||
|
||||
val post = postService.findByUrl(like.`object`!!)
|
||||
?: throw PostNotFoundException("${like.`object`} was not found")
|
||||
|
|
|
@ -75,7 +75,8 @@ class ActivityPubNoteServiceImpl(
|
|||
return postToNote(post)
|
||||
}
|
||||
val response = httpClient.getAp(
|
||||
url, targetActor?.let { "$targetActor#pubkey" }
|
||||
url,
|
||||
targetActor?.let { "$targetActor#pubkey" }
|
||||
)
|
||||
val note = Config.configData.objectMapper.readValue<Note>(response.bodyAsText())
|
||||
return note(note, targetActor, url)
|
||||
|
|
|
@ -3,6 +3,7 @@ package dev.usbharu.hideout.service.api
|
|||
import dev.usbharu.hideout.domain.model.hideout.entity.Post
|
||||
import java.time.Instant
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
interface IPostApiService {
|
||||
suspend fun createPost(postForm: dev.usbharu.hideout.domain.model.hideout.form.Post, userId: Long): Post
|
||||
suspend fun getById(id: Long, userId: Long?): Post
|
||||
|
|
|
@ -56,15 +56,15 @@ class PostApiServiceImpl(
|
|||
return if (idOrNull == null) {
|
||||
val acct = AcctUtil.parse(nameOrId)
|
||||
postRepository.findByUserNameAndDomain(
|
||||
acct.username,
|
||||
acct.domain
|
||||
username = acct.username,
|
||||
s = acct.domain
|
||||
?: Config.configData.domain,
|
||||
since,
|
||||
until,
|
||||
minId,
|
||||
maxId,
|
||||
limit,
|
||||
userId
|
||||
since = since,
|
||||
until = until,
|
||||
minId = minId,
|
||||
maxId = maxId,
|
||||
limit = limit,
|
||||
userId = userId
|
||||
)
|
||||
} else {
|
||||
postRepository.findByUserId(idOrNull, since, until, minId, maxId, limit, userId)
|
||||
|
|
Loading…
Reference in New Issue