From c52d1576969cbcf619ab834e03a400795d8abc31 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Sat, 14 Sep 2024 22:09:39 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF?= =?UTF-8?q?=E3=82=BF=E3=83=AA=E3=83=B3=E3=82=B0=E3=81=A7=E5=A3=8A=E3=82=8C?= =?UTF-8?q?=E3=81=9F=E9=83=A8=E5=88=86=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actor/GetActorDetailApplicationService.kt | 4 +-- .../RegisterApplicationApplicationService.kt | 1 - .../core/application/model/ActorDetail.kt | 6 ++-- .../ExposedUserTimelineQueryService.kt | 31 +++++++++++-------- .../resources/templates/fragments-post.html | 6 ++-- .../mastodon/interfaces/api/SpringMediaApi.kt | 17 +++++----- 6 files changed, 35 insertions(+), 30 deletions(-) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/GetActorDetailApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/GetActorDetailApplicationService.kt index ec8b44a2..29ffdc33 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/GetActorDetailApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/GetActorDetailApplicationService.kt @@ -39,8 +39,8 @@ class GetActorDetailApplicationService( throw IllegalArgumentException("id and actorName are null.") } - val iconUrl = actor.icon?.let { mediaRepository.findById(it)?.url } - val bannerUrl = actor.banner?.let { mediaRepository.findById(it)?.url } + val iconUrl = actor.icon?.let { mediaRepository.findById(it) } + val bannerUrl = actor.banner?.let { mediaRepository.findById(it) } return ActorDetail.of(actor, iconUrl, bannerUrl) } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/application/RegisterApplicationApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/application/RegisterApplicationApplicationService.kt index 3b057729..47a2de93 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/application/RegisterApplicationApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/application/RegisterApplicationApplicationService.kt @@ -16,7 +16,6 @@ package dev.usbharu.hideout.core.application.application -import dev.usbharu.hideout.core.application.model.Application import dev.usbharu.hideout.core.application.shared.AbstractApplicationService import dev.usbharu.hideout.core.application.shared.Transaction import dev.usbharu.hideout.core.domain.model.application.Application diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/model/ActorDetail.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/model/ActorDetail.kt index 851dcd44..fd3694b8 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/model/ActorDetail.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/model/ActorDetail.kt @@ -9,7 +9,8 @@ data class ActorDetail( val name: String, val screenName: String, val host: String, - val remoteUrl: String?, + val instanceId: Long, + val remoteUrl: URI?, val locked: Boolean, val description: String, val postsCount: Int, @@ -25,7 +26,8 @@ data class ActorDetail( name = actor.name.name, screenName = actor.screenName.screenName, host = actor.url.host, - remoteUrl = actor.url.toString(), + instanceId = actor.instance.instanceId, + remoteUrl = actor.url, locked = actor.locked, description = actor.description.description, postsCount = actor.postsCount.postsCount, diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedquery/ExposedUserTimelineQueryService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedquery/ExposedUserTimelineQueryService.kt index 4e36dfb8..1864586b 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedquery/ExposedUserTimelineQueryService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedquery/ExposedUserTimelineQueryService.kt @@ -42,10 +42,10 @@ class ExposedUserTimelineQueryService : UserTimelineQueryService, AbstractReposi .select(Posts.columns) .where { Posts.visibility eq Visibility.PUBLIC.name or - (Posts.visibility eq Visibility.UNLISTED.name) or - (Posts.visibility eq Visibility.DIRECT.name and (PostsVisibleActors.actorId eq principal.actorId.id)) or - (Posts.visibility eq Visibility.FOLLOWERS.name and (Relationships.blocking eq false and (relationshipsAlias[Relationships.following] eq true))) or - (Posts.actorId eq principal.actorId.id) + (Posts.visibility eq Visibility.UNLISTED.name) or + (Posts.visibility eq Visibility.DIRECT.name and (PostsVisibleActors.actorId eq principal.actorId.id)) or + (Posts.visibility eq Visibility.FOLLOWERS.name and (Relationships.blocking eq false and (relationshipsAlias[Relationships.following] eq true))) or + (Posts.actorId eq principal.actorId.id) } .alias("authorized_table") } @@ -56,15 +56,15 @@ class ExposedUserTimelineQueryService : UserTimelineQueryService, AbstractReposi val iconMedia = Media.alias("ICON_MEDIA") return authorizedQuery - .leftJoin(PostsVisibleActors, { authorizedQuery[Posts.id] }, { PostsVisibleActors.postId }) - .leftJoin(Actors, { authorizedQuery[Posts.actorId] }, { Actors.id }) + .leftJoin(PostsVisibleActors, { authorizedQuery[Posts.id] }, { postId }) + .leftJoin(Actors, { authorizedQuery[Posts.actorId] }, { id }) .leftJoin(iconMedia, { Actors.icon }, { iconMedia[Media.id] }) - .leftJoin(PostsMedia, { authorizedQuery[Posts.id] }, { PostsMedia.postId }) - .leftJoin(Media, { PostsMedia.mediaId }, { Media.id }) + .leftJoin(PostsMedia, { authorizedQuery[Posts.id] }, { postId }) + .leftJoin(Media, { PostsMedia.mediaId }, { id }) .leftJoin( Reactions, { authorizedQuery[Posts.id] }, - { Reactions.postId }, + { postId }, { Reactions.id isDistinctFrom principal.actorId.id } ) .selectAll() @@ -85,14 +85,19 @@ class ExposedUserTimelineQueryService : UserTimelineQueryService, AbstractReposi return PostDetail( id = it[authorizedQuery[Posts.id]], actor = ActorDetail( - actorId = it[authorizedQuery[Posts.actorId]], + id = it[authorizedQuery[Posts.actorId]], instanceId = it[Actors.instance], name = it[Actors.name], - domain = it[Actors.domain], + host = it[Actors.domain], screenName = it[Actors.screenName], - url = it[Actors.url], + remoteUrl = it[Actors.url], locked = it[Actors.locked], - icon = it.getOrNull(iconMedia[Media.url]) + iconUrl = it.getOrNull(iconMedia[Media.url]), + description = it[Actors.description], + postsCount = it[Actors.postsCount], + bannerURL = null, + followingCount = it[Actors.followingCount], + followersCount = it[Actors.followersCount], ), overview = it[authorizedQuery[Posts.overview]], text = it[authorizedQuery[Posts.text]], diff --git a/hideout-core/src/main/resources/templates/fragments-post.html b/hideout-core/src/main/resources/templates/fragments-post.html index a58fb594..e094c18a 100644 --- a/hideout-core/src/main/resources/templates/fragments-post.html +++ b/hideout-core/src/main/resources/templates/fragments-post.html @@ -9,10 +9,10 @@
- +
- +
diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringMediaApi.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringMediaApi.kt index 16fbe9cb..d5bed541 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringMediaApi.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringMediaApi.kt @@ -18,7 +18,6 @@ package dev.usbharu.hideout.mastodon.interfaces.api import dev.usbharu.hideout.core.application.media.UploadMedia import dev.usbharu.hideout.core.application.media.UploadMediaApplicationService -import dev.usbharu.hideout.core.domain.model.media.FileType.* import dev.usbharu.hideout.core.infrastructure.springframework.oauth2.SpringSecurityOauth2PrincipalContextHolder import dev.usbharu.hideout.mastodon.interfaces.api.generated.MediaApi import dev.usbharu.hideout.mastodon.interfaces.api.generated.model.MediaAttachment @@ -58,18 +57,18 @@ class SpringMediaApi( return ResponseEntity.ok( MediaAttachment( - id = media.id.toString(), + id = media.mediaId.toString(), type = when (media.type) { - Image -> MediaAttachment.Type.image - Video -> MediaAttachment.Type.video - Audio -> MediaAttachment.Type.audio - Unknown -> MediaAttachment.Type.unknown + "Image" -> MediaAttachment.Type.image + "Video" -> MediaAttachment.Type.video + "Audio" -> MediaAttachment.Type.audio + else -> MediaAttachment.Type.unknown }, url = media.url.toString(), - previewUrl = media.thumbprintURI?.toString(), - remoteUrl = media.remoteURL?.toString(), + previewUrl = media.thumbnailUrl?.toString(), + remoteUrl = null, description = media.description, - blurhash = media.blurHash, + blurhash = media.blurhash, textUrl = media.url.toASCIIString() ) )