mirror of https://github.com/usbharu/Hideout.git
style: スタイルを調整
This commit is contained in:
parent
7c66ceac00
commit
d19a6029e2
|
@ -3,6 +3,7 @@ build:
|
|||
weights:
|
||||
Indentation: 0
|
||||
MagicNumber: 0
|
||||
InjectDispatcher: 0
|
||||
|
||||
style:
|
||||
ClassOrdering:
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.net.URI
|
|||
@Configuration
|
||||
class AwsConfig {
|
||||
@Bean
|
||||
fun s3(awsConfig: StorageConfig): S3Client {
|
||||
fun s3Client(awsConfig: StorageConfig): S3Client {
|
||||
return S3Client.builder()
|
||||
.endpointOverride(URI.create(awsConfig.endpoint))
|
||||
.region(Region.of(awsConfig.region))
|
||||
|
|
|
@ -9,7 +9,6 @@ class SuccessSavedMedia(
|
|||
) :
|
||||
SavedMedia(true)
|
||||
|
||||
|
||||
class FaildSavedMedia(
|
||||
val reason: String,
|
||||
val description: String,
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package dev.usbharu.hideout.repository
|
||||
|
||||
|
||||
import dev.usbharu.hideout.domain.model.hideout.dto.FileType
|
||||
import dev.usbharu.hideout.exception.FailedToGetResourcesException
|
||||
import dev.usbharu.hideout.service.core.IdGenerateService
|
||||
|
@ -17,7 +16,8 @@ class MediaRepositoryImpl(private val idGenerateService: IdGenerateService) : Me
|
|||
override suspend fun save(media: EntityMedia): EntityMedia {
|
||||
if (Media.select {
|
||||
Media.id eq media.id
|
||||
}.singleOrNull() != null) {
|
||||
}.singleOrNull() != null
|
||||
) {
|
||||
Media.update({ Media.id eq media.id }) {
|
||||
it[Media.name] = media.name
|
||||
it[Media.url] = media.url
|
||||
|
@ -58,13 +58,13 @@ class MediaRepositoryImpl(private val idGenerateService: IdGenerateService) : Me
|
|||
|
||||
fun ResultRow.toMedia(): EntityMedia {
|
||||
return EntityMedia(
|
||||
this[Media.id],
|
||||
this[Media.name],
|
||||
this[Media.url],
|
||||
this[Media.remoteUrl],
|
||||
this[Media.thumbnailUrl],
|
||||
FileType.values().first { it.ordinal == this[Media.type] },
|
||||
this[Media.blurhash],
|
||||
id = this[Media.id],
|
||||
name = this[Media.name],
|
||||
url = this[Media.url],
|
||||
remoteUrl = this[Media.remoteUrl],
|
||||
thumbnailUrl = this[Media.thumbnailUrl],
|
||||
type = FileType.values().first { it.ordinal == this[Media.type] },
|
||||
blurHash = this[Media.blurhash],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ class ReactionRepositoryImpl(
|
|||
private val idGenerateService: IdGenerateService
|
||||
) : ReactionRepository {
|
||||
|
||||
|
||||
override suspend fun generateId(): Long = idGenerateService.generateId()
|
||||
|
||||
override suspend fun save(reaction: Reaction): Reaction {
|
||||
|
|
|
@ -13,7 +13,6 @@ class MediaApiServiceImpl(private val mediaService: MediaService, private val tr
|
|||
|
||||
override suspend fun postMedia(media: Media): MediaAttachment {
|
||||
return transaction.transaction {
|
||||
|
||||
val uploadLocalMedia = mediaService.uploadLocalMedia(media)
|
||||
val type = when (uploadLocalMedia.type) {
|
||||
FileType.Image -> MediaAttachment.Type.image
|
||||
|
@ -22,14 +21,14 @@ class MediaApiServiceImpl(private val mediaService: MediaService, private val tr
|
|||
FileType.Unknown -> MediaAttachment.Type.unknown
|
||||
}
|
||||
return@transaction MediaAttachment(
|
||||
uploadLocalMedia.id.toString(),
|
||||
type,
|
||||
uploadLocalMedia.url,
|
||||
uploadLocalMedia.thumbnailUrl,
|
||||
null,
|
||||
media.description,
|
||||
uploadLocalMedia.blurHash,
|
||||
uploadLocalMedia.url
|
||||
id = uploadLocalMedia.id.toString(),
|
||||
type = type,
|
||||
url = uploadLocalMedia.url,
|
||||
previewUrl = uploadLocalMedia.thumbnailUrl,
|
||||
remoteUrl = null,
|
||||
description = media.description,
|
||||
blurhash = uploadLocalMedia.blurHash,
|
||||
textUrl = uploadLocalMedia.url
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,5 +4,4 @@ import dev.usbharu.hideout.domain.model.hideout.dto.FileType
|
|||
|
||||
interface FileTypeDeterminationService {
|
||||
fun fileType(byteArray: ByteArray, filename: String, contentType: String?): FileType
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,9 @@ class MediaServiceImpl(
|
|||
private val mediaProcessService: MediaProcessService
|
||||
) : MediaService {
|
||||
override suspend fun uploadLocalMedia(media: Media): EntityMedia {
|
||||
logger.info("Media upload. filename:${media.file.name} size:${media.file.size} contentType:${media.file.contentType}")
|
||||
logger.info(
|
||||
"Media upload. filename:${media.file.name} size:${media.file.size} contentType:${media.file.contentType}"
|
||||
)
|
||||
|
||||
if (media.file.size == 0L) {
|
||||
throw MediaFileSizeIsZeroException("Media file size is zero.")
|
||||
|
@ -85,9 +87,7 @@ class MediaServiceImpl(
|
|||
)
|
||||
}
|
||||
|
||||
override suspend fun uploadRemoteMedia(remoteMedia: RemoteMedia) {
|
||||
|
||||
}
|
||||
override suspend fun uploadRemoteMedia(remoteMedia: RemoteMedia) = Unit
|
||||
|
||||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(MediaServiceImpl::class.java)
|
||||
|
|
|
@ -19,7 +19,6 @@ class MediaProcessServiceImpl(
|
|||
file: ByteArray,
|
||||
thumbnail: ByteArray?
|
||||
): ProcessedMedia {
|
||||
|
||||
val fileInputStream = try {
|
||||
mediaConverterRoot.convert(fileType, contentType, filename, file.inputStream().buffered())
|
||||
} catch (e: Exception) {
|
||||
|
@ -33,7 +32,8 @@ class MediaProcessServiceImpl(
|
|||
null
|
||||
}
|
||||
return ProcessedMedia(
|
||||
fileInputStream, thumbnailGenerateService.generate(
|
||||
fileInputStream,
|
||||
thumbnailGenerateService.generate(
|
||||
thumbnailInputStream?.byteArray ?: file,
|
||||
2048,
|
||||
2048
|
||||
|
|
Loading…
Reference in New Issue