about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--__e2e__/mock-server.ts58
-rw-r--r--src/lib/labeling/const.ts18
-rw-r--r--src/lib/labeling/helpers.ts8
-rw-r--r--src/lib/labeling/types.ts7
-rw-r--r--src/state/models/ui/preferences.ts11
5 files changed, 99 insertions, 3 deletions
diff --git a/__e2e__/mock-server.ts b/__e2e__/mock-server.ts
index 3577990d3..6744f697f 100644
--- a/__e2e__/mock-server.ts
+++ b/__e2e__/mock-server.ts
@@ -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(
diff --git a/src/lib/labeling/const.ts b/src/lib/labeling/const.ts
index f219cdb79..54cc732b9 100644
--- a/src/lib/labeling/const.ts
+++ b/src/lib/labeling/const.ts
@@ -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 = {
diff --git a/src/lib/labeling/helpers.ts b/src/lib/labeling/helpers.ts
index 5ec591cfb..71ea43c08 100644
--- a/src/lib/labeling/helpers.ts
+++ b/src/lib/labeling/helpers.ts
@@ -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]
     }
diff --git a/src/lib/labeling/types.ts b/src/lib/labeling/types.ts
index 20ecaa5b5..123c5d1f3 100644
--- a/src/lib/labeling/types.ts
+++ b/src/lib/labeling/types.ts
@@ -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
diff --git a/src/state/models/ui/preferences.ts b/src/state/models/ui/preferences.ts
index f6b29169d..7b41fa746 100644
--- a/src/state/models/ui/preferences.ts
+++ b/src/state/models/ui/preferences.ts
@@ -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
       }