Skip to content

Commit

Permalink
Fix: correctly detect blocked QPs when moderating posts (#2338)
Browse files Browse the repository at this point in the history
* Fix: correctly detect blocked QPs when moderating posts

* Add changeset
  • Loading branch information
pfrazee authored Mar 18, 2024
1 parent f689bd5 commit 36f2e96
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/quiet-papayas-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@atproto/api': patch
---

Fix: correctly detected blocked quote-posts when moderating posts
34 changes: 34 additions & 0 deletions packages/api/src/moderation/subjects/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ export function decidePost(
) {
// quoted post with media
embedAcc = decideQuotedPost(subject.embed.record.record, opts)
} else if (AppBskyEmbedRecord.isViewBlocked(subject.embed.record)) {
// blocked quote post
embedAcc = decideBlockedQuotedPost(subject.embed.record, opts)
} else if (
AppBskyEmbedRecordWithMedia.isView(subject.embed) &&
AppBskyEmbedRecord.isViewBlocked(subject.embed.record.record)
) {
// blocked quoted post with media
embedAcc = decideBlockedQuotedPost(subject.embed.record.record, opts)
}
}

Expand Down Expand Up @@ -71,6 +80,31 @@ function decideQuotedPost(
)
}

function decideBlockedQuotedPost(
subject: AppBskyEmbedRecord.ViewBlocked,
opts: ModerationOpts,
) {
const acc = new ModerationDecision()
acc.setDid(subject.author.did)
acc.setIsMe(subject.author.did === opts.userDid)
if (subject.author.viewer?.muted) {
if (subject.author.viewer?.mutedByList) {
acc.addMutedByList(subject.author.viewer?.mutedByList)
} else {
acc.addMuted(subject.author.viewer?.muted)
}
}
if (subject.author.viewer?.blocking) {
if (subject.author.viewer?.blockingByList) {
acc.addBlockingByList(subject.author.viewer?.blockingByList)
} else {
acc.addBlocking(subject.author.viewer?.blocking)
}
}
acc.addBlockedBy(subject.author.viewer?.blockedBy)
return acc
}

function checkHiddenPost(
subject: ModerationSubjectPost,
hiddenPosts: string[] | undefined,
Expand Down

0 comments on commit 36f2e96

Please sign in to comment.