mirror of https://github.com/usbharu/Hideout.git
fix: lint
This commit is contained in:
parent
f0a84e7fa1
commit
ac0e05ade8
|
@ -41,7 +41,5 @@ open class Delete : Object {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String = "Delete(`object`=$`object`, published=$published) ${super.toString()}"
|
||||||
return "Delete(`object`=$`object`, published=$published) ${super.toString()}"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,13 +62,9 @@ class ContextDeserializer : JsonDeserializer<String>() {
|
||||||
|
|
||||||
class ContextSerializer : JsonSerializer<List<String>>() {
|
class ContextSerializer : JsonSerializer<List<String>>() {
|
||||||
|
|
||||||
override fun isEmpty(value: List<String>?): Boolean {
|
override fun isEmpty(value: List<String>?): Boolean = value.isNullOrEmpty()
|
||||||
return value.isNullOrEmpty()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun isEmpty(provider: SerializerProvider?, value: List<String>?): Boolean {
|
override fun isEmpty(provider: SerializerProvider?, value: List<String>?): Boolean = value.isNullOrEmpty()
|
||||||
return value.isNullOrEmpty()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun serialize(value: List<String>?, gen: JsonGenerator?, serializers: SerializerProvider) {
|
override fun serialize(value: List<String>?, gen: JsonGenerator?, serializers: SerializerProvider) {
|
||||||
if (value.isNullOrEmpty()) {
|
if (value.isNullOrEmpty()) {
|
||||||
|
|
|
@ -46,9 +46,7 @@ open class Object : JsonLd {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String = "Object(type=$type, name=$name, actor=$actor, id=$id) ${super.toString()}"
|
||||||
return "Object(type=$type, name=$name, actor=$actor, id=$id) ${super.toString()}"
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
|
|
@ -12,7 +12,7 @@ class UserAPControllerImpl(private val apUserService: APUserService) : UserAPCon
|
||||||
override suspend fun userAp(username: String): ResponseEntity<Person> {
|
override suspend fun userAp(username: String): ResponseEntity<Person> {
|
||||||
val person = try {
|
val person = try {
|
||||||
apUserService.getPersonByName(username)
|
apUserService.getPersonByName(username)
|
||||||
} catch (e: FailedToGetResourcesException) {
|
} catch (_: FailedToGetResourcesException) {
|
||||||
return ResponseEntity.notFound().build()
|
return ResponseEntity.notFound().build()
|
||||||
}
|
}
|
||||||
person.context += listOf("https://www.w3.org/ns/activitystreams")
|
person.context += listOf("https://www.w3.org/ns/activitystreams")
|
||||||
|
|
|
@ -22,7 +22,7 @@ class APReceiveDeleteServiceImpl(
|
||||||
|
|
||||||
val post = try {
|
val post = try {
|
||||||
postQueryService.findByApId(deleteId)
|
postQueryService.findByApId(deleteId)
|
||||||
} catch (e: FailedToGetResourcesException) {
|
} catch (_: FailedToGetResourcesException) {
|
||||||
return@transaction ActivityPubStringResponse(HttpStatusCode.OK, "Resource not found or already deleted")
|
return@transaction ActivityPubStringResponse(HttpStatusCode.OK, "Resource not found or already deleted")
|
||||||
}
|
}
|
||||||
postRepository.delete(post.id)
|
postRepository.delete(post.id)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package dev.usbharu.hideout.activitypub.service.objects.note
|
package dev.usbharu.hideout.activitypub.service.objects.note
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper
|
|
||||||
import dev.usbharu.hideout.activitypub.domain.exception.FailedToGetActivityPubResourceException
|
import dev.usbharu.hideout.activitypub.domain.exception.FailedToGetActivityPubResourceException
|
||||||
import dev.usbharu.hideout.activitypub.domain.exception.IllegalActivityPubObjectException
|
import dev.usbharu.hideout.activitypub.domain.exception.IllegalActivityPubObjectException
|
||||||
import dev.usbharu.hideout.activitypub.domain.model.Note
|
import dev.usbharu.hideout.activitypub.domain.model.Note
|
||||||
|
@ -24,7 +23,6 @@ import kotlinx.coroutines.async
|
||||||
import kotlinx.coroutines.slf4j.MDCContext
|
import kotlinx.coroutines.slf4j.MDCContext
|
||||||
import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction
|
import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.beans.factory.annotation.Qualifier
|
|
||||||
import org.springframework.cache.annotation.Cacheable
|
import org.springframework.cache.annotation.Cacheable
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
@ -50,7 +48,6 @@ class APNoteServiceImpl(
|
||||||
private val postRepository: PostRepository,
|
private val postRepository: PostRepository,
|
||||||
private val apUserService: APUserService,
|
private val apUserService: APUserService,
|
||||||
private val postQueryService: PostQueryService,
|
private val postQueryService: PostQueryService,
|
||||||
@Qualifier("activitypub") private val objectMapper: ObjectMapper,
|
|
||||||
private val postService: PostService,
|
private val postService: PostService,
|
||||||
private val apResourceResolveService: APResourceResolveService,
|
private val apResourceResolveService: APResourceResolveService,
|
||||||
private val postBuilder: Post.PostBuilder,
|
private val postBuilder: Post.PostBuilder,
|
||||||
|
|
|
@ -73,7 +73,6 @@ class PostRepositoryImpl(
|
||||||
.let(postQueryMapper::map)
|
.let(postQueryMapper::map)
|
||||||
.singleOr { FailedToGetResourcesException("id: $id was not found.", it) }
|
.singleOr { FailedToGetResourcesException("id: $id was not found.", it) }
|
||||||
|
|
||||||
|
|
||||||
override suspend fun delete(id: Long) {
|
override suspend fun delete(id: Long) {
|
||||||
Posts.deleteWhere { Posts.id eq id }
|
Posts.deleteWhere { Posts.id eq id }
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ open class MediaServiceImpl(
|
||||||
private val remoteMediaDownloadService: RemoteMediaDownloadService,
|
private val remoteMediaDownloadService: RemoteMediaDownloadService,
|
||||||
private val renameService: MediaFileRenameService
|
private val renameService: MediaFileRenameService
|
||||||
) : MediaService {
|
) : MediaService {
|
||||||
|
@Suppress("LongMethod")
|
||||||
override suspend fun uploadLocalMedia(mediaRequest: MediaRequest): EntityMedia {
|
override suspend fun uploadLocalMedia(mediaRequest: MediaRequest): EntityMedia {
|
||||||
val fileName = mediaRequest.file.name
|
val fileName = mediaRequest.file.name
|
||||||
logger.info(
|
logger.info(
|
||||||
|
@ -33,8 +34,6 @@ open class MediaServiceImpl(
|
||||||
|
|
||||||
val tempFile = Files.createTempFile("hideout-tmp-file", ".tmp")
|
val tempFile = Files.createTempFile("hideout-tmp-file", ".tmp")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
tempFile.withDelete().use {
|
tempFile.withDelete().use {
|
||||||
Files.newOutputStream(tempFile).use { outputStream ->
|
Files.newOutputStream(tempFile).use { outputStream ->
|
||||||
mediaRequest.file.inputStream.use {
|
mediaRequest.file.inputStream.use {
|
||||||
|
@ -93,8 +92,6 @@ open class MediaServiceImpl(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: 仮の処理として保存したように動かす
|
// TODO: 仮の処理として保存したように動かす
|
||||||
|
@ -156,11 +153,11 @@ open class MediaServiceImpl(
|
||||||
return mediaProcessServices.first {
|
return mediaProcessServices.first {
|
||||||
try {
|
try {
|
||||||
it.isSupport(mimeType)
|
it.isSupport(mimeType)
|
||||||
} catch (e: Exception) {
|
} catch (_: Exception) {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: NoSuchElementException) {
|
} catch (_: NoSuchElementException) {
|
||||||
throw UnsupportedMediaException("MediaType: $mimeType isn't supported.")
|
throw UnsupportedMediaException("MediaType: $mimeType isn't supported.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,7 @@ class MediaProcessServiceImpl(
|
||||||
private val mediaConverterRoot: MediaConverterRoot,
|
private val mediaConverterRoot: MediaConverterRoot,
|
||||||
private val thumbnailGenerateService: ThumbnailGenerateService
|
private val thumbnailGenerateService: ThumbnailGenerateService
|
||||||
) : MediaProcessService {
|
) : MediaProcessService {
|
||||||
override fun isSupport(mimeType: MimeType): Boolean {
|
override fun isSupport(mimeType: MimeType): Boolean = false
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun process(
|
override suspend fun process(
|
||||||
fileType: FileType,
|
fileType: FileType,
|
||||||
|
|
|
@ -70,7 +70,9 @@ class ImageMediaProcessService(private val imageMediaProcessorConfiguration: Ima
|
||||||
Thumbnails.of(thumbnails.toFile()).size(width, height).asBufferedImage()
|
Thumbnails.of(thumbnails.toFile()).size(width, height).asBufferedImage()
|
||||||
} else {
|
} else {
|
||||||
Thumbnails.of(bufferedImage).size(width, height).asBufferedImage()
|
Thumbnails.of(bufferedImage).size(width, height).asBufferedImage()
|
||||||
}, convertType, it
|
},
|
||||||
|
convertType,
|
||||||
|
it
|
||||||
)
|
)
|
||||||
if (write) {
|
if (write) {
|
||||||
tempThumbnailFile
|
tempThumbnailFile
|
||||||
|
|
|
@ -22,9 +22,7 @@ import kotlin.math.min
|
||||||
@Service
|
@Service
|
||||||
@Qualifier("video")
|
@Qualifier("video")
|
||||||
class MovieMediaProcessService : MediaProcessService {
|
class MovieMediaProcessService : MediaProcessService {
|
||||||
override fun isSupport(mimeType: MimeType): Boolean {
|
override fun isSupport(mimeType: MimeType): Boolean = mimeType.type == "video"
|
||||||
return mimeType.type == "video"
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun process(
|
override suspend fun process(
|
||||||
fileType: FileType,
|
fileType: FileType,
|
||||||
|
@ -92,7 +90,6 @@ class MovieMediaProcessService : MediaProcessService {
|
||||||
while (true) {
|
while (true) {
|
||||||
val grab = grabber.grab() ?: break
|
val grab = grabber.grab() ?: break
|
||||||
|
|
||||||
|
|
||||||
if (bufferedImage == null) {
|
if (bufferedImage == null) {
|
||||||
bufferedImage = frameConverter.convert(grab)
|
bufferedImage = frameConverter.convert(grab)
|
||||||
}
|
}
|
||||||
|
@ -106,14 +103,11 @@ class MovieMediaProcessService : MediaProcessService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (bufferedImage != null) {
|
if (bufferedImage != null) {
|
||||||
ImageIO.write(bufferedImage, "jpeg", thumbnailFile.toFile())
|
ImageIO.write(bufferedImage, "jpeg", thumbnailFile.toFile())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("SUCCESS Convert Movie Media {}", fileName)
|
logger.info("SUCCESS Convert Movie Media {}", fileName)
|
||||||
|
|
|
@ -45,7 +45,7 @@ class ReactionServiceImpl(
|
||||||
reactionQueryService.findByPostIdAndUserIdAndEmojiId(postId, userId, 0)
|
reactionQueryService.findByPostIdAndUserIdAndEmojiId(postId, userId, 0)
|
||||||
reactionRepository.delete(findByPostIdAndUserIdAndEmojiId)
|
reactionRepository.delete(findByPostIdAndUserIdAndEmojiId)
|
||||||
apReactionService.removeReaction(findByPostIdAndUserIdAndEmojiId)
|
apReactionService.removeReaction(findByPostIdAndUserIdAndEmojiId)
|
||||||
} catch (e: FailedToGetResourcesException) {
|
} catch (_: FailedToGetResourcesException) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,6 @@ import org.junit.jupiter.api.Assertions.assertEquals
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.junit.jupiter.api.assertThrows
|
import org.junit.jupiter.api.assertThrows
|
||||||
import org.mockito.kotlin.*
|
import org.mockito.kotlin.*
|
||||||
import utils.JsonObjectMapper.objectMapper
|
|
||||||
import utils.PostBuilder
|
import utils.PostBuilder
|
||||||
import utils.UserBuilder
|
import utils.UserBuilder
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
@ -74,7 +73,6 @@ class APNoteServiceImplTest {
|
||||||
postRepository = mock(),
|
postRepository = mock(),
|
||||||
apUserService = mock(),
|
apUserService = mock(),
|
||||||
postQueryService = mock(),
|
postQueryService = mock(),
|
||||||
objectMapper = objectMapper,
|
|
||||||
postService = mock(),
|
postService = mock(),
|
||||||
apResourceResolveService = mock(),
|
apResourceResolveService = mock(),
|
||||||
postBuilder = Post.PostBuilder(CharacterLimit()),
|
postBuilder = Post.PostBuilder(CharacterLimit()),
|
||||||
|
@ -152,7 +150,6 @@ class APNoteServiceImplTest {
|
||||||
postRepository = postRepository,
|
postRepository = postRepository,
|
||||||
apUserService = apUserService,
|
apUserService = apUserService,
|
||||||
postQueryService = postQueryService,
|
postQueryService = postQueryService,
|
||||||
objectMapper = objectMapper,
|
|
||||||
postService = mock(),
|
postService = mock(),
|
||||||
apResourceResolveService = apResourceResolveService,
|
apResourceResolveService = apResourceResolveService,
|
||||||
postBuilder = Post.PostBuilder(CharacterLimit()),
|
postBuilder = Post.PostBuilder(CharacterLimit()),
|
||||||
|
@ -221,7 +218,6 @@ class APNoteServiceImplTest {
|
||||||
postRepository = mock(),
|
postRepository = mock(),
|
||||||
apUserService = mock(),
|
apUserService = mock(),
|
||||||
postQueryService = postQueryService,
|
postQueryService = postQueryService,
|
||||||
objectMapper = objectMapper,
|
|
||||||
postService = mock(),
|
postService = mock(),
|
||||||
apResourceResolveService = apResourceResolveService,
|
apResourceResolveService = apResourceResolveService,
|
||||||
postBuilder = Post.PostBuilder(CharacterLimit()),
|
postBuilder = Post.PostBuilder(CharacterLimit()),
|
||||||
|
@ -274,7 +270,6 @@ class APNoteServiceImplTest {
|
||||||
postRepository = postRepository,
|
postRepository = postRepository,
|
||||||
apUserService = apUserService,
|
apUserService = apUserService,
|
||||||
postQueryService = mock(),
|
postQueryService = mock(),
|
||||||
objectMapper = objectMapper,
|
|
||||||
postService = postService,
|
postService = postService,
|
||||||
apResourceResolveService = mock(),
|
apResourceResolveService = mock(),
|
||||||
postBuilder = postBuilder,
|
postBuilder = postBuilder,
|
||||||
|
@ -333,7 +328,6 @@ class APNoteServiceImplTest {
|
||||||
postRepository = mock(),
|
postRepository = mock(),
|
||||||
apUserService = mock(),
|
apUserService = mock(),
|
||||||
postQueryService = mock(),
|
postQueryService = mock(),
|
||||||
objectMapper = objectMapper,
|
|
||||||
postService = mock(),
|
postService = mock(),
|
||||||
apResourceResolveService = mock(),
|
apResourceResolveService = mock(),
|
||||||
postBuilder = postBuilder,
|
postBuilder = postBuilder,
|
||||||
|
|
Loading…
Reference in New Issue