Skip to content

Commit

Permalink
api: Always apply self labels even if post is your own, downgrade `hi…
Browse files Browse the repository at this point in the history
…de` moderation preference to `blur` when the post is your own (#2467)

* always show your post even if it's labeled

still apply to `contentMedia`

update tests

only apply to posts and `contentView`

add a comment

always show your post even if it's labeled

* Tweak to use a more consistent approach

* Add changeset

---------

Co-authored-by: Paul Frazee <pfrazee@gmail.com>
  • Loading branch information
haileyok and pfrazee committed May 9, 2024
1 parent c812902 commit f83b4c8
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/clever-trainers-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/api": patch
---

Modify label-handling on user's own content to still apply blurring
18 changes: 12 additions & 6 deletions packages/api/src/moderation/decision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ export class ModerationDecision {

ui(context: keyof ModerationBehavior): ModerationUI {
const ui = new ModerationUI()
if (this.isMe) {
return ui
}
for (const cause of this.causes) {
if (
cause.type === 'blocking' ||
cause.type === 'blocked-by' ||
cause.type === 'block-other'
) {
if (this.isMe) {
continue
}
if (context === 'profileList' || context === 'contentList') {
ui.filters.push(cause)
}
Expand All @@ -101,6 +101,9 @@ export class ModerationDecision {
}
}
} else if (cause.type === 'muted') {
if (this.isMe) {
continue
}
if (context === 'profileList' || context === 'contentList') {
ui.filters.push(cause)
}
Expand All @@ -114,6 +117,9 @@ export class ModerationDecision {
}
}
} else if (cause.type === 'mute-word') {
if (this.isMe) {
continue
}
if (context === 'contentList') {
ui.filters.push(cause)
}
Expand Down Expand Up @@ -141,21 +147,21 @@ export class ModerationDecision {
}
} else if (cause.type === 'label') {
if (context === 'profileList' && cause.target === 'account') {
if (cause.setting === 'hide') {
if (cause.setting === 'hide' && !this.isMe) {
ui.filters.push(cause)
}
} else if (
context === 'contentList' &&
(cause.target === 'account' || cause.target === 'content')
) {
if (cause.setting === 'hide') {
if (cause.setting === 'hide' && !this.isMe) {
ui.filters.push(cause)
}
}
if (!cause.downgraded) {
if (cause.behavior[context] === 'blur') {
ui.blurs.push(cause)
if (cause.noOverride) {
if (cause.noOverride && !this.isMe) {
ui.noOverride = true
}
} else if (cause.behavior[context] === 'alert') {
Expand Down
53 changes: 45 additions & 8 deletions packages/api/tests/moderation-behaviors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,58 +536,95 @@ const SCENARIOS: SuiteScenarios = {
subject: 'profile',
author: 'self',
labels: { account: ['!hide'] },
behaviors: {},
behaviors: {
avatar: ['blur'],
banner: ['blur'],
displayName: ['blur'],
profileList: ['blur'],
profileView: ['blur'],
contentList: ['blur'],
contentView: ['blur'],
},
},
'Self-profile: !hide on profile': {
cfg: 'none',
subject: 'profile',
author: 'self',
labels: { profile: ['!hide'] },
behaviors: {},
behaviors: {
avatar: ['blur'],
banner: ['blur'],
displayName: ['blur'],
},
},

"Self-post: Imperative label ('!hide') on post": {
cfg: 'none',
subject: 'post',
author: 'self',
labels: { post: ['!hide'] },
behaviors: {},
behaviors: {
contentView: ['blur'],
contentList: ['blur'],
},
},
"Self-post: Imperative label ('!hide') on author profile": {
cfg: 'none',
subject: 'post',
author: 'self',
labels: { profile: ['!hide'] },
behaviors: {},
behaviors: {
avatar: ['blur'],
banner: ['blur'],
displayName: ['blur'],
},
},
"Self-post: Imperative label ('!hide') on author account": {
cfg: 'none',
subject: 'post',
author: 'self',
labels: { account: ['!hide'] },
behaviors: {},
behaviors: {
avatar: ['blur'],
banner: ['blur'],
displayName: ['blur'],
contentList: ['blur'],
contentView: ['blur'],
},
},

"Self-post: Imperative label ('!warn') on post": {
cfg: 'none',
subject: 'post',
author: 'self',
labels: { post: ['!warn'] },
behaviors: {},
behaviors: {
contentView: ['blur'],
contentList: ['blur'],
},
},
"Self-post: Imperative label ('!warn') on author profile": {
cfg: 'none',
subject: 'post',
author: 'self',
labels: { profile: ['!warn'] },
behaviors: {},
behaviors: {
avatar: ['blur'],
banner: ['blur'],
displayName: ['blur'],
},
},
"Self-post: Imperative label ('!warn') on author account": {
cfg: 'none',
subject: 'post',
author: 'self',
labels: { account: ['!warn'] },
behaviors: {},
behaviors: {
avatar: ['blur'],
banner: ['blur'],
contentList: ['blur'],
contentView: ['blur'],
},
},

'Mute/block: Blocking user': {
Expand Down

0 comments on commit f83b4c8

Please sign in to comment.