about summary refs log tree commit diff
path: root/src/state/queries/preferences/moderation.ts
blob: cdae5293740abc7f4a453ebb4cca7800c7b6a24f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import {
  LabelPreference,
  ComAtprotoLabelDefs,
  ModerationOpts,
} from '@atproto/api'

import {
  LabelGroup,
  ConfigurableLabelGroup,
  UsePreferencesQueryResponse,
} from '#/state/queries/preferences/types'

export type Label = ComAtprotoLabelDefs.Label

export type LabelGroupConfig = {
  id: LabelGroup
  title: string
  isAdultImagery?: boolean
  subtitle?: string
  warning: string
  values: string[]
}

export const DEFAULT_LABEL_PREFERENCES: Record<
  ConfigurableLabelGroup,
  LabelPreference
> = {
  nsfw: 'hide',
  nudity: 'warn',
  suggestive: 'warn',
  gore: 'warn',
  hate: 'hide',
  spam: 'hide',
  impersonation: 'hide',
}

/**
 * More strict than our default settings for logged in users.
 *
 * TODO(pwi)
 */
export const DEFAULT_LOGGED_OUT_LABEL_PREFERENCES: Record<
  ConfigurableLabelGroup,
  LabelPreference
> = {
  nsfw: 'hide',
  nudity: 'hide',
  suggestive: 'hide',
  gore: 'hide',
  hate: 'hide',
  spam: 'hide',
  impersonation: 'hide',
}

export const ILLEGAL_LABEL_GROUP: LabelGroupConfig = {
  id: 'illegal',
  title: 'Illegal Content',
  warning: 'Illegal Content',
  values: ['csam', 'dmca-violation', 'nudity-nonconsensual'],
}

export const ALWAYS_FILTER_LABEL_GROUP: LabelGroupConfig = {
  id: 'always-filter',
  title: 'Content Warning',
  warning: 'Content Warning',
  values: ['!filter'],
}

export const ALWAYS_WARN_LABEL_GROUP: LabelGroupConfig = {
  id: 'always-warn',
  title: 'Content Warning',
  warning: 'Content Warning',
  values: ['!warn', 'account-security'],
}

export const UNKNOWN_LABEL_GROUP: LabelGroupConfig = {
  id: 'unknown',
  title: 'Unknown Label',
  warning: 'Content Warning',
  values: [],
}

export const CONFIGURABLE_LABEL_GROUPS: Record<
  ConfigurableLabelGroup,
  LabelGroupConfig
> = {
  nsfw: {
    id: 'nsfw',
    title: 'Explicit Sexual Images',
    subtitle: 'i.e. pornography',
    warning: 'Sexually Explicit',
    values: ['porn', 'nsfl'],
    isAdultImagery: true,
  },
  nudity: {
    id: 'nudity',
    title: 'Other Nudity',
    subtitle: 'Including non-sexual and artistic',
    warning: 'Nudity',
    values: ['nudity'],
    isAdultImagery: true,
  },
  suggestive: {
    id: 'suggestive',
    title: 'Sexually Suggestive',
    subtitle: 'Does not include nudity',
    warning: 'Sexually Suggestive',
    values: ['sexual'],
    isAdultImagery: true,
  },
  gore: {
    id: 'gore',
    title: 'Violent / Bloody',
    subtitle: 'Gore, self-harm, torture',
    warning: 'Violence',
    values: ['gore', 'self-harm', 'torture', 'nsfl', 'corpse'],
    isAdultImagery: true,
  },
  hate: {
    id: 'hate',
    title: 'Hate Group Iconography',
    subtitle: 'Images of terror groups, articles covering events, etc.',
    warning: 'Hate Groups',
    values: ['icon-kkk', 'icon-nazi', 'icon-intolerant', 'behavior-intolerant'],
  },
  spam: {
    id: 'spam',
    title: 'Spam',
    subtitle: 'Excessive unwanted interactions',
    warning: 'Spam',
    values: ['spam'],
  },
  impersonation: {
    id: 'impersonation',
    title: 'Impersonation',
    subtitle: 'Accounts falsely claiming to be people or orgs',
    warning: 'Impersonation',
    values: ['impersonation'],
  },
}

export function getModerationOpts({
  userDid,
  preferences,
}: {
  userDid: string
  preferences: UsePreferencesQueryResponse
}): ModerationOpts {
  return {
    userDid: userDid,
    adultContentEnabled: preferences.adultContentEnabled,
    labels: {
      porn: preferences.contentLabels.nsfw,
      sexual: preferences.contentLabels.suggestive,
      nudity: preferences.contentLabels.nudity,
      nsfl: preferences.contentLabels.gore,
      corpse: preferences.contentLabels.gore,
      gore: preferences.contentLabels.gore,
      torture: preferences.contentLabels.gore,
      'self-harm': preferences.contentLabels.gore,
      'intolerant-race': preferences.contentLabels.hate,
      'intolerant-gender': preferences.contentLabels.hate,
      'intolerant-sexual-orientation': preferences.contentLabels.hate,
      'intolerant-religion': preferences.contentLabels.hate,
      intolerant: preferences.contentLabels.hate,
      'icon-intolerant': preferences.contentLabels.hate,
      spam: preferences.contentLabels.spam,
      impersonation: preferences.contentLabels.impersonation,
      scam: 'warn',
    },
    labelers: [
      {
        labeler: {
          did: '',
          displayName: 'Bluesky Social',
        },
        labels: {},
      },
    ],
  }
}