diff --git a/packages/api/src/moderation/decision.ts b/packages/api/src/moderation/decision.ts index 0a072bd516e..a1884c61848 100644 --- a/packages/api/src/moderation/decision.ts +++ b/packages/api/src/moderation/decision.ts @@ -113,7 +113,14 @@ export class ModerationDecision { ui.informs.push(cause) } } else if (cause.type === 'label') { - if (context === 'profileList' || context === 'contentList') { + if (context === 'profileList' && cause.target === 'account') { + if (cause.setting === 'hide') { + ui.filters.push(cause) + } + } else if ( + context === 'contentList' && + (cause.target === 'account' || cause.target === 'content') + ) { if (cause.setting === 'hide') { ui.filters.push(cause) } @@ -298,6 +305,7 @@ export class ModerationDecision { : { type: 'labeler', did: labeler.did }, label, labelDef, + target, setting: labelPref, behavior: labelDef.behaviors[target] || NOOP_BEHAVIOR, noOverride, diff --git a/packages/api/src/moderation/types.ts b/packages/api/src/moderation/types.ts index 6f662049283..4c5f43c345f 100644 --- a/packages/api/src/moderation/types.ts +++ b/packages/api/src/moderation/types.ts @@ -119,6 +119,7 @@ export type ModerationCause = source: ModerationCauseSource label: Label labelDef: InterpretedLabelValueDefinition + target: LabelTarget setting: LabelPreference behavior: ModerationBehavior noOverride: boolean diff --git a/packages/api/src/moderation/util.ts b/packages/api/src/moderation/util.ts index afb0bc474e0..2e66bc47730 100644 --- a/packages/api/src/moderation/util.ts +++ b/packages/api/src/moderation/util.ts @@ -47,10 +47,8 @@ export function interpretLabelValueDefinition( behaviors.account.contentList = 'blur' behaviors.account.contentView = def.adultOnly ? 'blur' : alertOrInform // target=profile, blurs=content - behaviors.account.profileView = alertOrInform - behaviors.profile.avatar = 'blur' - behaviors.profile.banner = 'blur' - behaviors.profile.displayName = 'blur' + behaviors.profile.profileList = alertOrInform + behaviors.profile.profileView = alertOrInform // target=content, blurs=content behaviors.content.contentList = 'blur' behaviors.content.contentView = def.adultOnly ? 'blur' : alertOrInform @@ -62,6 +60,7 @@ export function interpretLabelValueDefinition( behaviors.account.banner = 'blur' behaviors.account.contentMedia = 'blur' // target=profile, blurs=media + behaviors.profile.profileList = alertOrInform behaviors.profile.profileView = alertOrInform behaviors.profile.avatar = 'blur' behaviors.profile.banner = 'blur' @@ -74,6 +73,7 @@ export function interpretLabelValueDefinition( behaviors.account.contentList = alertOrInform behaviors.account.contentView = alertOrInform // target=profile, blurs=none + behaviors.profile.profileList = alertOrInform behaviors.profile.profileView = alertOrInform // target=content, blurs=none behaviors.content.contentList = alertOrInform diff --git a/packages/api/tests/moderation-behaviors.test.ts b/packages/api/tests/moderation-behaviors.test.ts index 68ae09983b8..686956fd6ae 100644 --- a/packages/api/tests/moderation-behaviors.test.ts +++ b/packages/api/tests/moderation-behaviors.test.ts @@ -129,11 +129,9 @@ const SCENARIOS: SuiteScenarios = { author: 'alice', labels: { profile: ['!hide'] }, behaviors: { - profileList: ['filter'], avatar: ['blur', 'noOverride'], banner: ['blur', 'noOverride'], displayName: ['blur', 'noOverride'], - contentList: ['filter'], }, }, "Imperative label ('!hide') on post": { @@ -155,7 +153,6 @@ const SCENARIOS: SuiteScenarios = { avatar: ['blur', 'noOverride'], banner: ['blur', 'noOverride'], displayName: ['blur', 'noOverride'], - contentList: ['filter'], }, }, "Imperative label ('!hide') on author account": { @@ -354,10 +351,8 @@ const SCENARIOS: SuiteScenarios = { author: 'alice', labels: { profile: ['porn'] }, behaviors: { - profileList: ['filter'], avatar: ['blur'], banner: ['blur'], - contentList: ['filter'], }, }, "Blur-media label ('porn') on post (hide)": { @@ -378,7 +373,6 @@ const SCENARIOS: SuiteScenarios = { behaviors: { avatar: ['blur'], banner: ['blur'], - contentList: ['filter'], }, }, "Blur-media label ('porn') on author account (hide)": { @@ -498,10 +492,10 @@ const SCENARIOS: SuiteScenarios = { author: 'alice', labels: { profile: ['porn'] }, behaviors: { - profileList: ['filter'], + profileList: [], avatar: ['blur', 'noOverride'], banner: ['blur', 'noOverride'], - contentList: ['filter'], + contentList: [], }, }, 'Adult-only label on post when adult content is disabled': { @@ -522,7 +516,7 @@ const SCENARIOS: SuiteScenarios = { behaviors: { avatar: ['blur', 'noOverride'], banner: ['blur', 'noOverride'], - contentList: ['filter'], + contentList: [], }, }, 'Adult-only label on author account when adult content is disabled': { @@ -793,12 +787,12 @@ const SCENARIOS: SuiteScenarios = { author: 'alice', labels: { account: ['!warn'], profile: ['!hide'] }, behaviors: { - profileList: ['filter', 'blur'], + profileList: ['blur'], profileView: ['blur'], avatar: ['blur', 'noOverride'], banner: ['blur', 'noOverride'], displayName: ['blur', 'noOverride'], - contentList: ['filter', 'blur'], + contentList: ['blur'], contentView: ['blur'], }, }, diff --git a/packages/api/tests/moderation-custom-labels.test.ts b/packages/api/tests/moderation-custom-labels.test.ts index f9054e246ce..48c4158d50a 100644 --- a/packages/api/tests/moderation-custom-labels.test.ts +++ b/packages/api/tests/moderation-custom-labels.test.ts @@ -38,14 +38,10 @@ const TESTS: Scenario[] = [ contentView: ['alert'], }, profile: { - profileList: ['filter'], - avatar: ['blur'], - banner: ['blur'], - displayName: ['blur'], - contentList: ['filter'], + profileList: ['alert'], + profileView: ['alert'], }, post: { - profileList: ['filter'], contentList: ['filter', 'blur'], contentView: ['alert'], }, @@ -60,14 +56,10 @@ const TESTS: Scenario[] = [ contentView: ['inform'], }, profile: { - profileList: ['filter'], - avatar: ['blur'], - banner: ['blur'], - displayName: ['blur'], - contentList: ['filter'], + profileList: ['inform'], + profileView: ['inform'], }, post: { - profileList: ['filter'], contentList: ['filter', 'blur'], contentView: ['inform'], }, @@ -82,14 +74,10 @@ const TESTS: Scenario[] = [ contentView: [], }, profile: { - profileList: ['filter'], - avatar: ['blur'], - banner: ['blur'], - displayName: ['blur'], - contentList: ['filter'], + profileList: [], + profileView: [], }, post: { - profileList: ['filter'], contentList: ['filter', 'blur'], contentView: [], }, @@ -107,14 +95,12 @@ const TESTS: Scenario[] = [ contentMedia: ['blur'], }, profile: { - profileList: ['filter'], + profileList: ['alert'], profileView: ['alert'], avatar: ['blur'], banner: ['blur'], - contentList: ['filter'], }, post: { - profileList: ['filter'], contentList: ['filter'], contentMedia: ['blur'], }, @@ -131,14 +117,12 @@ const TESTS: Scenario[] = [ contentMedia: ['blur'], }, profile: { - profileList: ['filter'], + profileList: ['inform'], profileView: ['inform'], avatar: ['blur'], banner: ['blur'], - contentList: ['filter'], }, post: { - profileList: ['filter'], contentList: ['filter'], contentMedia: ['blur'], }, @@ -154,13 +138,10 @@ const TESTS: Scenario[] = [ contentMedia: ['blur'], }, profile: { - profileList: ['filter'], avatar: ['blur'], banner: ['blur'], - contentList: ['filter'], }, post: { - profileList: ['filter'], contentList: ['filter'], contentMedia: ['blur'], }, @@ -176,12 +157,10 @@ const TESTS: Scenario[] = [ contentView: ['alert'], }, profile: { - profileList: ['filter'], + profileList: ['alert'], profileView: ['alert'], - contentList: ['filter'], }, post: { - profileList: ['filter'], contentList: ['filter', 'alert'], contentView: ['alert'], }, @@ -196,12 +175,10 @@ const TESTS: Scenario[] = [ contentView: ['inform'], }, profile: { - profileList: ['filter'], + profileList: ['inform'], profileView: ['inform'], - contentList: ['filter'], }, post: { - profileList: ['filter'], contentList: ['filter', 'inform'], contentView: ['inform'], }, @@ -213,12 +190,8 @@ const TESTS: Scenario[] = [ profileList: ['filter'], contentList: ['filter'], }, - profile: { - profileList: ['filter'], - contentList: ['filter'], - }, + profile: {}, post: { - profileList: ['filter'], contentList: ['filter'], }, }, @@ -300,27 +273,27 @@ describe('Moderation: custom labels', () => { }), modOpts(blurs, severity), ) - expect(res.ui('profileList')).toBeModerationResult( - expected.profileList || [], - ) - expect(res.ui('profileView')).toBeModerationResult( - expected.profileView || [], - ) - expect(res.ui('avatar')).toBeModerationResult(expected.avatar || []) - expect(res.ui('banner')).toBeModerationResult(expected.banner || []) - expect(res.ui('displayName')).toBeModerationResult( - expected.displayName || [], - ) - expect(res.ui('contentList')).toBeModerationResult( - expected.contentList || [], - ) - expect(res.ui('contentView')).toBeModerationResult( - expected.contentView || [], - ) - expect(res.ui('contentMedia')).toBeModerationResult( - expected.contentMedia || [], - ) } + expect(res.ui('profileList')).toBeModerationResult( + expected.profileList || [], + ) + expect(res.ui('profileView')).toBeModerationResult( + expected.profileView || [], + ) + expect(res.ui('avatar')).toBeModerationResult(expected.avatar || []) + expect(res.ui('banner')).toBeModerationResult(expected.banner || []) + expect(res.ui('displayName')).toBeModerationResult( + expected.displayName || [], + ) + expect(res.ui('contentList')).toBeModerationResult( + expected.contentList || [], + ) + expect(res.ui('contentView')).toBeModerationResult( + expected.contentView || [], + ) + expect(res.ui('contentMedia')).toBeModerationResult( + expected.contentMedia || [], + ) }, ) }) diff --git a/packages/api/tests/moderation.test.ts b/packages/api/tests/moderation.test.ts index 6d4cc998ed0..8b84afab699 100644 --- a/packages/api/tests/moderation.test.ts +++ b/packages/api/tests/moderation.test.ts @@ -354,7 +354,7 @@ describe('Moderation', () => { modOpts, ) - expect(res.ui('profileList')).toBeModerationResult(['filter']) + expect(res.ui('profileList')).toBeModerationResult([]) expect(res.ui('profileView')).toBeModerationResult([]) expect(res.ui('avatar')).toBeModerationResult([]) expect(res.ui('banner')).toBeModerationResult([]) @@ -512,7 +512,7 @@ describe('Moderation', () => { modOpts, ) - expect(res1.ui('profileList')).toBeModerationResult(['filter']) + expect(res1.ui('profileList')).toBeModerationResult([]) expect(res1.ui('profileView')).toBeModerationResult([]) expect(res1.ui('avatar')).toBeModerationResult([]) expect(res1.ui('banner')).toBeModerationResult([]) @@ -637,7 +637,7 @@ describe('Moderation', () => { modOpts, ) - expect(res.ui('profileList')).toBeModerationResult(['filter']) + expect(res.ui('profileList')).toBeModerationResult([]) expect(res.ui('profileView')).toBeModerationResult([]) expect(res.ui('avatar')).toBeModerationResult([]) expect(res.ui('banner')).toBeModerationResult([])