mirror of https://github.com/usbharu/Hideout.git
feat: ALTの永続化
This commit is contained in:
parent
58b0931a49
commit
94065578b4
|
@ -133,7 +133,8 @@ class APNoteServiceImpl(
|
||||||
RemoteMedia(
|
RemoteMedia(
|
||||||
(it.name ?: it.url)!!,
|
(it.name ?: it.url)!!,
|
||||||
it.url!!,
|
it.url!!,
|
||||||
it.mediaType ?: "application/octet-stream"
|
it.mediaType ?: "application/octet-stream",
|
||||||
|
description = it.name
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ class HttpClientConfig {
|
||||||
fun httpClient(): HttpClient = HttpClient(CIO).config {
|
fun httpClient(): HttpClient = HttpClient(CIO).config {
|
||||||
install(Logging) {
|
install(Logging) {
|
||||||
logger = Logger.DEFAULT
|
logger = Logger.DEFAULT
|
||||||
level = LogLevel.INFO
|
level = LogLevel.ALL
|
||||||
}
|
}
|
||||||
install(HttpCache) {
|
install(HttpCache) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,5 +11,6 @@ data class Media(
|
||||||
val thumbnailUrl: String?,
|
val thumbnailUrl: String?,
|
||||||
val type: FileType,
|
val type: FileType,
|
||||||
val mimeType: MimeType,
|
val mimeType: MimeType,
|
||||||
val blurHash: String?
|
val blurHash: String?,
|
||||||
|
val description: String? = null
|
||||||
)
|
)
|
||||||
|
|
|
@ -28,6 +28,8 @@ class MediaRepositoryImpl(private val idGenerateService: IdGenerateService) : Me
|
||||||
it[thumbnailUrl] = media.thumbnailUrl
|
it[thumbnailUrl] = media.thumbnailUrl
|
||||||
it[type] = media.type.ordinal
|
it[type] = media.type.ordinal
|
||||||
it[blurhash] = media.blurHash
|
it[blurhash] = media.blurHash
|
||||||
|
it[mimeType] = media.mimeType.type + "/" + media.mimeType.subtype
|
||||||
|
it[description] = media.description
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Media.insert {
|
Media.insert {
|
||||||
|
@ -38,6 +40,8 @@ class MediaRepositoryImpl(private val idGenerateService: IdGenerateService) : Me
|
||||||
it[thumbnailUrl] = media.thumbnailUrl
|
it[thumbnailUrl] = media.thumbnailUrl
|
||||||
it[type] = media.type.ordinal
|
it[type] = media.type.ordinal
|
||||||
it[blurhash] = media.blurHash
|
it[blurhash] = media.blurHash
|
||||||
|
it[mimeType] = media.mimeType.type + "/" + media.mimeType.subtype
|
||||||
|
it[description] = media.description
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return media
|
return media
|
||||||
|
@ -71,7 +75,8 @@ fun ResultRow.toMedia(): EntityMedia {
|
||||||
thumbnailUrl = this[Media.thumbnailUrl],
|
thumbnailUrl = this[Media.thumbnailUrl],
|
||||||
type = fileType,
|
type = fileType,
|
||||||
blurHash = this[Media.blurhash],
|
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],
|
thumbnailUrl = this[Media.thumbnailUrl],
|
||||||
type = FileType.values().first { it.ordinal == this.getOrNull(Media.type) },
|
type = FileType.values().first { it.ordinal == this.getOrNull(Media.type) },
|
||||||
blurHash = this[Media.blurhash],
|
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 type = integer("type")
|
||||||
val blurhash = varchar("blurhash", 255).nullable()
|
val blurhash = varchar("blurhash", 255).nullable()
|
||||||
val mimeType = varchar("mime_type", 255)
|
val mimeType = varchar("mime_type", 255)
|
||||||
|
val description = varchar("description", 4000).nullable()
|
||||||
override val primaryKey = PrimaryKey(id)
|
override val primaryKey = PrimaryKey(id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,8 @@ open class MediaServiceImpl(
|
||||||
thumbnailUrl = save.thumbnailUrl,
|
thumbnailUrl = save.thumbnailUrl,
|
||||||
type = process.fileMimeType.fileType,
|
type = process.fileMimeType.fileType,
|
||||||
mimeType = process.fileMimeType,
|
mimeType = process.fileMimeType,
|
||||||
blurHash = blurHash
|
blurHash = blurHash,
|
||||||
|
description = mediaRequest.description
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,5 +3,6 @@ package dev.usbharu.hideout.core.service.media
|
||||||
data class RemoteMedia(
|
data class RemoteMedia(
|
||||||
val name: String,
|
val name: String,
|
||||||
val url: String,
|
val url: String,
|
||||||
val mediaType: String
|
val mediaType: String,
|
||||||
|
val description: String? = null
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue