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