mirror of https://github.com/usbharu/Hideout.git
style: fix lint
This commit is contained in:
parent
2105c47b03
commit
3323229ef3
|
@ -49,9 +49,9 @@ constructor(
|
|||
@Suppress("CyclomaticComplexMethod")
|
||||
override fun hashCode(): Int {
|
||||
var result = super.hashCode()
|
||||
result = 31 * result + name.hashCode()
|
||||
result = 31 * result + (name?.hashCode() ?: 0)
|
||||
result = 31 * result + id.hashCode()
|
||||
result = 31 * result + (preferredUsername?.hashCode() ?: 0)
|
||||
result = 31 * result + preferredUsername.hashCode()
|
||||
result = 31 * result + (summary?.hashCode() ?: 0)
|
||||
result = 31 * result + inbox.hashCode()
|
||||
result = 31 * result + outbox.hashCode()
|
||||
|
@ -61,15 +61,15 @@ constructor(
|
|||
result = 31 * result + endpoints.hashCode()
|
||||
result = 31 * result + (followers?.hashCode() ?: 0)
|
||||
result = 31 * result + (following?.hashCode() ?: 0)
|
||||
result = 31 * result + manuallyApprovesFollowers.hashCode()
|
||||
result = 31 * result + (manuallyApprovesFollowers?.hashCode() ?: 0)
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "Person(" +
|
||||
"name='$name', " +
|
||||
"name=$name, " +
|
||||
"id='$id', " +
|
||||
"preferredUsername=$preferredUsername, " +
|
||||
"preferredUsername='$preferredUsername', " +
|
||||
"summary=$summary, " +
|
||||
"inbox='$inbox', " +
|
||||
"outbox='$outbox', " +
|
||||
|
|
|
@ -26,8 +26,10 @@ class NoteQueryServiceImpl(private val postRepository: PostRepository, private v
|
|||
.leftJoin(Media)
|
||||
.select { Posts.id eq id }
|
||||
.let {
|
||||
(it.toNote() ?: return null) to (postQueryMapper.map(it)
|
||||
.singleOrNull() ?: return null)
|
||||
(it.toNote() ?: return null) to (
|
||||
postQueryMapper.map(it)
|
||||
.singleOrNull() ?: return null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,8 +40,10 @@ class NoteQueryServiceImpl(private val postRepository: PostRepository, private v
|
|||
.leftJoin(Media)
|
||||
.select { Posts.apId eq apId }
|
||||
.let {
|
||||
(it.toNote() ?: return null) to (postQueryMapper.map(it)
|
||||
.singleOrNull() ?: return null)
|
||||
(it.toNote() ?: return null) to (
|
||||
postQueryMapper.map(it)
|
||||
.singleOrNull() ?: return null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,14 +36,12 @@ class APDeleteProcessor(
|
|||
val actor = actorRepository.findByUrl(deleteId)
|
||||
actor?.let { userService.deleteRemoteActor(it.id) }
|
||||
|
||||
|
||||
val post = postRepository.findByApId(deleteId)
|
||||
if (post == null) {
|
||||
logger.warn("FAILED Delete id: {} is not found.", deleteId)
|
||||
return
|
||||
}
|
||||
postService.deleteRemote(post)
|
||||
|
||||
}
|
||||
|
||||
override fun isSupported(activityType: ActivityType): Boolean = activityType == ActivityType.Delete
|
||||
|
|
|
@ -42,7 +42,6 @@ class APLikeProcessor(
|
|||
logger.trace("", e)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun isSupported(activityType: ActivityType): Boolean = activityType == ActivityType.Like
|
||||
|
|
|
@ -24,70 +24,32 @@ class APUndoProcessor(
|
|||
private val reactionService: ReactionService,
|
||||
private val actorRepository: ActorRepository,
|
||||
private val postRepository: PostRepository
|
||||
) :
|
||||
AbstractActivityPubProcessor<Undo>(transaction) {
|
||||
) : AbstractActivityPubProcessor<Undo>(transaction) {
|
||||
override suspend fun internalProcess(activity: ActivityPubProcessContext<Undo>) {
|
||||
val undo = activity.activity
|
||||
|
||||
val type =
|
||||
undo.apObject.type
|
||||
.firstOrNull { it == "Block" || it == "Follow" || it == "Like" || it == "Announce" || it == "Accept" }
|
||||
?: return
|
||||
val type = undo.apObject.type.firstOrNull {
|
||||
it == "Block" || it == "Follow" || it == "Like" || it == "Announce" || it == "Accept"
|
||||
} ?: return
|
||||
|
||||
when (type) {
|
||||
"Follow" -> {
|
||||
val follow = undo.apObject as Follow
|
||||
|
||||
val follower = apUserService.fetchPersonWithEntity(undo.actor, follow.apObject).second
|
||||
val target =
|
||||
actorRepository.findByUrl(follow.apObject) ?: throw UserNotFoundException.withUrl(follow.apObject)
|
||||
|
||||
relationshipService.unfollow(follower.id, target.id)
|
||||
follow(undo)
|
||||
return
|
||||
}
|
||||
|
||||
"Block" -> {
|
||||
val block = undo.apObject as Block
|
||||
|
||||
val blocker = apUserService.fetchPersonWithEntity(undo.actor, block.apObject).second
|
||||
val target =
|
||||
actorRepository.findByUrl(block.apObject) ?: throw UserNotFoundException.withUrl(block.apObject)
|
||||
|
||||
relationshipService.unblock(blocker.id, target.id)
|
||||
block(undo)
|
||||
return
|
||||
}
|
||||
|
||||
"Accept" -> {
|
||||
val accept = undo.apObject as Accept
|
||||
|
||||
val acceptObject = if (accept.apObject is ObjectValue) {
|
||||
accept.apObject.`object`
|
||||
} else if (accept.apObject is Follow) {
|
||||
accept.apObject.apObject
|
||||
} else {
|
||||
logger.warn("FAILED Unsupported type. Undo Accept {}", accept.apObject.type)
|
||||
return
|
||||
}
|
||||
|
||||
val accepter = apUserService.fetchPersonWithEntity(undo.actor, acceptObject).second
|
||||
val target =
|
||||
actorRepository.findByUrl(acceptObject) ?: throw UserNotFoundException.withUrl(acceptObject)
|
||||
|
||||
relationshipService.rejectFollowRequest(accepter.id, target.id)
|
||||
accept(undo)
|
||||
return
|
||||
}
|
||||
|
||||
"Like" -> {
|
||||
val like = undo.apObject as Like
|
||||
|
||||
val post =
|
||||
postRepository.findByUrl(like.apObject) ?: throw PostNotFoundException.withUrl(like.apObject)
|
||||
|
||||
val signer =
|
||||
actorRepository.findById(post.actorId) ?: throw LocalUserNotFoundException.withId(post.actorId)
|
||||
val actor = apUserService.fetchPersonWithEntity(like.actor, signer.url).second
|
||||
|
||||
reactionService.receiveRemoveReaction(actor.id, post.id)
|
||||
like(undo)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -96,6 +58,57 @@ class APUndoProcessor(
|
|||
TODO()
|
||||
}
|
||||
|
||||
private suspend fun accept(undo: Undo) {
|
||||
val accept = undo.apObject as Accept
|
||||
|
||||
val acceptObject = if (accept.apObject is ObjectValue) {
|
||||
accept.apObject.`object`
|
||||
} else if (accept.apObject is Follow) {
|
||||
accept.apObject.apObject
|
||||
} else {
|
||||
logger.warn("FAILED Unsupported type. Undo Accept {}", accept.apObject.type)
|
||||
return
|
||||
}
|
||||
|
||||
val accepter = apUserService.fetchPersonWithEntity(undo.actor, acceptObject).second
|
||||
val target = actorRepository.findByUrl(acceptObject) ?: throw UserNotFoundException.withUrl(acceptObject)
|
||||
|
||||
relationshipService.rejectFollowRequest(accepter.id, target.id)
|
||||
return
|
||||
}
|
||||
|
||||
private suspend fun like(undo: Undo) {
|
||||
val like = undo.apObject as Like
|
||||
|
||||
val post = postRepository.findByUrl(like.apObject) ?: throw PostNotFoundException.withUrl(like.apObject)
|
||||
|
||||
val signer = actorRepository.findById(post.actorId) ?: throw LocalUserNotFoundException.withId(post.actorId)
|
||||
val actor = apUserService.fetchPersonWithEntity(like.actor, signer.url).second
|
||||
|
||||
reactionService.receiveRemoveReaction(actor.id, post.id)
|
||||
return
|
||||
}
|
||||
|
||||
private suspend fun block(undo: Undo) {
|
||||
val block = undo.apObject as Block
|
||||
|
||||
val blocker = apUserService.fetchPersonWithEntity(undo.actor, block.apObject).second
|
||||
val target = actorRepository.findByUrl(block.apObject) ?: throw UserNotFoundException.withUrl(block.apObject)
|
||||
|
||||
relationshipService.unblock(blocker.id, target.id)
|
||||
return
|
||||
}
|
||||
|
||||
private suspend fun follow(undo: Undo) {
|
||||
val follow = undo.apObject as Follow
|
||||
|
||||
val follower = apUserService.fetchPersonWithEntity(undo.actor, follow.apObject).second
|
||||
val target = actorRepository.findByUrl(follow.apObject) ?: throw UserNotFoundException.withUrl(follow.apObject)
|
||||
|
||||
relationshipService.unfollow(follower.id, target.id)
|
||||
return
|
||||
}
|
||||
|
||||
override fun isSupported(activityType: ActivityType): Boolean = activityType == ActivityType.Undo
|
||||
|
||||
override fun type(): Class<Undo> = Undo::class.java
|
||||
|
|
|
@ -91,8 +91,7 @@ class InboxJobProcessor(
|
|||
|
||||
logger.debug("Has signature? {}", signature != null)
|
||||
|
||||
|
||||
//todo 不正なactorを取得してしまわないようにする
|
||||
// todo 不正なactorを取得してしまわないようにする
|
||||
val verify =
|
||||
signature?.let {
|
||||
verifyHttpSignature(
|
||||
|
|
|
@ -53,7 +53,9 @@ class APNoteServiceImpl(
|
|||
apResourceResolveService.resolve<Note>(url, null as Long?)
|
||||
} catch (e: ClientRequestException) {
|
||||
logger.warn(
|
||||
"FAILED Failed to retrieve ActivityPub resource. HTTP Status Code: {} url: {}", e.response.status, url
|
||||
"FAILED Failed to retrieve ActivityPub resource. HTTP Status Code: {} url: {}",
|
||||
e.response.status,
|
||||
url
|
||||
)
|
||||
throw FailedToGetActivityPubResourceException("Could not retrieve $url.", e)
|
||||
}
|
||||
|
@ -63,14 +65,15 @@ class APNoteServiceImpl(
|
|||
}
|
||||
|
||||
private suspend fun saveIfMissing(
|
||||
note: Note, targetActor: String?, url: String
|
||||
): Pair<Note, Post> {
|
||||
return noteQueryService.findByApid(note.id) ?: saveNote(note, targetActor, url)
|
||||
}
|
||||
note: Note,
|
||||
targetActor: String?,
|
||||
url: String
|
||||
): Pair<Note, Post> = noteQueryService.findByApid(note.id) ?: saveNote(note, targetActor, url)
|
||||
|
||||
private suspend fun saveNote(note: Note, targetActor: String?, url: String): Pair<Note, Post> {
|
||||
val person = apUserService.fetchPersonWithEntity(
|
||||
note.attributedTo, targetActor
|
||||
note.attributedTo,
|
||||
targetActor
|
||||
)
|
||||
|
||||
val post = postRepository.findByApId(note.id)
|
||||
|
@ -101,7 +104,10 @@ class APNoteServiceImpl(
|
|||
val mediaList = note.attachment.map {
|
||||
mediaService.uploadRemoteMedia(
|
||||
RemoteMedia(
|
||||
it.name, it.url, it.mediaType, description = it.name
|
||||
it.name,
|
||||
it.url,
|
||||
it.mediaType,
|
||||
description = it.name
|
||||
)
|
||||
)
|
||||
}.map { it.id }
|
||||
|
|
|
@ -12,7 +12,6 @@ import dev.usbharu.hideout.core.domain.model.actor.Actor
|
|||
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||
import dev.usbharu.hideout.core.service.user.RemoteUserCreateDto
|
||||
import dev.usbharu.hideout.core.service.user.UserService
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
interface APUserService {
|
||||
|
@ -83,7 +82,6 @@ class APUserServiceImpl(
|
|||
return entityToPerson(userEntity, userEntity.url) to userEntity
|
||||
}
|
||||
|
||||
|
||||
val person = apResourceResolveService.resolve<Person>(url, null as Long?)
|
||||
|
||||
val id = person.id
|
||||
|
@ -111,7 +109,6 @@ class APUserServiceImpl(
|
|||
locked = person.manuallyApprovesFollowers
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
private fun entityToPerson(
|
||||
|
@ -141,8 +138,4 @@ class APUserServiceImpl(
|
|||
following = actorEntity.following,
|
||||
manuallyApprovesFollowers = actorEntity.locked
|
||||
)
|
||||
|
||||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(APUserServiceImpl::class.java)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ open class UserNotFoundException : NotFoundException {
|
|||
@Serial
|
||||
private const val serialVersionUID: Long = 3219433672235626200L
|
||||
|
||||
|
||||
fun withName(string: String, throwable: Throwable? = null): UserNotFoundException =
|
||||
UserNotFoundException("name: $string was not found.", throwable)
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ class LocalUserNotFoundException : UserNotFoundException {
|
|||
writableStackTrace
|
||||
)
|
||||
|
||||
|
||||
companion object {
|
||||
@Serial
|
||||
private const val serialVersionUID: Long = -4742548128672528145L
|
||||
|
@ -29,5 +28,4 @@ class LocalUserNotFoundException : UserNotFoundException {
|
|||
fun withUrl(url: String, throwable: Throwable? = null): LocalUserNotFoundException =
|
||||
LocalUserNotFoundException("url: $url was not found.", throwable)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@ data class Actor private constructor(
|
|||
postsCount: Int = 0,
|
||||
lastPostDate: Instant? = null
|
||||
): Actor {
|
||||
|
||||
if (id == 0L) {
|
||||
return Actor(
|
||||
id = id,
|
||||
|
|
|
@ -3,6 +3,7 @@ package dev.usbharu.hideout.core.domain.model.actor
|
|||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
@Suppress("TooManyFunctions")
|
||||
interface ActorRepository {
|
||||
suspend fun save(actor: Actor): Actor
|
||||
|
||||
|
|
|
@ -5,5 +5,5 @@ interface InstanceRepository {
|
|||
suspend fun save(instance: Instance): Instance
|
||||
suspend fun findById(id: Long): Instance?
|
||||
suspend fun delete(instance: Instance)
|
||||
suspend fun findByUrl(url:String):Instance?
|
||||
suspend fun findByUrl(url: String): Instance?
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package dev.usbharu.hideout.core.domain.model.reaction
|
|||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
@Suppress("FunctionMaxLength")
|
||||
interface ReactionRepository {
|
||||
suspend fun generateId(): Long
|
||||
suspend fun save(reaction: Reaction): Reaction
|
||||
|
|
|
@ -31,8 +31,9 @@ interface RelationshipRepository {
|
|||
|
||||
suspend fun deleteByActorIdOrTargetActorId(actorId: Long, targetActorId: Long)
|
||||
|
||||
suspend fun findByTargetIdAndFollowing(targetId: Long,following:Boolean):List<Relationship>
|
||||
suspend fun findByTargetIdAndFollowing(targetId: Long, following: Boolean): List<Relationship>
|
||||
|
||||
@Suppress("LongParameterList", "FunctionMaxLength")
|
||||
suspend fun findByTargetIdAndFollowRequestAndIgnoreFollowRequest(
|
||||
maxId: Long?,
|
||||
sinceId: Long?,
|
||||
|
|
|
@ -12,13 +12,11 @@ import org.springframework.stereotype.Service
|
|||
@Service
|
||||
class RelationshipRepositoryImpl : RelationshipRepository, AbstractRepository() {
|
||||
override suspend fun save(relationship: Relationship): Relationship = query {
|
||||
val singleOrNull =
|
||||
Relationships
|
||||
.select {
|
||||
(Relationships.actorId eq relationship.actorId)
|
||||
.and(Relationships.targetActorId eq relationship.targetActorId)
|
||||
}.forUpdate()
|
||||
.singleOrNull()
|
||||
val singleOrNull = Relationships.select {
|
||||
(Relationships.actorId eq relationship.actorId).and(
|
||||
Relationships.targetActorId eq relationship.targetActorId
|
||||
)
|
||||
}.forUpdate().singleOrNull()
|
||||
|
||||
if (singleOrNull == null) {
|
||||
Relationships.insert {
|
||||
|
@ -31,34 +29,33 @@ class RelationshipRepositoryImpl : RelationshipRepository, AbstractRepository()
|
|||
it[ignoreFollowRequestFromTarget] = relationship.ignoreFollowRequestToTarget
|
||||
}
|
||||
} else {
|
||||
Relationships
|
||||
.update({
|
||||
(Relationships.actorId eq relationship.actorId)
|
||||
.and(Relationships.targetActorId eq relationship.targetActorId)
|
||||
}) {
|
||||
it[following] = relationship.following
|
||||
it[blocking] = relationship.blocking
|
||||
it[muting] = relationship.muting
|
||||
it[followRequest] = relationship.followRequest
|
||||
it[ignoreFollowRequestFromTarget] = relationship.ignoreFollowRequestToTarget
|
||||
}
|
||||
Relationships.update({
|
||||
(Relationships.actorId eq relationship.actorId).and(
|
||||
Relationships.targetActorId eq relationship.targetActorId
|
||||
)
|
||||
}) {
|
||||
it[following] = relationship.following
|
||||
it[blocking] = relationship.blocking
|
||||
it[muting] = relationship.muting
|
||||
it[followRequest] = relationship.followRequest
|
||||
it[ignoreFollowRequestFromTarget] = relationship.ignoreFollowRequestToTarget
|
||||
}
|
||||
}
|
||||
return@query relationship
|
||||
}
|
||||
|
||||
override suspend fun delete(relationship: Relationship): Unit = query {
|
||||
Relationships.deleteWhere {
|
||||
(Relationships.actorId eq relationship.actorId)
|
||||
.and(Relationships.targetActorId eq relationship.targetActorId)
|
||||
(Relationships.actorId eq relationship.actorId).and(
|
||||
Relationships.targetActorId eq relationship.targetActorId
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun findByUserIdAndTargetUserId(actorId: Long, targetActorId: Long): Relationship? = query {
|
||||
return@query Relationships.select {
|
||||
(Relationships.actorId eq actorId)
|
||||
.and(Relationships.targetActorId eq targetActorId)
|
||||
}.singleOrNull()
|
||||
?.toRelationships()
|
||||
(Relationships.actorId eq actorId).and(Relationships.targetActorId eq targetActorId)
|
||||
}.singleOrNull()?.toRelationships()
|
||||
}
|
||||
|
||||
override suspend fun deleteByActorIdOrTargetActorId(actorId: Long, targetActorId: Long): Unit = query {
|
||||
|
@ -68,7 +65,8 @@ class RelationshipRepositoryImpl : RelationshipRepository, AbstractRepository()
|
|||
}
|
||||
|
||||
override suspend fun findByTargetIdAndFollowing(targetId: Long, following: Boolean): List<Relationship> = query {
|
||||
return@query Relationships.select { Relationships.targetActorId eq targetId and (Relationships.following eq following) }
|
||||
return@query Relationships
|
||||
.select { Relationships.targetActorId eq targetId and (Relationships.following eq following) }
|
||||
.map { it.toRelationships() }
|
||||
}
|
||||
|
||||
|
@ -81,8 +79,7 @@ class RelationshipRepositoryImpl : RelationshipRepository, AbstractRepository()
|
|||
ignoreFollowRequest: Boolean
|
||||
): List<Relationship> = query {
|
||||
val query = Relationships.select {
|
||||
Relationships.targetActorId.eq(targetId)
|
||||
.and(Relationships.followRequest.eq(followRequest))
|
||||
Relationships.targetActorId.eq(targetId).and(Relationships.followRequest.eq(followRequest))
|
||||
.and(Relationships.ignoreFollowRequestFromTarget.eq(ignoreFollowRequest))
|
||||
}.limit(limit)
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Value
|
|||
import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator
|
||||
import java.sql.SQLException
|
||||
|
||||
@Suppress("VarCouldBeVal")
|
||||
abstract class AbstractRepository {
|
||||
protected abstract val logger: Logger
|
||||
private val sqlErrorCodeSQLExceptionTranslator = SQLErrorCodeSQLExceptionTranslator()
|
||||
|
@ -18,8 +19,8 @@ abstract class AbstractRepository {
|
|||
private var traceQueryCall: Boolean = false
|
||||
|
||||
protected suspend fun <T> query(block: () -> T): T = try {
|
||||
|
||||
if (traceQueryCall) {
|
||||
@Suppress("ThrowingExceptionsWithoutMessageOrCause")
|
||||
logger.trace(
|
||||
"""
|
||||
***** QUERY CALL STACK TRACE *****
|
||||
|
@ -29,11 +30,9 @@ ${Throwable().stackTrace.joinToString("\n")}
|
|||
***** QUERY CALL STACK TRACE *****
|
||||
"""
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
block.invoke()
|
||||
|
||||
} catch (e: SQLException) {
|
||||
if (traceQueryException) {
|
||||
logger.trace("FAILED EXECUTE SQL", e)
|
||||
|
|
|
@ -18,14 +18,12 @@ class ActorRepositoryImpl(
|
|||
private val actorResultRowMapper: ResultRowMapper<Actor>,
|
||||
private val actorQueryMapper: QueryMapper<Actor>
|
||||
) : ActorRepository, AbstractRepository() {
|
||||
|
||||
override val logger: Logger
|
||||
get() = Companion.logger
|
||||
|
||||
override suspend fun save(actor: Actor): Actor = query {
|
||||
|
||||
|
||||
val singleOrNull = Actors.select { Actors.id eq actor.id }.forUpdate().empty()
|
||||
if (singleOrNull) {
|
||||
|
||||
Actors.insert {
|
||||
it[id] = actor.id
|
||||
it[name] = actor.name
|
||||
|
@ -125,9 +123,6 @@ class ActorRepositoryImpl(
|
|||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(ActorRepositoryImpl::class.java)
|
||||
}
|
||||
|
||||
override val logger: Logger
|
||||
get() = Companion.logger
|
||||
}
|
||||
|
||||
object Actors : Table("actors") {
|
||||
|
@ -136,14 +131,16 @@ object Actors : Table("actors") {
|
|||
val domain: Column<String> = varchar("domain", length = 1000)
|
||||
val screenName: Column<String> = varchar("screen_name", length = 300)
|
||||
val description: Column<String> = varchar(
|
||||
"description", length = 10000
|
||||
"description",
|
||||
length = 10000
|
||||
)
|
||||
val inbox: Column<String> = varchar("inbox", length = 1000).uniqueIndex()
|
||||
val outbox: Column<String> = varchar("outbox", length = 1000).uniqueIndex()
|
||||
val url: Column<String> = varchar("url", length = 1000).uniqueIndex()
|
||||
val publicKey: Column<String> = varchar("public_key", length = 10000)
|
||||
val privateKey: Column<String?> = varchar(
|
||||
"private_key", length = 10000
|
||||
"private_key",
|
||||
length = 10000
|
||||
).nullable()
|
||||
val createdAt: Column<Long> = long("created_at")
|
||||
val keyId = varchar("key_id", length = 1000)
|
||||
|
|
|
@ -11,6 +11,9 @@ import org.springframework.stereotype.Repository
|
|||
|
||||
@Repository
|
||||
class DeletedActorRepositoryImpl : DeletedActorRepository, AbstractRepository() {
|
||||
override val logger: Logger
|
||||
get() = Companion.logger
|
||||
|
||||
override suspend fun save(deletedActor: DeletedActor): DeletedActor = query {
|
||||
val singleOrNull = DeletedActors.select { DeletedActors.id eq deletedActor.id }.forUpdate().singleOrNull()
|
||||
|
||||
|
@ -51,9 +54,6 @@ class DeletedActorRepositoryImpl : DeletedActorRepository, AbstractRepository()
|
|||
?.toDeletedActor()
|
||||
}
|
||||
|
||||
override val logger: Logger
|
||||
get() = Companion.logger
|
||||
|
||||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(DeletedActorRepositoryImpl::class.java)
|
||||
}
|
||||
|
|
|
@ -16,6 +16,9 @@ import org.springframework.stereotype.Repository
|
|||
@ConditionalOnProperty("hideout.use-mongodb", havingValue = "false", matchIfMissing = true)
|
||||
class ExposedTimelineRepository(private val idGenerateService: IdGenerateService) : TimelineRepository,
|
||||
AbstractRepository() {
|
||||
override val logger: Logger
|
||||
get() = Companion.logger
|
||||
|
||||
override suspend fun generateId(): Long = idGenerateService.generateId()
|
||||
|
||||
override suspend fun save(timeline: Timeline): Timeline = query {
|
||||
|
@ -82,16 +85,14 @@ class ExposedTimelineRepository(private val idGenerateService: IdGenerateService
|
|||
.map { it.toTimeline() }
|
||||
}
|
||||
|
||||
override val logger: Logger
|
||||
get() = Companion.logger
|
||||
|
||||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(ExposedTimelineRepository::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
fun ResultRow.toTimeline(): Timeline {
|
||||
return Timeline(id = this[Timelines.id],
|
||||
return Timeline(
|
||||
id = this[Timelines.id],
|
||||
userId = this[Timelines.userId],
|
||||
timelineId = this[Timelines.timelineId],
|
||||
postId = this[Timelines.postId],
|
||||
|
@ -103,7 +104,8 @@ fun ResultRow.toTimeline(): Timeline {
|
|||
sensitive = this[Timelines.sensitive],
|
||||
isLocal = this[Timelines.isLocal],
|
||||
isPureRepost = this[Timelines.isPureRepost],
|
||||
mediaIds = this[Timelines.mediaIds].split(",").mapNotNull { it.toLongOrNull() })
|
||||
mediaIds = this[Timelines.mediaIds].split(",").mapNotNull { it.toLongOrNull() }
|
||||
)
|
||||
}
|
||||
|
||||
object Timelines : Table("timelines") {
|
||||
|
|
|
@ -13,6 +13,9 @@ import dev.usbharu.hideout.core.domain.model.instance.Instance as InstanceEntity
|
|||
@Repository
|
||||
class InstanceRepositoryImpl(private val idGenerateService: IdGenerateService) : InstanceRepository,
|
||||
AbstractRepository() {
|
||||
override val logger: Logger
|
||||
get() = Companion.logger
|
||||
|
||||
override suspend fun generateId(): Long = idGenerateService.generateId()
|
||||
|
||||
override suspend fun save(instance: InstanceEntity): InstanceEntity = query {
|
||||
|
@ -62,9 +65,6 @@ class InstanceRepositoryImpl(private val idGenerateService: IdGenerateService) :
|
|||
return@query Instance.select { Instance.url eq url }.singleOrNull()?.toInstance()
|
||||
}
|
||||
|
||||
override val logger: Logger
|
||||
get() = Companion.logger
|
||||
|
||||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(InstanceRepositoryImpl::class.java)
|
||||
}
|
||||
|
|
|
@ -14,6 +14,9 @@ import dev.usbharu.hideout.core.domain.model.media.Media as EntityMedia
|
|||
|
||||
@Repository
|
||||
class MediaRepositoryImpl(private val idGenerateService: IdGenerateService) : MediaRepository, AbstractRepository() {
|
||||
override val logger: Logger
|
||||
get() = Companion.logger
|
||||
|
||||
override suspend fun generateId(): Long = idGenerateService.generateId()
|
||||
|
||||
override suspend fun save(media: EntityMedia): EntityMedia = query {
|
||||
|
@ -65,10 +68,7 @@ class MediaRepositoryImpl(private val idGenerateService: IdGenerateService) : Me
|
|||
override suspend fun findByRemoteUrl(remoteUrl: String): dev.usbharu.hideout.core.domain.model.media.Media? =
|
||||
query {
|
||||
return@query Media.select { Media.remoteUrl eq remoteUrl }.singleOrNull()?.toMedia()
|
||||
}
|
||||
|
||||
override val logger: Logger
|
||||
get() = Companion.logger
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(MediaRepositoryImpl::class.java)
|
||||
|
|
|
@ -15,6 +15,8 @@ class PostRepositoryImpl(
|
|||
private val idGenerateService: IdGenerateService,
|
||||
private val postQueryMapper: QueryMapper<Post>
|
||||
) : PostRepository, AbstractRepository() {
|
||||
override val logger: Logger
|
||||
get() = Companion.logger
|
||||
|
||||
override suspend fun generateId(): Long = idGenerateService.generateId()
|
||||
|
||||
|
@ -97,9 +99,6 @@ class PostRepositoryImpl(
|
|||
Posts.deleteWhere { Posts.id eq id }
|
||||
}
|
||||
|
||||
override val logger: Logger
|
||||
get() = Companion.logger
|
||||
|
||||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(PostRepositoryImpl::class.java)
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ import org.springframework.stereotype.Repository
|
|||
class ReactionRepositoryImpl(
|
||||
private val idGenerateService: IdGenerateService
|
||||
) : ReactionRepository, AbstractRepository() {
|
||||
override val logger: Logger
|
||||
get() = Companion.logger
|
||||
|
||||
override suspend fun generateId(): Long = idGenerateService.generateId()
|
||||
|
||||
|
@ -85,9 +87,6 @@ class ReactionRepositoryImpl(
|
|||
.map { it.toReaction() }
|
||||
}
|
||||
|
||||
override val logger: Logger
|
||||
get() = Companion.logger
|
||||
|
||||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(ReactionRepositoryImpl::class.java)
|
||||
}
|
||||
|
@ -95,7 +94,10 @@ class ReactionRepositoryImpl(
|
|||
|
||||
fun ResultRow.toReaction(): Reaction {
|
||||
return Reaction(
|
||||
this[Reactions.id].value, this[Reactions.emojiId], this[Reactions.postId], this[Reactions.actorId]
|
||||
this[Reactions.id].value,
|
||||
this[Reactions.emojiId],
|
||||
this[Reactions.postId],
|
||||
this[Reactions.actorId]
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,9 @@ import org.springframework.stereotype.Repository
|
|||
|
||||
@Repository
|
||||
class UserDetailRepositoryImpl : UserDetailRepository, AbstractRepository() {
|
||||
override val logger: Logger
|
||||
get() = Companion.logger
|
||||
|
||||
override suspend fun save(userDetail: UserDetail): UserDetail = query {
|
||||
val singleOrNull = UserDetails.select { UserDetails.actorId eq userDetail.actorId }.forUpdate().singleOrNull()
|
||||
if (singleOrNull == null) {
|
||||
|
@ -48,9 +51,6 @@ class UserDetailRepositoryImpl : UserDetailRepository, AbstractRepository() {
|
|||
}
|
||||
}
|
||||
|
||||
override val logger: Logger
|
||||
get() = Companion.logger
|
||||
|
||||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(UserDetailRepositoryImpl::class.java)
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import java.net.URL
|
|||
|
||||
@JsonDeserialize(using = HttpRequestDeserializer::class)
|
||||
@JsonSubTypes
|
||||
@Suppress("UnnecessaryAbstractClass")
|
||||
abstract class HttpRequestMixIn
|
||||
|
||||
class HttpRequestDeserializer : JsonDeserializer<HttpRequest>() {
|
||||
|
|
|
@ -41,8 +41,8 @@ class KJobMongoJobQueueWorkerService(
|
|||
}
|
||||
for (jobProcessor in jobQueueProcessorList) {
|
||||
kjob.register(jobProcessor.job()) {
|
||||
|
||||
execute {
|
||||
@Suppress("TooGenericExceptionCaught")
|
||||
try {
|
||||
MDC.put("x-job-id", this.jobId)
|
||||
val param = it.convertUnsafe(props)
|
||||
|
|
|
@ -6,5 +6,6 @@ import org.springframework.web.bind.annotation.GetMapping
|
|||
@Controller
|
||||
class AuthController {
|
||||
@GetMapping("/auth/sign_up")
|
||||
@Suppress("FunctionOnlyReturningConstant")
|
||||
fun signUp(): String = "sign_up"
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ class LocalFileSystemMediaDataStore(
|
|||
val fileSavePathString = fileSavePath.toAbsolutePath().toString()
|
||||
logger.info("MEDIA save. path: {}", fileSavePathString)
|
||||
|
||||
@Suppress("TooGenericExceptionCaught")
|
||||
try {
|
||||
dataSaveRequest.filePath.copyTo(fileSavePath)
|
||||
dataSaveRequest.thumbnailPath?.copyTo(thumbnailSavePath)
|
||||
|
@ -97,6 +98,7 @@ class LocalFileSystemMediaDataStore(
|
|||
*/
|
||||
override suspend fun delete(id: String) {
|
||||
logger.info("START Media delete. id: {}", id)
|
||||
@Suppress("TooGenericExceptionCaught")
|
||||
try {
|
||||
buildSavePath(savePath, id).deleteIfExists()
|
||||
buildSavePath(savePath, "thumbnail-$id").deleteIfExists()
|
||||
|
|
|
@ -99,7 +99,6 @@ class MediaServiceImpl(
|
|||
override suspend fun uploadRemoteMedia(remoteMedia: RemoteMedia): Media {
|
||||
logger.info("MEDIA Remote media. filename:${remoteMedia.name} url:${remoteMedia.url}")
|
||||
|
||||
|
||||
val findByRemoteUrl = mediaRepository.findByRemoteUrl(remoteMedia.url)
|
||||
if (findByRemoteUrl != null) {
|
||||
logger.warn("DUPLICATED Remote media is duplicated. url: {}", remoteMedia.url)
|
||||
|
@ -156,7 +155,7 @@ class MediaServiceImpl(
|
|||
}
|
||||
}
|
||||
|
||||
protected fun findMediaProcessor(mimeType: MimeType): MediaProcessService {
|
||||
private fun findMediaProcessor(mimeType: MimeType): MediaProcessService {
|
||||
try {
|
||||
return mediaProcessServices.first {
|
||||
try {
|
||||
|
@ -170,7 +169,7 @@ class MediaServiceImpl(
|
|||
}
|
||||
}
|
||||
|
||||
protected fun generateBlurhash(process: ProcessedMediaPath): String {
|
||||
private fun generateBlurhash(process: ProcessedMediaPath): String {
|
||||
val path = if (process.thumbnailPath != null && process.thumbnailMimeType != null) {
|
||||
process.thumbnailPath
|
||||
} else {
|
||||
|
|
|
@ -81,7 +81,7 @@ class PostServiceImpl(
|
|||
timelineService.publishTimeline(post, isLocal)
|
||||
actorRepository.save(actor.incrementPostsCount())
|
||||
save
|
||||
} catch (e: DuplicateException) {
|
||||
} catch (_: DuplicateException) {
|
||||
postRepository.findByApId(post.apId) ?: throw PostNotFoundException.withApId(post.apId)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ class ReactionServiceImpl(
|
|||
reactionRepository.delete(findByPostIdAndUserIdAndEmojiId)
|
||||
}
|
||||
|
||||
|
||||
val reaction = Reaction(reactionRepository.generateId(), 0, postId, actorId)
|
||||
reactionRepository.save(reaction)
|
||||
apReactionService.reaction(reaction)
|
||||
|
|
|
@ -33,7 +33,6 @@ class InMemoryCacheManager : CacheManager {
|
|||
val processed = try {
|
||||
block()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
cacheKey.remove(key)
|
||||
throw e
|
||||
}
|
||||
|
|
|
@ -59,7 +59,6 @@ class StatsesApiServiceImpl(
|
|||
} else {
|
||||
actorRepository.findById(findById.actorId)?.id
|
||||
}
|
||||
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue