Add the !filter and !warn imperative labels (#580)

zio/stable
Paul Frazee 2023-05-04 00:55:33 -05:00 committed by GitHub
parent 33bf9c3869
commit ab3074fdee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 99 additions and 3 deletions

View File

@ -84,6 +84,12 @@ async function main() {
'unknown-account',
'unknown-profile',
'unknown-posts',
'always-filter-account',
'always-filter-profile',
'always-filter-posts',
'always-warn-account',
'always-warn-profile',
'always-warn-posts',
'muted-account',
]) {
await server.mocker.createUser(user)
@ -196,6 +202,58 @@ async function main() {
),
)
await server.mocker.labelAccount('!filter', 'always-filter-account')
await server.mocker.labelProfile('!filter', 'always-filter-profile')
await server.mocker.labelPost(
'!filter',
await server.mocker.createPost(
'always-filter-posts',
'always-filter post',
),
)
await server.mocker.labelPost(
'!filter',
await server.mocker.createQuotePost(
'always-filter-posts',
'always-filter quote post',
anchorPost,
),
)
await server.mocker.labelPost(
'!filter',
await server.mocker.createReply(
'always-filter-posts',
'always-filter reply',
anchorPost,
),
)
await server.mocker.labelAccount('!warn', 'always-warn-account')
await server.mocker.labelProfile('!warn', 'always-warn-profile')
await server.mocker.labelPost(
'!warn',
await server.mocker.createPost(
'always-warn-posts',
'always-warn post',
),
)
await server.mocker.labelPost(
'!warn',
await server.mocker.createQuotePost(
'always-warn-posts',
'always-warn quote post',
anchorPost,
),
)
await server.mocker.labelPost(
'!warn',
await server.mocker.createReply(
'always-warn-posts',
'always-warn reply',
anchorPost,
),
)
await server.mocker.users.alice.agent.mute('muted-account.test')
await server.mocker.createPost('muted-account', 'muted post')
await server.mocker.createQuotePost(

View File

@ -6,7 +6,23 @@ export const ILLEGAL_LABEL_GROUP: LabelValGroup = {
title: 'Illegal Content',
warning: 'Illegal Content',
values: ['csam', 'dmca-violation', 'nudity-nonconsentual'],
imagesOnly: false, // not applicable
imagesOnly: false,
}
export const ALWAYS_FILTER_LABEL_GROUP: LabelValGroup = {
id: 'always-filter',
title: 'Content Warning',
warning: 'Content Warning',
values: ['!filter'],
imagesOnly: false,
}
export const ALWAYS_WARN_LABEL_GROUP: LabelValGroup = {
id: 'always-warn',
title: 'Content Warning',
warning: 'Content Warning',
values: ['!warn'],
imagesOnly: false,
}
export const UNKNOWN_LABEL_GROUP: LabelValGroup = {

View File

@ -8,6 +8,8 @@ import {
import {
CONFIGURABLE_LABEL_GROUPS,
ILLEGAL_LABEL_GROUP,
ALWAYS_FILTER_LABEL_GROUP,
ALWAYS_WARN_LABEL_GROUP,
UNKNOWN_LABEL_GROUP,
} from './const'
import {
@ -34,6 +36,12 @@ export function getLabelValueGroup(labelVal: string): LabelValGroup {
if (ILLEGAL_LABEL_GROUP.values.includes(labelVal)) {
return ILLEGAL_LABEL_GROUP
}
if (ALWAYS_FILTER_LABEL_GROUP.values.includes(labelVal)) {
return ALWAYS_FILTER_LABEL_GROUP
}
if (ALWAYS_WARN_LABEL_GROUP.values.includes(labelVal)) {
return ALWAYS_WARN_LABEL_GROUP
}
if (CONFIGURABLE_LABEL_GROUPS[id].values.includes(labelVal)) {
return CONFIGURABLE_LABEL_GROUPS[id]
}

View File

@ -4,7 +4,12 @@ import {LabelPreferencesModel} from 'state/models/ui/preferences'
export type Label = ComAtprotoLabelDefs.Label
export interface LabelValGroup {
id: keyof LabelPreferencesModel | 'illegal' | 'unknown'
id:
| keyof LabelPreferencesModel
| 'illegal'
| 'always-filter'
| 'always-warn'
| 'unknown'
title: string
imagesOnly: boolean
subtitle?: string

View File

@ -4,7 +4,12 @@ import {isObj, hasProp} from 'lib/type-guards'
import {ComAtprotoLabelDefs} from '@atproto/api'
import {LabelValGroup} from 'lib/labeling/types'
import {getLabelValueGroup} from 'lib/labeling/helpers'
import {UNKNOWN_LABEL_GROUP, ILLEGAL_LABEL_GROUP} from 'lib/labeling/const'
import {
UNKNOWN_LABEL_GROUP,
ILLEGAL_LABEL_GROUP,
ALWAYS_FILTER_LABEL_GROUP,
ALWAYS_WARN_LABEL_GROUP,
} from 'lib/labeling/const'
const deviceLocales = getLocales()
@ -94,6 +99,10 @@ export class PreferencesModel {
const group = getLabelValueGroup(label.val)
if (group.id === 'illegal') {
return {pref: 'hide', desc: ILLEGAL_LABEL_GROUP}
} else if (group.id === 'always-filter') {
return {pref: 'hide', desc: ALWAYS_FILTER_LABEL_GROUP}
} else if (group.id === 'always-warn') {
return {pref: 'warn', desc: ALWAYS_WARN_LABEL_GROUP}
} else if (group.id === 'unknown') {
continue
}