Apply suggestions from code review

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
usbharu 2024-02-03 16:15:27 +09:00 committed by GitHub
parent 35d126703b
commit 7b9ef770da
9 changed files with 52 additions and 55 deletions

View File

@ -15,4 +15,6 @@ open class Announce @JsonCreator constructor(
val cc: List<String> = emptyList()
) : Object(
type = add(type, "Announce")
), HasActor, HasId
),
HasActor,
HasId

View File

@ -20,10 +20,10 @@ constructor(
val attachment: List<Document> = emptyList(),
@JsonDeserialize(contentUsing = ObjectDeserializer::class)
val tag: List<Object> = 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()}"
}
}

View File

@ -42,7 +42,7 @@ class ObjectDeserializer : JsonDeserializer<Object>() {
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)

View File

@ -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

View File

@ -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
}

View File

@ -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<Announce>(transaction) {
override suspend fun internalProcess(activity: ActivityPubProcessContext<Announce>) {
apNoteService.fetchAnnounce(activity.activity)

View File

@ -100,7 +100,6 @@ class APNoteServiceImpl(
}
override suspend fun fetchAnnounce(announce: Announce, signerId: Long?): Pair<Announce, Post> {
val findByApId = announceQueryService.findByApId(announce.id)
if (findByApId != null) {
@ -227,7 +226,6 @@ class APNoteServiceImpl(
mediaIds = mediaList,
emojiIds = emojis
)
}
val createRemote = postService.createRemote(

View File

@ -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" +
")"
}
}

View File

@ -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<Long> = emptyList(),
emojiIds: List<Long> = 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 {