Little cleanup
This commit is contained in:
+35
-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'
|
||||
|
||||
@@ -77,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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user