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 {
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)
}
@ -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)
}
@ -114,6 +117,9 @@ export class ModerationDecision {
}
}
} else if (cause.type === 'mute-word') {
if (this.isMe) {
continue
}
if (context === 'contentList') {
ui.filters.push(cause)
}
@ -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') {

@ -536,14 +536,26 @@ 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": {
@ -551,21 +563,34 @@ const SCENARIOS: SuiteScenarios = {
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": {
@ -573,21 +598,33 @@ const SCENARIOS: SuiteScenarios = {
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': {