Merge branch '3p-moderators' of github.com:bluesky-social/social-app into 3p-moderators
This commit is contained in:
+62
-1
@@ -1,5 +1,11 @@
|
||||
import React from 'react'
|
||||
import {ModerationCause, LABEL_GROUPS, LabelGroupDefinition} from '@atproto/api'
|
||||
import {
|
||||
ModerationCause,
|
||||
LABEL_GROUPS,
|
||||
LabelGroupDefinition,
|
||||
AppBskyModerationDefs,
|
||||
} from '@atproto/api'
|
||||
|
||||
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
||||
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||
|
||||
@@ -39,6 +45,33 @@ export function useConfigurableLabelGroups() {
|
||||
return React.useMemo(() => getConfigurableLabelGroups(), [])
|
||||
}
|
||||
|
||||
export function useConfigurableContentLabelGroups() {
|
||||
return React.useMemo(() => {
|
||||
const groups = getConfigurableLabelGroups()
|
||||
return groups.filter(group => {
|
||||
return group.labels.every(l => l.targets.includes('content'))
|
||||
})
|
||||
}, [])
|
||||
}
|
||||
|
||||
export function useConfigurableProfileLabelGroups() {
|
||||
return React.useMemo(() => {
|
||||
const groups = getConfigurableLabelGroups()
|
||||
return groups.filter(group => {
|
||||
return group.labels.every(l => l.targets.includes('profile'))
|
||||
})
|
||||
}, [])
|
||||
}
|
||||
|
||||
export function useConfigurableAccountLabelGroups() {
|
||||
return React.useMemo(() => {
|
||||
const groups = getConfigurableLabelGroups()
|
||||
return groups.filter(group => {
|
||||
return group.labels.every(l => l.targets.includes('account'))
|
||||
})
|
||||
}, [])
|
||||
}
|
||||
|
||||
export function getModerationServiceTitle({
|
||||
displayName,
|
||||
handle,
|
||||
@@ -50,3 +83,31 @@ export function getModerationServiceTitle({
|
||||
? sanitizeDisplayName(displayName)
|
||||
: sanitizeHandle(handle, '@')
|
||||
}
|
||||
|
||||
export function getLabelGroupToLabelerMap(
|
||||
labelers: AppBskyModerationDefs.ModServiceViewDetailed[],
|
||||
) {
|
||||
if (!labelers) return {}
|
||||
|
||||
const groups: Partial<
|
||||
Record<
|
||||
LabelGroupDefinition['id'] | 'other',
|
||||
AppBskyModerationDefs.ModServiceViewDetailed[]
|
||||
>
|
||||
> = {
|
||||
// `other` reports go to all labelers TODO confirm this
|
||||
other: labelers,
|
||||
}
|
||||
|
||||
for (const modservice of labelers) {
|
||||
const labelGroups = getLabelGroupsFromLabels(
|
||||
modservice.policies.labelValues,
|
||||
)
|
||||
for (const group of labelGroups) {
|
||||
const g = (groups[group.id] = groups[group.id] || [])
|
||||
g.push(modservice)
|
||||
}
|
||||
}
|
||||
|
||||
return groups
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import {useLingui} from '@lingui/react'
|
||||
import {useMemo} from 'react'
|
||||
|
||||
export type LabelGroupStrings = Record<
|
||||
keyof typeof LABEL_GROUPS,
|
||||
keyof typeof LABEL_GROUPS | 'other',
|
||||
{name: string; description: string}
|
||||
>
|
||||
|
||||
@@ -116,6 +116,10 @@ export function useLabelGroupStrings(): LabelGroupStrings {
|
||||
msg`Helpful annotations to explain intent, such as satire or parody.`,
|
||||
),
|
||||
},
|
||||
other: {
|
||||
name: _(msg`Other`),
|
||||
description: _(msg`Other content not covered by the other categories.`),
|
||||
},
|
||||
}),
|
||||
[_],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user