diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Announce.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Announce.kt index e65a996d..54fd40f1 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Announce.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Announce.kt @@ -15,4 +15,6 @@ open class Announce @JsonCreator constructor( val cc: List = emptyList() ) : Object( type = add(type, "Announce") -), HasActor, HasId \ No newline at end of file +), + HasActor, + HasId \ No newline at end of file diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Note.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Note.kt index ba888274..04910b09 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Note.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Note.kt @@ -20,10 +20,10 @@ constructor( val attachment: List = emptyList(), @JsonDeserialize(contentUsing = ObjectDeserializer::class) val tag: List = emptyList(), - val quoteUri:String? = null, - val quoteUrl:String? = null, + val quoteUri: String? = null, + val quoteUrl: String? = null, @JsonProperty("_misskey_quote") - val misskeyQuote:String? = null + val misskeyQuote: String? = null ) : Object( type = add(type, "Note") ), @@ -72,20 +72,20 @@ constructor( override fun toString(): String { return "Note(" + - "id='$id', " + - "attributedTo='$attributedTo', " + - "content='$content', " + - "published='$published', " + - "to=$to, " + - "cc=$cc, " + - "sensitive=$sensitive, " + - "inReplyTo=$inReplyTo, " + - "attachment=$attachment, " + - "tag=$tag, " + - "quoteUri=$quoteUri, " + - "quoteUrl=$quoteUrl, " + - "misskeyQuote=$misskeyQuote" + - ")" + - " ${super.toString()}" + "id='$id', " + + "attributedTo='$attributedTo', " + + "content='$content', " + + "published='$published', " + + "to=$to, " + + "cc=$cc, " + + "sensitive=$sensitive, " + + "inReplyTo=$inReplyTo, " + + "attachment=$attachment, " + + "tag=$tag, " + + "quoteUri=$quoteUri, " + + "quoteUrl=$quoteUrl, " + + "misskeyQuote=$misskeyQuote" + + ")" + + " ${super.toString()}" } } diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/objects/ObjectDeserializer.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/objects/ObjectDeserializer.kt index 5867cd4c..781857d3 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/objects/ObjectDeserializer.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/objects/ObjectDeserializer.kt @@ -42,7 +42,7 @@ class ObjectDeserializer : JsonDeserializer() { ExtendedActivityVocabulary.OrderedCollectionPage -> null ExtendedActivityVocabulary.Accept -> p.codec.treeToValue(treeNode, Accept::class.java) ExtendedActivityVocabulary.Add -> null - ExtendedActivityVocabulary.Announce -> p.codec.treeToValue(treeNode,Announce::class.java) + ExtendedActivityVocabulary.Announce -> p.codec.treeToValue(treeNode, Announce::class.java) ExtendedActivityVocabulary.Arrive -> null ExtendedActivityVocabulary.Block -> p.codec.treeToValue(treeNode, Block::class.java) ExtendedActivityVocabulary.Create -> p.codec.treeToValue(treeNode, Create::class.java) diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/infrastructure/exposedquery/ExposedAnnounceQueryService.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/infrastructure/exposedquery/ExposedAnnounceQueryService.kt index 1921be1b..9051e61f 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/infrastructure/exposedquery/ExposedAnnounceQueryService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/infrastructure/exposedquery/ExposedAnnounceQueryService.kt @@ -35,7 +35,6 @@ class ExposedAnnounceQueryService( ?.let { (it.toAnnounce() ?: return null) to (postResultRowMapper.map(it)) } } - private suspend fun ResultRow.toAnnounce(): Announce? { val repostId = this[Posts.repostId] ?: return null val repost = postRepository.findById(repostId)?.url ?: return null diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/infrastructure/exposedquery/NoteQueryServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/infrastructure/exposedquery/NoteQueryServiceImpl.kt index 00dd9167..fa4b99f6 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/infrastructure/exposedquery/NoteQueryServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/infrastructure/exposedquery/NoteQueryServiceImpl.kt @@ -62,11 +62,12 @@ class NoteQueryServiceImpl(private val postRepository: PostRepository, private v val repostId = this[Posts.repostId] val repost = if (repostId != null) { val url = postRepository.findById(repostId)?.url - if (url == null){ + if (url == null) { logger.warn("Failed to get repostId: $repostId") } url - }else{ + } + else { null } diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/announce/ApAnnounceProcessor.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/announce/ApAnnounceProcessor.kt index 8d803503..a4d74f66 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/announce/ApAnnounceProcessor.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/announce/ApAnnounceProcessor.kt @@ -9,7 +9,7 @@ import dev.usbharu.hideout.application.external.Transaction import org.springframework.stereotype.Service @Service -class ApAnnounceProcessor(transaction: Transaction,private val apNoteService:APNoteService) : +class ApAnnounceProcessor(transaction: Transaction, private val apNoteService: APNoteService) : AbstractActivityPubProcessor(transaction) { override suspend fun internalProcess(activity: ActivityPubProcessContext) { apNoteService.fetchAnnounce(activity.activity) diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/objects/note/APNoteService.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/objects/note/APNoteService.kt index fb2b22ba..df39051a 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/objects/note/APNoteService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/objects/note/APNoteService.kt @@ -100,7 +100,6 @@ class APNoteServiceImpl( } override suspend fun fetchAnnounce(announce: Announce, signerId: Long?): Pair { - val findByApId = announceQueryService.findByApId(announce.id) if (findByApId != null) { @@ -227,7 +226,6 @@ class APNoteServiceImpl( mediaIds = mediaList, emojiIds = emojis ) - } val createRemote = postService.createRemote( diff --git a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt index e488d86b..59f16059 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt @@ -177,8 +177,8 @@ data class Actor private constructor( following = following, instance = instance, locked = locked, - followersCount = max(0,followersCount), - followingCount = max(0,followingCount), + followersCount = max(0, followersCount), + followingCount = max(0, followingCount), postsCount = max(0, postsCount), lastPostDate = lastPostDate, emojis = emojis @@ -201,27 +201,27 @@ data class Actor private constructor( fun withLastPostAt(lastPostDate: Instant): Actor = this.copy(lastPostDate = lastPostDate) override fun toString(): String { return "Actor(" + - "id=$id, " + - "name='$name', " + - "domain='$domain', " + - "screenName='$screenName', " + - "description='$description', " + - "inbox='$inbox', " + - "outbox='$outbox', " + - "url='$url', " + - "publicKey='$publicKey', " + - "privateKey=$privateKey, " + - "createdAt=$createdAt, " + - "keyId='$keyId', " + - "followers=$followers, " + - "following=$following, " + - "instance=$instance, " + - "locked=$locked, " + - "followersCount=$followersCount, " + - "followingCount=$followingCount, " + - "postsCount=$postsCount, " + - "lastPostDate=$lastPostDate, " + - "emojis=$emojis" + - ")" + "id=$id, " + + "name='$name', " + + "domain='$domain', " + + "screenName='$screenName', " + + "description='$description', " + + "inbox='$inbox', " + + "outbox='$outbox', " + + "url='$url', " + + "publicKey='$publicKey', " + + "privateKey=$privateKey, " + + "createdAt=$createdAt, " + + "keyId='$keyId', " + + "followers=$followers, " + + "following=$following, " + + "instance=$instance, " + + "locked=$locked, " + + "followersCount=$followersCount, " + + "followingCount=$followingCount, " + + "postsCount=$postsCount, " + + "lastPostDate=$lastPostDate, " + + "emojis=$emojis" + + ")" } } diff --git a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/post/Post.kt b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/post/Post.kt index f50e879b..c5d905e4 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/post/Post.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/post/Post.kt @@ -98,7 +98,6 @@ data class Post private constructor( repost: Post, apId: String ): Post { - // リポストの公開範囲は元のポストより広くてはいけない val fixedVisibility = if (visibility.ordinal <= repost.visibility.ordinal) { repost.visibility @@ -110,7 +109,6 @@ data class Post private constructor( require(actorId >= 0) { "actorId must be greater than or equal to 0." } - return Post( id, actorId, @@ -138,14 +136,13 @@ data class Post private constructor( createdAt: Instant, visibility: Visibility, url: String, - repost:Post, + repost: Post, replyId: Long? = null, sensitive: Boolean = false, apId: String = url, mediaIds: List = emptyList(), emojiIds: List = emptyList() ): Post { - // リポストの公開範囲は元のポストより広くてはいけない val fixedVisibility = if (visibility.ordinal <= repost.visibility.ordinal) { repost.visibility @@ -225,7 +222,7 @@ data class Post private constructor( } } - fun isPureRepost():Boolean = + fun isPureRepost(): Boolean = this.text.isEmpty() && this.content.isEmpty() && this.overview == null && this.replyId == null && this.repostId != null fun delete(): Post {