api: Always apply self labels even if post is your own, downgrade hide moderation preference to blur when the post is your own ()

* 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>
This commit is contained in:
Hailey 2024-05-08 18:42:56 -07:00 committed by GitHub
parent c812902107
commit f83b4c8cad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 62 additions and 14 deletions
.changeset
packages/api

@ -0,0 +1,5 @@
---
"@atproto/api": patch
---
Modify label-handling on user's own content to still apply blurring

@ -78,15 +78,15 @@ export class ModerationDecision {
ui(context: keyof ModerationBehavior): ModerationUI { ui(context: keyof ModerationBehavior): ModerationUI {
const ui = new ModerationUI() const ui = new ModerationUI()
if (this.isMe) {
return ui
}
for (const cause of this.causes) { for (const cause of this.causes) {
if ( if (
cause.type === 'blocking' || cause.type === 'blocking' ||
cause.type === 'blocked-by' || cause.type === 'blocked-by' ||
cause.type === 'block-other' cause.type === 'block-other'
) { ) {
if (this.isMe) {
continue
}
if (context === 'profileList' || context === 'contentList') { if (context === 'profileList' || context === 'contentList') {
ui.filters.push(cause) ui.filters.push(cause)
} }
@ -101,6 +101,9 @@ export class ModerationDecision {
} }
} }
} else if (cause.type === 'muted') { } else if (cause.type === 'muted') {
if (this.isMe) {
continue
}
if (context === 'profileList' || context === 'contentList') { if (context === 'profileList' || context === 'contentList') {
ui.filters.push(cause) ui.filters.push(cause)
} }
@ -114,6 +117,9 @@ export class ModerationDecision {
} }
} }
} else if (cause.type === 'mute-word') { } else if (cause.type === 'mute-word') {
if (this.isMe) {
continue
}
if (context === 'contentList') { if (context === 'contentList') {
ui.filters.push(cause) ui.filters.push(cause)
} }
@ -141,21 +147,21 @@ export class ModerationDecision {
} }
} else if (cause.type === 'label') { } else if (cause.type === 'label') {
if (context === 'profileList' && cause.target === 'account') { if (context === 'profileList' && cause.target === 'account') {
if (cause.setting === 'hide') { if (cause.setting === 'hide' && !this.isMe) {
ui.filters.push(cause) ui.filters.push(cause)
} }
} else if ( } else if (
context === 'contentList' && context === 'contentList' &&
(cause.target === 'account' || cause.target === 'content') (cause.target === 'account' || cause.target === 'content')
) { ) {
if (cause.setting === 'hide') { if (cause.setting === 'hide' && !this.isMe) {
ui.filters.push(cause) ui.filters.push(cause)
} }
} }
if (!cause.downgraded) { if (!cause.downgraded) {
if (cause.behavior[context] === 'blur') { if (cause.behavior[context] === 'blur') {
ui.blurs.push(cause) ui.blurs.push(cause)
if (cause.noOverride) { if (cause.noOverride && !this.isMe) {
ui.noOverride = true ui.noOverride = true
} }
} else if (cause.behavior[context] === 'alert') { } else if (cause.behavior[context] === 'alert') {

@ -536,14 +536,26 @@ const SCENARIOS: SuiteScenarios = {
subject: 'profile', subject: 'profile',
author: 'self', author: 'self',
labels: { account: ['!hide'] }, labels: { account: ['!hide'] },
behaviors: {}, behaviors: {
avatar: ['blur'],
banner: ['blur'],
displayName: ['blur'],
profileList: ['blur'],
profileView: ['blur'],
contentList: ['blur'],
contentView: ['blur'],
},
}, },
'Self-profile: !hide on profile': { 'Self-profile: !hide on profile': {
cfg: 'none', cfg: 'none',
subject: 'profile', subject: 'profile',
author: 'self', author: 'self',
labels: { profile: ['!hide'] }, labels: { profile: ['!hide'] },
behaviors: {}, behaviors: {
avatar: ['blur'],
banner: ['blur'],
displayName: ['blur'],
},
}, },
"Self-post: Imperative label ('!hide') on post": { "Self-post: Imperative label ('!hide') on post": {
@ -551,21 +563,34 @@ const SCENARIOS: SuiteScenarios = {
subject: 'post', subject: 'post',
author: 'self', author: 'self',
labels: { post: ['!hide'] }, labels: { post: ['!hide'] },
behaviors: {}, behaviors: {
contentView: ['blur'],
contentList: ['blur'],
},
}, },
"Self-post: Imperative label ('!hide') on author profile": { "Self-post: Imperative label ('!hide') on author profile": {
cfg: 'none', cfg: 'none',
subject: 'post', subject: 'post',
author: 'self', author: 'self',
labels: { profile: ['!hide'] }, labels: { profile: ['!hide'] },
behaviors: {}, behaviors: {
avatar: ['blur'],
banner: ['blur'],
displayName: ['blur'],
},
}, },
"Self-post: Imperative label ('!hide') on author account": { "Self-post: Imperative label ('!hide') on author account": {
cfg: 'none', cfg: 'none',
subject: 'post', subject: 'post',
author: 'self', author: 'self',
labels: { account: ['!hide'] }, labels: { account: ['!hide'] },
behaviors: {}, behaviors: {
avatar: ['blur'],
banner: ['blur'],
displayName: ['blur'],
contentList: ['blur'],
contentView: ['blur'],
},
}, },
"Self-post: Imperative label ('!warn') on post": { "Self-post: Imperative label ('!warn') on post": {
@ -573,21 +598,33 @@ const SCENARIOS: SuiteScenarios = {
subject: 'post', subject: 'post',
author: 'self', author: 'self',
labels: { post: ['!warn'] }, labels: { post: ['!warn'] },
behaviors: {}, behaviors: {
contentView: ['blur'],
contentList: ['blur'],
},
}, },
"Self-post: Imperative label ('!warn') on author profile": { "Self-post: Imperative label ('!warn') on author profile": {
cfg: 'none', cfg: 'none',
subject: 'post', subject: 'post',
author: 'self', author: 'self',
labels: { profile: ['!warn'] }, labels: { profile: ['!warn'] },
behaviors: {}, behaviors: {
avatar: ['blur'],
banner: ['blur'],
displayName: ['blur'],
},
}, },
"Self-post: Imperative label ('!warn') on author account": { "Self-post: Imperative label ('!warn') on author account": {
cfg: 'none', cfg: 'none',
subject: 'post', subject: 'post',
author: 'self', author: 'self',
labels: { account: ['!warn'] }, labels: { account: ['!warn'] },
behaviors: {}, behaviors: {
avatar: ['blur'],
banner: ['blur'],
contentList: ['blur'],
contentView: ['blur'],
},
}, },
'Mute/block: Blocking user': { 'Mute/block: Blocking user': {