mirror of https://github.com/usbharu/Hideout.git
Merge branch 'develop' into detekt
This commit is contained in:
commit
486268609b
|
@ -58,7 +58,8 @@ class UploadMediaApplicationService(
|
||||||
type = process.fileType,
|
type = process.fileType,
|
||||||
mimeType = process.mimeType,
|
mimeType = process.mimeType,
|
||||||
blurHash = process.blurHash?.let { MediaBlurHash(it) },
|
blurHash = process.blurHash?.let { MediaBlurHash(it) },
|
||||||
description = command.description?.let { MediaDescription(it) }
|
description = command.description?.let { MediaDescription(it) },
|
||||||
|
actorId = principal.actorId
|
||||||
)
|
)
|
||||||
|
|
||||||
mediaRepository.save(media)
|
mediaRepository.save(media)
|
||||||
|
|
|
@ -10,18 +10,20 @@ data class MediaDetail(
|
||||||
val thumbnailUrl: URI?,
|
val thumbnailUrl: URI?,
|
||||||
val sensitive: Boolean,
|
val sensitive: Boolean,
|
||||||
val description: String,
|
val description: String,
|
||||||
val blurhash: String
|
val blurhash: String,
|
||||||
|
val actorId: Long
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
fun of(media: Media): MediaDetail {
|
fun of(media: Media): MediaDetail {
|
||||||
return MediaDetail(
|
return MediaDetail(
|
||||||
media.id.id,
|
mediaId = media.id.id,
|
||||||
media.type.name,
|
type = media.type.name,
|
||||||
media.url,
|
url = media.url,
|
||||||
media.thumbnailUrl,
|
thumbnailUrl = media.thumbnailUrl,
|
||||||
false,
|
sensitive = false,
|
||||||
media.description?.description.orEmpty(),
|
description = media.description?.description.orEmpty(),
|
||||||
media.blurHash?.hash.orEmpty()
|
blurhash = media.blurHash?.hash.orEmpty(),
|
||||||
|
actorId = media.actorId.id
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.domain.model.media
|
package dev.usbharu.hideout.core.domain.model.media
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
|
||||||
@Suppress("LongParameterList")
|
@Suppress("LongParameterList")
|
||||||
|
@ -29,6 +30,7 @@ class Media(
|
||||||
val mimeType: MimeType,
|
val mimeType: MimeType,
|
||||||
val blurHash: MediaBlurHash?,
|
val blurHash: MediaBlurHash?,
|
||||||
val description: MediaDescription? = null,
|
val description: MediaDescription? = null,
|
||||||
|
val actorId: ActorId,
|
||||||
) {
|
) {
|
||||||
var url = url
|
var url = url
|
||||||
private set
|
private set
|
||||||
|
@ -46,19 +48,21 @@ class Media(
|
||||||
return id == other.id
|
return id == other.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun hashCode(): Int = id.hashCode()
|
override fun hashCode(): Int = id.hashCode()
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return "Media(" +
|
return "Media(" +
|
||||||
"id=$id, " +
|
"id=$id, " +
|
||||||
"name=$name, " +
|
"name=$name, " +
|
||||||
"url=$url, " +
|
|
||||||
"remoteUrl=$remoteUrl, " +
|
"remoteUrl=$remoteUrl, " +
|
||||||
"thumbnailUrl=$thumbnailUrl, " +
|
"thumbnailUrl=$thumbnailUrl, " +
|
||||||
"type=$type, " +
|
"type=$type, " +
|
||||||
"mimeType=$mimeType, " +
|
"mimeType=$mimeType, " +
|
||||||
"blurHash=$blurHash, " +
|
"blurHash=$blurHash, " +
|
||||||
"description=$description" +
|
"description=$description, " +
|
||||||
|
"actorId=$actorId, " +
|
||||||
|
"url=$url" +
|
||||||
")"
|
")"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ class ExposedActorRepository(
|
||||||
it[description] = actor.description.description
|
it[description] = actor.description.description
|
||||||
it[inbox] = actor.inbox.toString()
|
it[inbox] = actor.inbox.toString()
|
||||||
it[outbox] = actor.outbox.toString()
|
it[outbox] = actor.outbox.toString()
|
||||||
it[url] = actor.outbox.toString()
|
it[url] = actor.url.toString()
|
||||||
it[publicKey] = actor.publicKey.publicKey
|
it[publicKey] = actor.publicKey.publicKey
|
||||||
it[privateKey] = actor.privateKey?.privateKey
|
it[privateKey] = actor.privateKey?.privateKey
|
||||||
it[createdAt] = actor.createdAt
|
it[createdAt] = actor.createdAt
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.infrastructure.exposedrepository
|
package dev.usbharu.hideout.core.infrastructure.exposedrepository
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||||
import dev.usbharu.hideout.core.domain.model.media.*
|
import dev.usbharu.hideout.core.domain.model.media.*
|
||||||
import org.jetbrains.exposed.sql.*
|
import org.jetbrains.exposed.sql.*
|
||||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||||
|
@ -66,6 +67,7 @@ class MediaRepositoryImpl : MediaRepository, AbstractRepository() {
|
||||||
it[blurhash] = media.blurHash?.hash
|
it[blurhash] = media.blurHash?.hash
|
||||||
it[mimeType] = media.mimeType.type + "/" + media.mimeType.subtype
|
it[mimeType] = media.mimeType.type + "/" + media.mimeType.subtype
|
||||||
it[description] = media.description?.description
|
it[description] = media.description?.description
|
||||||
|
it[actorId] = media.actorId.id
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Media.insert {
|
Media.insert {
|
||||||
|
@ -78,6 +80,7 @@ class MediaRepositoryImpl : MediaRepository, AbstractRepository() {
|
||||||
it[blurhash] = media.blurHash?.hash
|
it[blurhash] = media.blurHash?.hash
|
||||||
it[mimeType] = media.mimeType.type + "/" + media.mimeType.subtype
|
it[mimeType] = media.mimeType.type + "/" + media.mimeType.subtype
|
||||||
it[description] = media.description?.description
|
it[description] = media.description?.description
|
||||||
|
it[actorId] = media.actorId.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return@query media
|
return@query media
|
||||||
|
@ -100,7 +103,8 @@ fun ResultRow.toMedia(): EntityMedia {
|
||||||
type = fileType,
|
type = fileType,
|
||||||
blurHash = this[Media.blurhash]?.let { MediaBlurHash(it) },
|
blurHash = this[Media.blurhash]?.let { MediaBlurHash(it) },
|
||||||
mimeType = MimeType(mimeType.substringBefore("/"), mimeType.substringAfter("/"), fileType),
|
mimeType = MimeType(mimeType.substringBefore("/"), mimeType.substringAfter("/"), fileType),
|
||||||
description = this[Media.description]?.let { MediaDescription(it) }
|
description = this[Media.description]?.let { MediaDescription(it) },
|
||||||
|
actorId = ActorId(this[Media.actorId])
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,5 +118,6 @@ object Media : Table("media") {
|
||||||
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()
|
val description = varchar("description", 4000).nullable()
|
||||||
|
val actorId = long("actor_id").references(Actors.id)
|
||||||
override val primaryKey = PrimaryKey(id)
|
override val primaryKey = PrimaryKey(id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.mastodon.infrastructure.exposedquery
|
package dev.usbharu.hideout.mastodon.infrastructure.exposedquery
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||||
import dev.usbharu.hideout.core.domain.model.emoji.CustomEmoji
|
import dev.usbharu.hideout.core.domain.model.emoji.CustomEmoji
|
||||||
import dev.usbharu.hideout.core.domain.model.media.*
|
import dev.usbharu.hideout.core.domain.model.media.*
|
||||||
import dev.usbharu.hideout.core.domain.model.post.Visibility
|
import dev.usbharu.hideout.core.domain.model.post.Visibility
|
||||||
|
@ -285,7 +286,8 @@ fun ResultRow.toMedia(): EntityMedia {
|
||||||
type = fileType,
|
type = fileType,
|
||||||
blurHash = this[Media.blurhash]?.let { MediaBlurHash(it) },
|
blurHash = this[Media.blurhash]?.let { MediaBlurHash(it) },
|
||||||
mimeType = MimeType(mimeType.substringBefore("/"), mimeType.substringAfter("/"), fileType),
|
mimeType = MimeType(mimeType.substringBefore("/"), mimeType.substringAfter("/"), fileType),
|
||||||
description = this[Media.description]?.let { MediaDescription(it) }
|
description = this[Media.description]?.let { MediaDescription(it) },
|
||||||
|
actorId = ActorId(this[Media.actorId])
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,7 +303,8 @@ fun ResultRow.toMediaOrNull(): EntityMedia? {
|
||||||
type = FileType.valueOf(this[Media.type]),
|
type = FileType.valueOf(this[Media.type]),
|
||||||
blurHash = this[Media.blurhash]?.let { MediaBlurHash(it) },
|
blurHash = this[Media.blurhash]?.let { MediaBlurHash(it) },
|
||||||
mimeType = MimeType(mimeType.substringBefore("/"), mimeType.substringAfter("/"), fileType),
|
mimeType = MimeType(mimeType.substringBefore("/"), mimeType.substringAfter("/"), fileType),
|
||||||
description = this[Media.description]?.let { MediaDescription(it) }
|
description = this[Media.description]?.let { MediaDescription(it) },
|
||||||
|
actorId = ActorId(this[Media.actorId])
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue