Add the !filter and !warn imperative labels (#580)
parent
33bf9c3869
commit
ab3074fdee
|
@ -84,6 +84,12 @@ async function main() {
|
||||||
'unknown-account',
|
'unknown-account',
|
||||||
'unknown-profile',
|
'unknown-profile',
|
||||||
'unknown-posts',
|
'unknown-posts',
|
||||||
|
'always-filter-account',
|
||||||
|
'always-filter-profile',
|
||||||
|
'always-filter-posts',
|
||||||
|
'always-warn-account',
|
||||||
|
'always-warn-profile',
|
||||||
|
'always-warn-posts',
|
||||||
'muted-account',
|
'muted-account',
|
||||||
]) {
|
]) {
|
||||||
await server.mocker.createUser(user)
|
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.users.alice.agent.mute('muted-account.test')
|
||||||
await server.mocker.createPost('muted-account', 'muted post')
|
await server.mocker.createPost('muted-account', 'muted post')
|
||||||
await server.mocker.createQuotePost(
|
await server.mocker.createQuotePost(
|
||||||
|
|
|
@ -6,7 +6,23 @@ export const ILLEGAL_LABEL_GROUP: LabelValGroup = {
|
||||||
title: 'Illegal Content',
|
title: 'Illegal Content',
|
||||||
warning: 'Illegal Content',
|
warning: 'Illegal Content',
|
||||||
values: ['csam', 'dmca-violation', 'nudity-nonconsentual'],
|
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 = {
|
export const UNKNOWN_LABEL_GROUP: LabelValGroup = {
|
||||||
|
|
|
@ -8,6 +8,8 @@ import {
|
||||||
import {
|
import {
|
||||||
CONFIGURABLE_LABEL_GROUPS,
|
CONFIGURABLE_LABEL_GROUPS,
|
||||||
ILLEGAL_LABEL_GROUP,
|
ILLEGAL_LABEL_GROUP,
|
||||||
|
ALWAYS_FILTER_LABEL_GROUP,
|
||||||
|
ALWAYS_WARN_LABEL_GROUP,
|
||||||
UNKNOWN_LABEL_GROUP,
|
UNKNOWN_LABEL_GROUP,
|
||||||
} from './const'
|
} from './const'
|
||||||
import {
|
import {
|
||||||
|
@ -34,6 +36,12 @@ export function getLabelValueGroup(labelVal: string): LabelValGroup {
|
||||||
if (ILLEGAL_LABEL_GROUP.values.includes(labelVal)) {
|
if (ILLEGAL_LABEL_GROUP.values.includes(labelVal)) {
|
||||||
return ILLEGAL_LABEL_GROUP
|
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)) {
|
if (CONFIGURABLE_LABEL_GROUPS[id].values.includes(labelVal)) {
|
||||||
return CONFIGURABLE_LABEL_GROUPS[id]
|
return CONFIGURABLE_LABEL_GROUPS[id]
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,12 @@ import {LabelPreferencesModel} from 'state/models/ui/preferences'
|
||||||
export type Label = ComAtprotoLabelDefs.Label
|
export type Label = ComAtprotoLabelDefs.Label
|
||||||
|
|
||||||
export interface LabelValGroup {
|
export interface LabelValGroup {
|
||||||
id: keyof LabelPreferencesModel | 'illegal' | 'unknown'
|
id:
|
||||||
|
| keyof LabelPreferencesModel
|
||||||
|
| 'illegal'
|
||||||
|
| 'always-filter'
|
||||||
|
| 'always-warn'
|
||||||
|
| 'unknown'
|
||||||
title: string
|
title: string
|
||||||
imagesOnly: boolean
|
imagesOnly: boolean
|
||||||
subtitle?: string
|
subtitle?: string
|
||||||
|
|
|
@ -4,7 +4,12 @@ import {isObj, hasProp} from 'lib/type-guards'
|
||||||
import {ComAtprotoLabelDefs} from '@atproto/api'
|
import {ComAtprotoLabelDefs} from '@atproto/api'
|
||||||
import {LabelValGroup} from 'lib/labeling/types'
|
import {LabelValGroup} from 'lib/labeling/types'
|
||||||
import {getLabelValueGroup} from 'lib/labeling/helpers'
|
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()
|
const deviceLocales = getLocales()
|
||||||
|
|
||||||
|
@ -94,6 +99,10 @@ export class PreferencesModel {
|
||||||
const group = getLabelValueGroup(label.val)
|
const group = getLabelValueGroup(label.val)
|
||||||
if (group.id === 'illegal') {
|
if (group.id === 'illegal') {
|
||||||
return {pref: 'hide', desc: ILLEGAL_LABEL_GROUP}
|
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') {
|
} else if (group.id === 'unknown') {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue