mirror of https://github.com/usbharu/Hideout.git
Apply suggestions from code review
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
35d126703b
commit
7b9ef770da
|
@ -15,4 +15,6 @@ open class Announce @JsonCreator constructor(
|
|||
val cc: List<String> = emptyList()
|
||||
) : Object(
|
||||
type = add(type, "Announce")
|
||||
), HasActor, HasId
|
||||
),
|
||||
HasActor,
|
||||
HasId
|
|
@ -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()}"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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" +
|
||||
")"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue