diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt index cbbb29db..73f5d15c 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt @@ -20,6 +20,7 @@ import dev.usbharu.hideout.core.domain.event.actor.ActorDomainEventFactory import dev.usbharu.hideout.core.domain.event.actor.ActorEvent.* import dev.usbharu.hideout.core.domain.model.emoji.EmojiId import dev.usbharu.hideout.core.domain.model.instance.InstanceId +import dev.usbharu.hideout.core.domain.model.media.MediaId import dev.usbharu.hideout.core.domain.model.shared.Domain import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventStorable import java.net.URI @@ -53,8 +54,26 @@ class Actor( emojiIds: Set, deleted: Boolean, roles: Set, + icon: MediaId?, + banner: MediaId?, ) : DomainEventStorable() { + var banner = banner + private set + + fun setBannerUrl(banner: MediaId?, actor: Actor) { + addDomainEvent(ActorDomainEventFactory(this).createEvent(update)) + this.banner = banner + } + + var icon = icon + private set + + fun setIconUrl(icon: MediaId?, actor: Actor) { + addDomainEvent(ActorDomainEventFactory(this).createEvent(update)) + this.icon = icon + } + var roles = roles private set diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposed/ActorResultRowMapper.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposed/ActorResultRowMapper.kt index 3b26139e..3bb58e43 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposed/ActorResultRowMapper.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposed/ActorResultRowMapper.kt @@ -19,6 +19,7 @@ package dev.usbharu.hideout.core.infrastructure.exposed import dev.usbharu.hideout.core.domain.model.actor.* import dev.usbharu.hideout.core.domain.model.emoji.EmojiId import dev.usbharu.hideout.core.domain.model.instance.InstanceId +import dev.usbharu.hideout.core.domain.model.media.MediaId import dev.usbharu.hideout.core.domain.model.shared.Domain import dev.usbharu.hideout.core.infrastructure.exposedrepository.Actors import org.jetbrains.exposed.sql.ResultRow @@ -59,7 +60,9 @@ class ActorResultRowMapper : ResultRowMapper { .map { EmojiId(it.toLong()) } .toSet(), deleted = resultRow[Actors.deleted], - roles = emptySet() + roles = emptySet(), + icon = resultRow[Actors.icon]?.let { MediaId(it) }, + banner = resultRow[Actors.banner]?.let { MediaId(it) } ) } } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedActorRepository.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedActorRepository.kt index d8f560c9..fbdc1d62 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedActorRepository.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedActorRepository.kt @@ -53,6 +53,9 @@ class ExposedActorRepository( it[suspend] = actor.suspend it[moveTo] = actor.moveTo?.id it[emojis] = actor.emojis.joinToString(",") + it[icon] = actor.icon?.id + it[banner] = actor.banner?.id + } ActorsAlsoKnownAs.deleteWhere { actorId eq actor.id.id @@ -127,6 +130,8 @@ object Actors : Table("actors") { val moveTo = long("move_to").references(id).nullable() val emojis = varchar("emojis", 3000) val deleted = bool("deleted") + val banner = long("banner").references(Media.id).nullable() + val icon = long("icon").references(Media.id).nullable() override val primaryKey = PrimaryKey(id) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/factory/ActorFactoryImpl.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/factory/ActorFactoryImpl.kt index 09ba2411..0fb961c5 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/factory/ActorFactoryImpl.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/factory/ActorFactoryImpl.kt @@ -61,7 +61,9 @@ class ActorFactoryImpl( suspend = false, emojiIds = emptySet(), deleted = false, - roles = emptySet() + roles = emptySet(), + banner = null, + icon = null ) } } diff --git a/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/domain/model/actor/TestActorFactory.kt b/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/domain/model/actor/TestActorFactory.kt index 4bb92910..0fb9087d 100644 --- a/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/domain/model/actor/TestActorFactory.kt +++ b/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/domain/model/actor/TestActorFactory.kt @@ -65,7 +65,9 @@ object TestActorFactory { moveTo = moveTo, emojiIds = emojiIds, deleted = deleted, - roles = emptySet() + roles = emptySet(), + icon = null, + banner = null ) } }