Add special handling of the mod authorities
This commit is contained in:
@@ -3,6 +3,9 @@ import {
|
||||
ModerationUI,
|
||||
InterpretedLabelValueDefinition,
|
||||
LABELS,
|
||||
AppBskyLabelerDefs,
|
||||
BskyAgent,
|
||||
ModerationOpts,
|
||||
} from '@atproto/api'
|
||||
|
||||
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
||||
@@ -50,3 +53,29 @@ export function lookupLabelValueDefinition(
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
export function isModAuthority(
|
||||
labeler:
|
||||
| string
|
||||
| AppBskyLabelerDefs.LabelerView
|
||||
| AppBskyLabelerDefs.LabelerViewDetailed,
|
||||
): boolean {
|
||||
if (typeof labeler === 'string') {
|
||||
return BskyAgent.modAuthoritiesHeader.includes(labeler)
|
||||
}
|
||||
return BskyAgent.modAuthoritiesHeader.includes(labeler.creator.did)
|
||||
}
|
||||
|
||||
export function isLabelerSubscribed(
|
||||
labeler:
|
||||
| string
|
||||
| AppBskyLabelerDefs.LabelerView
|
||||
| AppBskyLabelerDefs.LabelerViewDetailed,
|
||||
modOpts: ModerationOpts,
|
||||
) {
|
||||
labeler = typeof labeler === 'string' ? labeler : labeler.creator.did
|
||||
if (isModAuthority(labeler)) {
|
||||
return true
|
||||
}
|
||||
return modOpts.prefs.labelers.find(l => l.did === labeler)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user