Merge remote-tracking branch 'origin/multiproject' into multiproject

This commit is contained in:
usbharu 2024-12-19 20:33:26 +09:00
commit c75f5da307
Signed by: usbharu
GPG Key ID: 95CBCF7046307B77
26 changed files with 163 additions and 163 deletions

View File

@ -46,9 +46,9 @@ class GetLocalInstanceApplicationService(
} }
val instance = ( val instance = (
instanceRepository.findByUrl(applicationConfig.url) instanceRepository.findByUrl(applicationConfig.url)
?: throw InternalServerException("Local instance not found.") ?: throw InternalServerException("Local instance not found.")
) )
cachedInstance = Instance.of(instance) cachedInstance = Instance.of(instance)
@Suppress("UnsafeCallOnNullableType") @Suppress("UnsafeCallOnNullableType")

View File

@ -47,14 +47,14 @@ class GetRelationshipApplicationService(
val target = actorRepository.findById(targetId) val target = actorRepository.findById(targetId)
?: throw IllegalArgumentException("Actor ${command.targetActorId} not found.") ?: throw IllegalArgumentException("Actor ${command.targetActorId} not found.")
val relationship = ( val relationship = (
relationshipRepository.findByActorIdAndTargetId(actor.id, targetId) relationshipRepository.findByActorIdAndTargetId(actor.id, targetId)
?: dev.usbharu.hideout.core.domain.model.relationship.Relationship.default(actor.id, targetId) ?: dev.usbharu.hideout.core.domain.model.relationship.Relationship.default(actor.id, targetId)
) )
val relationship1 = ( val relationship1 = (
relationshipRepository.findByActorIdAndTargetId(targetId, actor.id) relationshipRepository.findByActorIdAndTargetId(targetId, actor.id)
?: dev.usbharu.hideout.core.domain.model.relationship.Relationship.default(targetId, actor.id) ?: dev.usbharu.hideout.core.domain.model.relationship.Relationship.default(targetId, actor.id)
) )
val actorInstanceRelationship = val actorInstanceRelationship =
actorInstanceRelationshipRepository.findByActorIdAndInstanceId(actor.id, target.instance) actorInstanceRelationshipRepository.findByActorIdAndInstanceId(actor.id, target.instance)

View File

@ -41,9 +41,9 @@ class UserRegisterHomeTimelineApplicationService(
) : AbstractApplicationService<RegisterHomeTimeline, Unit>(transaction, logger) { ) : AbstractApplicationService<RegisterHomeTimeline, Unit>(transaction, logger) {
override suspend fun internalExecute(command: RegisterHomeTimeline, principal: Principal) { override suspend fun internalExecute(command: RegisterHomeTimeline, principal: Principal) {
val userDetail = ( val userDetail = (
userDetailRepository.findById(UserDetailId(command.userDetailId)) userDetailRepository.findById(UserDetailId(command.userDetailId))
?: throw IllegalArgumentException("UserDetail ${command.userDetailId} not found.") ?: throw IllegalArgumentException("UserDetail ${command.userDetailId} not found.")
) )
val timeline = Timeline.create( val timeline = Timeline.create(
TimelineId(idGenerateService.generateId()), TimelineId(idGenerateService.generateId()),

View File

@ -39,14 +39,14 @@ class UserRemoveTimelineRelationshipApplicationService(
override suspend fun internalExecute(command: RemoveTimelineRelationship, principal: LocalUser) { override suspend fun internalExecute(command: RemoveTimelineRelationship, principal: LocalUser) {
val timelineRelationship = ( val timelineRelationship = (
timelineRelationshipRepository.findById(command.timelineRelationshipId) timelineRelationshipRepository.findById(command.timelineRelationshipId)
?: throw IllegalArgumentException("TimelineRelationship ${command.timelineRelationshipId} not found.") ?: throw IllegalArgumentException("TimelineRelationship ${command.timelineRelationshipId} not found.")
) )
val timeline = ( val timeline = (
timelineRepository.findById(timelineRelationship.timelineId) timelineRepository.findById(timelineRelationship.timelineId)
?: throw IllegalArgumentException("Timeline ${timelineRelationship.timelineId} not found.") ?: throw IllegalArgumentException("Timeline ${timelineRelationship.timelineId} not found.")
) )
if (timeline.userDetailId != principal.userDetailId) { if (timeline.userDetailId != principal.userDetailId) {
throw PermissionDeniedException() throw PermissionDeniedException()

View File

@ -158,34 +158,34 @@ class Actor(
override fun toString(): String { override fun toString(): String {
return "Actor(" + return "Actor(" +
"id=$id, " + "id=$id, " +
"name=$name, " + "name=$name, " +
"domain=$domain, " + "domain=$domain, " +
"inbox=$inbox, " + "inbox=$inbox, " +
"outbox=$outbox, " + "outbox=$outbox, " +
"url=$url, " + "url=$url, " +
"publicKey=$publicKey, " + "publicKey=$publicKey, " +
"privateKey=$privateKey, " + "privateKey=$privateKey, " +
"createdAt=$createdAt, " + "createdAt=$createdAt, " +
"keyId=$keyId, " + "keyId=$keyId, " +
"followersEndpoint=$followersEndpoint, " + "followersEndpoint=$followersEndpoint, " +
"followingEndpoint=$followingEndpoint, " + "followingEndpoint=$followingEndpoint, " +
"instance=$instance, " + "instance=$instance, " +
"locked=$locked, " + "locked=$locked, " +
"followersCount=$followersCount, " + "followersCount=$followersCount, " +
"followingCount=$followingCount, " + "followingCount=$followingCount, " +
"postsCount=$postsCount, " + "postsCount=$postsCount, " +
"lastPostAt=$lastPostAt, " + "lastPostAt=$lastPostAt, " +
"lastUpdateAt=$lastUpdateAt, " + "lastUpdateAt=$lastUpdateAt, " +
"banner=$banner, " + "banner=$banner, " +
"icon=$icon, " + "icon=$icon, " +
"suspend=$suspend, " + "suspend=$suspend, " +
"alsoKnownAs=$alsoKnownAs, " + "alsoKnownAs=$alsoKnownAs, " +
"moveTo=$moveTo, " + "moveTo=$moveTo, " +
"emojis=$emojis, " + "emojis=$emojis, " +
"description=$description, " + "description=$description, " +
"screenName=$screenName, " + "screenName=$screenName, " +
"deleted=$deleted" + "deleted=$deleted" +
")" ")"
} }
} }

View File

@ -25,12 +25,12 @@ value class ActorPrivateKey(val privateKey: String) {
fun create(privateKey: PrivateKey): ActorPrivateKey { fun create(privateKey: PrivateKey): ActorPrivateKey {
return ActorPrivateKey( return ActorPrivateKey(
"-----BEGIN PRIVATE KEY-----\n" + "-----BEGIN PRIVATE KEY-----\n" +
Base64 Base64
.getEncoder() .getEncoder()
.encodeToString(privateKey.encoded) .encodeToString(privateKey.encoded)
.chunked(64) .chunked(64)
.joinToString("\n") + .joinToString("\n") +
"\n-----END PRIVATE KEY-----" "\n-----END PRIVATE KEY-----"
) )
} }
} }

View File

@ -25,12 +25,12 @@ value class ActorPublicKey(val publicKey: String) {
fun create(publicKey: PublicKey): ActorPublicKey { fun create(publicKey: PublicKey): ActorPublicKey {
return ActorPublicKey( return ActorPublicKey(
"-----BEGIN PUBLIC KEY-----\n" + "-----BEGIN PUBLIC KEY-----\n" +
Base64 Base64
.getEncoder() .getEncoder()
.encodeToString(publicKey.encoded) .encodeToString(publicKey.encoded)
.chunked(64) .chunked(64)
.joinToString("\n") + .joinToString("\n") +
"\n-----END PUBLIC KEY-----" "\n-----END PUBLIC KEY-----"
) )
} }
} }

View File

@ -89,12 +89,12 @@ class ActorInstanceRelationship(
override fun toString(): String { override fun toString(): String {
return "ActorInstanceRelationship(" + return "ActorInstanceRelationship(" +
"actorId=$actorId, " + "actorId=$actorId, " +
"instanceId=$instanceId, " + "instanceId=$instanceId, " +
"blocking=$blocking, " + "blocking=$blocking, " +
"muting=$muting, " + "muting=$muting, " +
"doNotSendPrivate=$doNotSendPrivate" + "doNotSendPrivate=$doNotSendPrivate" +
")" ")"
} }
companion object { companion object {

View File

@ -29,9 +29,9 @@ sealed class Emoji {
abstract fun id(): String abstract fun id(): String
override fun toString(): String { override fun toString(): String {
return "Emoji(" + return "Emoji(" +
"domain='$domain', " + "domain='$domain', " +
"name='$name'" + "name='$name'" +
")" ")"
} }
} }

View File

@ -84,13 +84,13 @@ class Filter(
override fun hashCode(): Int = id.hashCode() override fun hashCode(): Int = id.hashCode()
override fun toString(): String { override fun toString(): String {
return "Filter(" + return "Filter(" +
"id=$id, " + "id=$id, " +
"userDetailId=$userDetailId, " + "userDetailId=$userDetailId, " +
"name=$name, " + "name=$name, " +
"filterContext=$filterContext, " + "filterContext=$filterContext, " +
"filterAction=$filterAction, " + "filterAction=$filterAction, " +
"filterKeywords=$filterKeywords" + "filterKeywords=$filterKeywords" +
")" ")"
} }
companion object { companion object {

View File

@ -34,9 +34,9 @@ class FilterKeyword(
override fun toString(): String { override fun toString(): String {
return "FilterKeyword(" + return "FilterKeyword(" +
"id=$id, " + "id=$id, " +
"keyword=$keyword, " + "keyword=$keyword, " +
"mode=$mode" + "mode=$mode" +
")" ")"
} }
} }

View File

@ -33,8 +33,8 @@ class FilterName(name: String) {
override fun toString(): String { override fun toString(): String {
return "FilterName(" + return "FilterName(" +
"name='$name'" + "name='$name'" +
")" ")"
} }
companion object { companion object {

View File

@ -37,8 +37,8 @@ class FilterResult(val filter: Filter, val matchedKeyword: String) {
override fun toString(): String { override fun toString(): String {
return "FilterResult(" + return "FilterResult(" +
"filter=$filter, " + "filter=$filter, " +
"matchedKeyword='$matchedKeyword'" + "matchedKeyword='$matchedKeyword'" +
")" ")"
} }
} }

View File

@ -39,8 +39,8 @@ class FilteredPost(val post: Post, val filterResults: List<FilterResult>) {
override fun toString(): String { override fun toString(): String {
return "FilteredPost(" + return "FilteredPost(" +
"post=$post, " + "post=$post, " +
"filterResults=$filterResults" + "filterResults=$filterResults" +
")" ")"
} }
} }

View File

@ -52,16 +52,16 @@ class Media(
override fun toString(): String { override fun toString(): String {
return "Media(" + return "Media(" +
"id=$id, " + "id=$id, " +
"name=$name, " + "name=$name, " +
"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, " + "actorId=$actorId, " +
"url=$url" + "url=$url" +
")" ")"
} }
} }

View File

@ -241,25 +241,25 @@ class Post(
override fun toString(): String { override fun toString(): String {
return "Post(" + return "Post(" +
"id=$id, " + "id=$id, " +
"createdAt=$createdAt, " + "createdAt=$createdAt, " +
"url=$url, " + "url=$url, " +
"repostId=$repostId, " + "repostId=$repostId, " +
"replyId=$replyId, " + "replyId=$replyId, " +
"apId=$apId, " + "apId=$apId, " +
"actorId=$actorId, " + "actorId=$actorId, " +
"visibility=$visibility, " + "visibility=$visibility, " +
"visibleActors=$visibleActors, " + "visibleActors=$visibleActors, " +
"content=$content, " + "content=$content, " +
"overview=$overview, " + "overview=$overview, " +
"sensitive=$sensitive, " + "sensitive=$sensitive, " +
"text='$text', " + "text='$text', " +
"emojiIds=$emojiIds, " + "emojiIds=$emojiIds, " +
"mediaIds=$mediaIds, " + "mediaIds=$mediaIds, " +
"deleted=$deleted, " + "deleted=$deleted, " +
"hide=$hide, " + "hide=$hide, " +
"moveTo=$moveTo" + "moveTo=$moveTo" +
")" ")"
} }
companion object { companion object {

View File

@ -77,9 +77,9 @@ class TimelineObject(
lastUpdatedAt = Instant.now() lastUpdatedAt = Instant.now()
isPureRepost = isPureRepost =
post.repostId != null && post.repostId != null &&
post.replyId == null && post.replyId == null &&
post.text.isEmpty() && post.text.isEmpty() &&
post.overview?.overview.isNullOrEmpty() post.overview?.overview.isNullOrEmpty()
warnFilters = filterResults.map { TimelineObjectWarnFilter(it.filter.id, it.matchedKeyword) } warnFilters = filterResults.map { TimelineObjectWarnFilter(it.filter.id, it.matchedKeyword) }
} }
@ -149,9 +149,9 @@ class TimelineObject(
repostActorId = repost.actorId, repostActorId = repost.actorId,
visibility = post.visibility, visibility = post.visibility,
isPureRepost = repost.mediaIds.isEmpty() && isPureRepost = repost.mediaIds.isEmpty() &&
repost.overview == null && repost.overview == null &&
repost.content == PostContent.empty && repost.content == PostContent.empty &&
repost.replyId == null, repost.replyId == null,
mediaIds = post.mediaIds, mediaIds = post.mediaIds,
emojiIds = post.emojiIds, emojiIds = post.emojiIds,
visibleActors = post.visibleActors.toList(), visibleActors = post.visibleActors.toList(),

View File

@ -44,13 +44,13 @@ class UserDetail(
override fun hashCode(): Int = id.hashCode() override fun hashCode(): Int = id.hashCode()
override fun toString(): String { override fun toString(): String {
return "UserDetail(" + return "UserDetail(" +
"id=$id, " + "id=$id, " +
"actorId=$actorId, " + "actorId=$actorId, " +
"password=$password, " + "password=$password, " +
"autoAcceptFolloweeFollowRequest=$autoAcceptFolloweeFollowRequest, " + "autoAcceptFolloweeFollowRequest=$autoAcceptFolloweeFollowRequest, " +
"lastMigration=$lastMigration, " + "lastMigration=$lastMigration, " +
"homeTimelineId=$homeTimelineId" + "homeTimelineId=$homeTimelineId" +
")" ")"
} }
companion object { companion object {

View File

@ -39,9 +39,9 @@ class DefaultPostReadAccessControl(private val relationshipRepository: Relations
} }
val relationship = ( val relationship = (
relationshipRepository.findByActorIdAndTargetId(post.actorId, principal.actorId) relationshipRepository.findByActorIdAndTargetId(post.actorId, principal.actorId)
?: Relationship.default(post.actorId, principal.actorId) ?: Relationship.default(post.actorId, principal.actorId)
) )
// ブロックされてたら見れない // ブロックされてたら見れない
if (relationship.blocking) { if (relationship.blocking) {

View File

@ -53,16 +53,16 @@ class ExposedUserTimelineQueryService : UserTimelineQueryService, AbstractReposi
.select(Posts.columns) .select(Posts.columns)
.where { .where {
Posts.visibility eq Visibility.PUBLIC.name or Posts.visibility eq Visibility.PUBLIC.name or
(Posts.visibility eq Visibility.UNLISTED.name) or (Posts.visibility eq Visibility.UNLISTED.name) or
( (
Posts.visibility eq Visibility.DIRECT.name and Posts.visibility eq Visibility.DIRECT.name and
(PostsVisibleActors.actorId eq principal.actorId.id) (PostsVisibleActors.actorId eq principal.actorId.id)
) or ) or
( (
Posts.visibility eq Visibility.FOLLOWERS.name and Posts.visibility eq Visibility.FOLLOWERS.name and
(Relationships.blocking eq false and (relationshipsAlias[Relationships.following] eq true)) (Relationships.blocking eq false and (relationshipsAlias[Relationships.following] eq true))
) or ) or
(Posts.actorId eq principal.actorId.id) (Posts.actorId eq principal.actorId.id)
} }
.alias("authorized_table") .alias("authorized_table")
} }

View File

@ -54,7 +54,7 @@ class ExposedActorInstanceRelationshipRepository(override val domainEventPublish
query { query {
ActorInstanceRelationships.deleteWhere { ActorInstanceRelationships.deleteWhere {
actorId eq actorInstanceRelationship.actorId.id and actorId eq actorInstanceRelationship.actorId.id and
(instanceId eq actorInstanceRelationship.instanceId.instanceId) (instanceId eq actorInstanceRelationship.instanceId.instanceId)
} }
onComplete { onComplete {
update(actorInstanceRelationship) update(actorInstanceRelationship)
@ -70,7 +70,7 @@ class ExposedActorInstanceRelationshipRepository(override val domainEventPublish
.selectAll() .selectAll()
.where { .where {
ActorInstanceRelationships.actorId eq actorId.id and ActorInstanceRelationships.actorId eq actorId.id and
(ActorInstanceRelationships.instanceId eq instanceId.instanceId) (ActorInstanceRelationships.instanceId eq instanceId.instanceId)
} }
.limit(1) .limit(1)
.singleOrNull() .singleOrNull()

View File

@ -87,10 +87,10 @@ class ExposedRelationshipRepository(override val domainEventPublisher: DomainEve
): List<Relationship> = query { ): List<Relationship> = query {
Relationships.selectAll().where { Relationships.selectAll().where {
Relationships.actorId eq actorId.id and ( Relationships.actorId eq actorId.id and (
Relationships.targetActorId inList targetIds.map { Relationships.targetActorId inList targetIds.map {
it.id it.id
} }
) and (Relationships.following eq following) ) and (Relationships.following eq following)
}.map { it.toRelationships() } }.map { it.toRelationships() }
} }

View File

@ -70,11 +70,11 @@ class HideoutUserDetails(
override fun toString(): String { override fun toString(): String {
return "HideoutUserDetails(" + return "HideoutUserDetails(" +
"password='$password', " + "password='$password', " +
"username='$username', " + "username='$username', " +
"userDetailsId=$userDetailsId, " + "userDetailsId=$userDetailsId, " +
"authorities=$authorities" + "authorities=$authorities" +
")" ")"
} }
companion object { companion object {

View File

@ -262,8 +262,8 @@ abstract class AbstractTimelineStore(private val idGenerateService: IdGenerateSe
val actors = val actors =
getActors( getActors(
timelineObjectList.map { it.postActorId } + timelineObjectList.map { it.postActorId } +
timelineObjectList.mapNotNull { it.repostActorId } + timelineObjectList.mapNotNull { it.repostActorId } +
timelineObjectList.mapNotNull { it.replyActorId } timelineObjectList.mapNotNull { it.replyActorId }
) )
val postMap = posts.associate { post -> val postMap = posts.associate { post ->
@ -272,7 +272,7 @@ abstract class AbstractTimelineStore(private val idGenerateService: IdGenerateSe
val mediaMap = getMedias( val mediaMap = getMedias(
posts.flatMap { it.mediaIds } + posts.flatMap { it.mediaIds } +
actors.mapNotNull { it.value.icon } actors.mapNotNull { it.value.icon }
) )
val reactions = getReactions(posts.map { it.id }) val reactions = getReactions(posts.map { it.id })

View File

@ -59,10 +59,10 @@ class StatusQueryServiceImpl : StatusQueryService {
.select(Posts.columns) .select(Posts.columns)
.where { .where {
Posts.visibility eq Visibility.PUBLIC.name or Posts.visibility eq Visibility.PUBLIC.name or
(Posts.visibility eq Visibility.UNLISTED.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.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.visibility eq Visibility.FOLLOWERS.name and (Relationships.blocking eq false and (relationshipsAlias[Relationships.following] eq true))) or
(Posts.actorId eq principal.actorId.id) (Posts.actorId eq principal.actorId.id)
} }
.alias("authorized_table") .alias("authorized_table")
} }

View File

@ -66,8 +66,8 @@ class StatusesRequest {
override fun toString(): String { override fun toString(): String {
return "StatusesRequest(status=$status, mediaIds=$media_ids, poll=$poll, inReplyToId=$in_reply_to_id, " + return "StatusesRequest(status=$status, mediaIds=$media_ids, poll=$poll, inReplyToId=$in_reply_to_id, " +
"sensitive=$sensitive, spoilerText=$spoiler_text, visibility=$visibility, language=$language," + "sensitive=$sensitive, spoilerText=$spoiler_text, visibility=$visibility, language=$language," +
" scheduledAt=$scheduled_at)" " scheduledAt=$scheduled_at)"
} }
@Suppress("EnumNaming", "EnumEntryNameCase") @Suppress("EnumNaming", "EnumEntryNameCase")