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()
|
val cc: List<String> = emptyList()
|
||||||
) : Object(
|
) : Object(
|
||||||
type = add(type, "Announce")
|
type = add(type, "Announce")
|
||||||
), HasActor, HasId
|
),
|
||||||
|
HasActor,
|
||||||
|
HasId
|
|
@ -20,10 +20,10 @@ constructor(
|
||||||
val attachment: List<Document> = emptyList(),
|
val attachment: List<Document> = emptyList(),
|
||||||
@JsonDeserialize(contentUsing = ObjectDeserializer::class)
|
@JsonDeserialize(contentUsing = ObjectDeserializer::class)
|
||||||
val tag: List<Object> = emptyList(),
|
val tag: List<Object> = emptyList(),
|
||||||
val quoteUri:String? = null,
|
val quoteUri: String? = null,
|
||||||
val quoteUrl:String? = null,
|
val quoteUrl: String? = null,
|
||||||
@JsonProperty("_misskey_quote")
|
@JsonProperty("_misskey_quote")
|
||||||
val misskeyQuote:String? = null
|
val misskeyQuote: String? = null
|
||||||
) : Object(
|
) : Object(
|
||||||
type = add(type, "Note")
|
type = add(type, "Note")
|
||||||
),
|
),
|
||||||
|
|
|
@ -42,7 +42,7 @@ class ObjectDeserializer : JsonDeserializer<Object>() {
|
||||||
ExtendedActivityVocabulary.OrderedCollectionPage -> null
|
ExtendedActivityVocabulary.OrderedCollectionPage -> null
|
||||||
ExtendedActivityVocabulary.Accept -> p.codec.treeToValue(treeNode, Accept::class.java)
|
ExtendedActivityVocabulary.Accept -> p.codec.treeToValue(treeNode, Accept::class.java)
|
||||||
ExtendedActivityVocabulary.Add -> null
|
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.Arrive -> null
|
||||||
ExtendedActivityVocabulary.Block -> p.codec.treeToValue(treeNode, Block::class.java)
|
ExtendedActivityVocabulary.Block -> p.codec.treeToValue(treeNode, Block::class.java)
|
||||||
ExtendedActivityVocabulary.Create -> p.codec.treeToValue(treeNode, Create::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)) }
|
?.let { (it.toAnnounce() ?: return null) to (postResultRowMapper.map(it)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private suspend fun ResultRow.toAnnounce(): Announce? {
|
private suspend fun ResultRow.toAnnounce(): Announce? {
|
||||||
val repostId = this[Posts.repostId] ?: return null
|
val repostId = this[Posts.repostId] ?: return null
|
||||||
val repost = postRepository.findById(repostId)?.url ?: 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 repostId = this[Posts.repostId]
|
||||||
val repost = if (repostId != null) {
|
val repost = if (repostId != null) {
|
||||||
val url = postRepository.findById(repostId)?.url
|
val url = postRepository.findById(repostId)?.url
|
||||||
if (url == null){
|
if (url == null) {
|
||||||
logger.warn("Failed to get repostId: $repostId")
|
logger.warn("Failed to get repostId: $repostId")
|
||||||
}
|
}
|
||||||
url
|
url
|
||||||
}else{
|
}
|
||||||
|
else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import dev.usbharu.hideout.application.external.Transaction
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
class ApAnnounceProcessor(transaction: Transaction,private val apNoteService:APNoteService) :
|
class ApAnnounceProcessor(transaction: Transaction, private val apNoteService: APNoteService) :
|
||||||
AbstractActivityPubProcessor<Announce>(transaction) {
|
AbstractActivityPubProcessor<Announce>(transaction) {
|
||||||
override suspend fun internalProcess(activity: ActivityPubProcessContext<Announce>) {
|
override suspend fun internalProcess(activity: ActivityPubProcessContext<Announce>) {
|
||||||
apNoteService.fetchAnnounce(activity.activity)
|
apNoteService.fetchAnnounce(activity.activity)
|
||||||
|
|
|
@ -100,7 +100,6 @@ class APNoteServiceImpl(
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun fetchAnnounce(announce: Announce, signerId: Long?): Pair<Announce, Post> {
|
override suspend fun fetchAnnounce(announce: Announce, signerId: Long?): Pair<Announce, Post> {
|
||||||
|
|
||||||
val findByApId = announceQueryService.findByApId(announce.id)
|
val findByApId = announceQueryService.findByApId(announce.id)
|
||||||
|
|
||||||
if (findByApId != null) {
|
if (findByApId != null) {
|
||||||
|
@ -227,7 +226,6 @@ class APNoteServiceImpl(
|
||||||
mediaIds = mediaList,
|
mediaIds = mediaList,
|
||||||
emojiIds = emojis
|
emojiIds = emojis
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val createRemote = postService.createRemote(
|
val createRemote = postService.createRemote(
|
||||||
|
|
|
@ -177,8 +177,8 @@ data class Actor private constructor(
|
||||||
following = following,
|
following = following,
|
||||||
instance = instance,
|
instance = instance,
|
||||||
locked = locked,
|
locked = locked,
|
||||||
followersCount = max(0,followersCount),
|
followersCount = max(0, followersCount),
|
||||||
followingCount = max(0,followingCount),
|
followingCount = max(0, followingCount),
|
||||||
postsCount = max(0, postsCount),
|
postsCount = max(0, postsCount),
|
||||||
lastPostDate = lastPostDate,
|
lastPostDate = lastPostDate,
|
||||||
emojis = emojis
|
emojis = emojis
|
||||||
|
|
|
@ -98,7 +98,6 @@ data class Post private constructor(
|
||||||
repost: Post,
|
repost: Post,
|
||||||
apId: String
|
apId: String
|
||||||
): Post {
|
): Post {
|
||||||
|
|
||||||
// リポストの公開範囲は元のポストより広くてはいけない
|
// リポストの公開範囲は元のポストより広くてはいけない
|
||||||
val fixedVisibility = if (visibility.ordinal <= repost.visibility.ordinal) {
|
val fixedVisibility = if (visibility.ordinal <= repost.visibility.ordinal) {
|
||||||
repost.visibility
|
repost.visibility
|
||||||
|
@ -110,7 +109,6 @@ data class Post private constructor(
|
||||||
|
|
||||||
require(actorId >= 0) { "actorId must be greater than or equal to 0." }
|
require(actorId >= 0) { "actorId must be greater than or equal to 0." }
|
||||||
|
|
||||||
|
|
||||||
return Post(
|
return Post(
|
||||||
id,
|
id,
|
||||||
actorId,
|
actorId,
|
||||||
|
@ -138,14 +136,13 @@ data class Post private constructor(
|
||||||
createdAt: Instant,
|
createdAt: Instant,
|
||||||
visibility: Visibility,
|
visibility: Visibility,
|
||||||
url: String,
|
url: String,
|
||||||
repost:Post,
|
repost: Post,
|
||||||
replyId: Long? = null,
|
replyId: Long? = null,
|
||||||
sensitive: Boolean = false,
|
sensitive: Boolean = false,
|
||||||
apId: String = url,
|
apId: String = url,
|
||||||
mediaIds: List<Long> = emptyList(),
|
mediaIds: List<Long> = emptyList(),
|
||||||
emojiIds: List<Long> = emptyList()
|
emojiIds: List<Long> = emptyList()
|
||||||
): Post {
|
): Post {
|
||||||
|
|
||||||
// リポストの公開範囲は元のポストより広くてはいけない
|
// リポストの公開範囲は元のポストより広くてはいけない
|
||||||
val fixedVisibility = if (visibility.ordinal <= repost.visibility.ordinal) {
|
val fixedVisibility = if (visibility.ordinal <= repost.visibility.ordinal) {
|
||||||
repost.visibility
|
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
|
this.text.isEmpty() && this.content.isEmpty() && this.overview == null && this.replyId == null && this.repostId != null
|
||||||
|
|
||||||
fun delete(): Post {
|
fun delete(): Post {
|
||||||
|
|
Loading…
Reference in New Issue