From 94065578b481d2767a2aaf1572b50bece63f41fd Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Wed, 15 Nov 2023 20:17:02 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20ALT=E3=81=AE=E6=B0=B8=E7=B6=9A=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activitypub/service/objects/note/APNoteService.kt | 3 ++- .../hideout/application/config/HttpClientConfig.kt | 2 +- .../usbharu/hideout/core/domain/model/media/Media.kt | 3 ++- .../exposedrepository/MediaRepositoryImpl.kt | 11 +++++++++-- .../hideout/core/service/media/MediaServiceImpl.kt | 3 ++- .../usbharu/hideout/core/service/media/RemoteMedia.kt | 3 ++- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/objects/note/APNoteService.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/objects/note/APNoteService.kt index 0fdee80b..204c503d 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/objects/note/APNoteService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/objects/note/APNoteService.kt @@ -133,7 +133,8 @@ class APNoteServiceImpl( RemoteMedia( (it.name ?: it.url)!!, it.url!!, - it.mediaType ?: "application/octet-stream" + it.mediaType ?: "application/octet-stream", + description = it.name ) ) } diff --git a/src/main/kotlin/dev/usbharu/hideout/application/config/HttpClientConfig.kt b/src/main/kotlin/dev/usbharu/hideout/application/config/HttpClientConfig.kt index 51222c8f..6000f0a3 100644 --- a/src/main/kotlin/dev/usbharu/hideout/application/config/HttpClientConfig.kt +++ b/src/main/kotlin/dev/usbharu/hideout/application/config/HttpClientConfig.kt @@ -13,7 +13,7 @@ class HttpClientConfig { fun httpClient(): HttpClient = HttpClient(CIO).config { install(Logging) { logger = Logger.DEFAULT - level = LogLevel.INFO + level = LogLevel.ALL } install(HttpCache) { } diff --git a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/media/Media.kt b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/media/Media.kt index d9697059..be6b3839 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/media/Media.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/media/Media.kt @@ -11,5 +11,6 @@ data class Media( val thumbnailUrl: String?, val type: FileType, val mimeType: MimeType, - val blurHash: String? + val blurHash: String?, + val description: String? = null ) diff --git a/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/MediaRepositoryImpl.kt b/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/MediaRepositoryImpl.kt index 7ef54c00..0206feb9 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/MediaRepositoryImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/MediaRepositoryImpl.kt @@ -28,6 +28,8 @@ class MediaRepositoryImpl(private val idGenerateService: IdGenerateService) : Me it[thumbnailUrl] = media.thumbnailUrl it[type] = media.type.ordinal it[blurhash] = media.blurHash + it[mimeType] = media.mimeType.type + "/" + media.mimeType.subtype + it[description] = media.description } } else { Media.insert { @@ -38,6 +40,8 @@ class MediaRepositoryImpl(private val idGenerateService: IdGenerateService) : Me it[thumbnailUrl] = media.thumbnailUrl it[type] = media.type.ordinal it[blurhash] = media.blurHash + it[mimeType] = media.mimeType.type + "/" + media.mimeType.subtype + it[description] = media.description } } return media @@ -71,7 +75,8 @@ fun ResultRow.toMedia(): EntityMedia { thumbnailUrl = this[Media.thumbnailUrl], type = fileType, blurHash = this[Media.blurhash], - mimeType = MimeType(mimeType.substringBefore("/"), mimeType.substringAfter("/"), fileType) + mimeType = MimeType(mimeType.substringBefore("/"), mimeType.substringAfter("/"), fileType), + description = this[Media.description] ) } @@ -86,7 +91,8 @@ fun ResultRow.toMediaOrNull(): EntityMedia? { thumbnailUrl = this[Media.thumbnailUrl], type = FileType.values().first { it.ordinal == this.getOrNull(Media.type) }, blurHash = this[Media.blurhash], - mimeType = MimeType(mimeType.substringBefore("/"), mimeType.substringAfter("/"), fileType) + mimeType = MimeType(mimeType.substringBefore("/"), mimeType.substringAfter("/"), fileType), + description = this[Media.description] ) } @@ -99,5 +105,6 @@ object Media : Table("media") { val type = integer("type") val blurhash = varchar("blurhash", 255).nullable() val mimeType = varchar("mime_type", 255) + val description = varchar("description", 4000).nullable() override val primaryKey = PrimaryKey(id) } diff --git a/src/main/kotlin/dev/usbharu/hideout/core/service/media/MediaServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/core/service/media/MediaServiceImpl.kt index c5731bb4..005ea34f 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/service/media/MediaServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/service/media/MediaServiceImpl.kt @@ -80,7 +80,8 @@ open class MediaServiceImpl( thumbnailUrl = save.thumbnailUrl, type = process.fileMimeType.fileType, mimeType = process.fileMimeType, - blurHash = blurHash + blurHash = blurHash, + description = mediaRequest.description ) ) } diff --git a/src/main/kotlin/dev/usbharu/hideout/core/service/media/RemoteMedia.kt b/src/main/kotlin/dev/usbharu/hideout/core/service/media/RemoteMedia.kt index 273487c3..66e5f349 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/service/media/RemoteMedia.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/service/media/RemoteMedia.kt @@ -3,5 +3,6 @@ package dev.usbharu.hideout.core.service.media data class RemoteMedia( val name: String, val url: String, - val mediaType: String + val mediaType: String, + val description: String? = null )