Replace consts and maps using exported values

This commit is contained in:
Eric Bailey
2025-10-03 15:26:26 -05:00
parent f68e6f1e6a
commit c88ac0dc9e
4 changed files with 192 additions and 112 deletions
@@ -1,2 +1,130 @@
import * as RootReportDefs from '@atproto/api/dist/client/types/com/atproto/moderation/defs'
import * as OzoneReportDefs from '@atproto/api/dist/client/types/tools/ozone/report/defs'
export const DMCA_LINK = 'https://bsky.social/about/support/copyright' export const DMCA_LINK = 'https://bsky.social/about/support/copyright'
export const SUPPORT_PAGE = 'https://bsky.social/about/support' export const SUPPORT_PAGE = 'https://bsky.social/about/support'
export const NEW_TO_OLD_REASON_MAPPING: Record<string, string> = {}
/**
* Mapping of new (Ozone namespace) reason types to old reason types.
*
* Matches the mapping defined in the Ozone codebase:
* @see https://github.com/bluesky-social/atproto/blob/09439d7d688294ad1a0c78a74b901ba2f7c5f4c3/packages/ozone/src/mod-service/profile.ts#L15
*/
export const NEW_TO_OLD_REASONS_MAP: Record<
OzoneReportDefs.ReasonType,
RootReportDefs.ReasonType
> = {
[OzoneReportDefs.REASONAPPEAL]: RootReportDefs.REASONAPPEAL,
// Violence-related
[OzoneReportDefs.REASONVIOLENCEANIMALWELFARE]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONVIOLENCETHREATS]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONVIOLENCEGRAPHICCONTENT]:
RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONVIOLENCESELFHARM]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONVIOLENCEGLORIFICATION]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONVIOLENCEEXTREMISTCONTENT]:
RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONVIOLENCETRAFFICKING]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONVIOLENCEOTHER]: RootReportDefs.REASONVIOLATION,
// Sexual-related
[OzoneReportDefs.REASONSEXUALABUSECONTENT]: RootReportDefs.REASONSEXUAL,
[OzoneReportDefs.REASONSEXUALNCII]: RootReportDefs.REASONSEXUAL,
[OzoneReportDefs.REASONSEXUALSEXTORTION]: RootReportDefs.REASONSEXUAL,
[OzoneReportDefs.REASONSEXUALDEEPFAKE]: RootReportDefs.REASONSEXUAL,
[OzoneReportDefs.REASONSEXUALANIMAL]: RootReportDefs.REASONSEXUAL,
[OzoneReportDefs.REASONSEXUALUNLABELED]: RootReportDefs.REASONSEXUAL,
[OzoneReportDefs.REASONSEXUALOTHER]: RootReportDefs.REASONSEXUAL,
// Child safety
[OzoneReportDefs.REASONCHILDSAFETYCSAM]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONCHILDSAFETYGROOM]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONCHILDSAFETYMINORPRIVACY]:
RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONCHILDSAFETYENDANGERMENT]:
RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONCHILDSAFETYHARASSMENT]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONCHILDSAFETYPROMOTION]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONCHILDSAFETYOTHER]: RootReportDefs.REASONVIOLATION,
// Harassment
[OzoneReportDefs.REASONHARASSMENTTROLL]: RootReportDefs.REASONRUDE,
[OzoneReportDefs.REASONHARASSMENTTARGETED]: RootReportDefs.REASONRUDE,
[OzoneReportDefs.REASONHARASSMENTHATESPEECH]: RootReportDefs.REASONRUDE,
[OzoneReportDefs.REASONHARASSMENTDOXXING]: RootReportDefs.REASONRUDE,
[OzoneReportDefs.REASONHARASSMENTOTHER]: RootReportDefs.REASONRUDE,
// Misleading
[OzoneReportDefs.REASONMISLEADINGSPAM]: RootReportDefs.REASONSPAM,
[OzoneReportDefs.REASONMISLEADINGBOT]: RootReportDefs.REASONMISLEADING,
[OzoneReportDefs.REASONMISLEADINGIMPERSONATION]:
RootReportDefs.REASONMISLEADING,
[OzoneReportDefs.REASONMISLEADINGSCAM]: RootReportDefs.REASONMISLEADING,
[OzoneReportDefs.REASONMISLEADINGSYNTHETICCONTENT]:
RootReportDefs.REASONMISLEADING,
[OzoneReportDefs.REASONMISLEADINGMISINFORMATION]:
RootReportDefs.REASONMISLEADING,
[OzoneReportDefs.REASONMISLEADINGOTHER]: RootReportDefs.REASONMISLEADING,
// Map all rule-related reasons to REASONVIOLATION
[OzoneReportDefs.REASONRULESITESECURITY]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONRULESTOLENCONTENT]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONRULEPROHIBITEDSALES]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONRULEBANEVASION]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONRULEOTHER]: RootReportDefs.REASONVIOLATION,
// Information Integrity
[OzoneReportDefs.REASONCIVICELECTORALPROCESS]:
RootReportDefs.REASONMISLEADING,
[OzoneReportDefs.REASONCIVICDISCLOSURE]: RootReportDefs.REASONMISLEADING,
[OzoneReportDefs.REASONCIVICINTERFERENCE]: RootReportDefs.REASONMISLEADING,
[OzoneReportDefs.REASONCIVICMISINFORMATION]: RootReportDefs.REASONMISLEADING,
[OzoneReportDefs.REASONCIVICIMPERSONATION]: RootReportDefs.REASONMISLEADING,
}
/**
* Mapping of old reason types to new (Ozone namespace) reason types.
* @see https://github.com/bluesky-social/proposals/tree/main/0009-mod-report-granularity#backwards-compatibility
*/
export const OLD_TO_NEW_REASONS_MAP: Record<
Exclude<RootReportDefs.ReasonType, OzoneReportDefs.ReasonType>,
OzoneReportDefs.ReasonType
> = {
[RootReportDefs.REASONSPAM]: [OzoneReportDefs.REASONMISLEADINGSPAM],
[RootReportDefs.REASONVIOLATION]: [OzoneReportDefs.REASONRULEOTHER],
[RootReportDefs.REASONMISLEADING]: [OzoneReportDefs.REASONMISLEADINGOTHER],
[RootReportDefs.REASONSEXUAL]: [OzoneReportDefs.REASONSEXUALUNLABELED],
[RootReportDefs.REASONRUDE]: [OzoneReportDefs.REASONHARASSMENTOTHER],
[RootReportDefs.REASONOTHER]: [OzoneReportDefs.REASONRULEOTHER],
[RootReportDefs.REASONAPPEAL]: [OzoneReportDefs.REASONAPPEAL],
}
/**
* Set of report reasons that should optionally include additional details from
* the reporter.
*/
export const OTHER_REPORT_REASONS: Set<OzoneReportDefs.ReasonType> = new Set([
OzoneReportDefs.REASONVIOLENCEOTHER,
OzoneReportDefs.REASONSEXUALOTHER,
OzoneReportDefs.REASONCHILDSAFETYOTHER,
OzoneReportDefs.REASONHARASSMENTOTHER,
OzoneReportDefs.REASONMISLEADINGOTHER,
OzoneReportDefs.REASONRULEOTHER,
])
/**
* Set of report reasons that should only be sent to moderation authorities,
* such as Bluesky.
*/
export const MOD_AUTHORITY_ONLY_REPORT_REASONS: Set<OzoneReportDefs.ReasonType> =
new Set([
OzoneReportDefs.REASONCHILDSAFETYCSAM,
OzoneReportDefs.REASONCHILDSAFETYGROOM,
OzoneReportDefs.REASONCHILDSAFETYENDANGERMENT,
OzoneReportDefs.REASONCHILDSAFETYPROMOTION,
OzoneReportDefs.REASONCHILDSAFETYOTHER,
OzoneReportDefs.REASONVIOLENCEEXTREMISTCONTENT,
])
@@ -36,8 +36,8 @@ import {initialState, reducer} from './state'
import {type ReportDialogProps, type ReportSubject} from './types' import {type ReportDialogProps, type ReportSubject} from './types'
import {parseReportSubject} from './utils/parseReportSubject' import {parseReportSubject} from './utils/parseReportSubject'
import { import {
type ReportCategoryConfig,
type ReportOption, type ReportOption,
type ReportOptionCategory,
useReportOptions, useReportOptions,
} from './utils/useReportOptions' } from './utils/useReportOptions'
@@ -620,8 +620,8 @@ function CategoryCard({
option, option,
onSelect, onSelect,
}: { }: {
option: ReportOptionCategory option: ReportCategoryConfig
onSelect?: (option: ReportOptionCategory) => void onSelect?: (option: ReportCategoryConfig) => void
}) { }) {
const t = useTheme() const t = useTheme()
const {_} = useLingui() const {_} = useLingui()
@@ -1,13 +1,13 @@
import {type AppBskyLabelerDefs} from '@atproto/api' import {type AppBskyLabelerDefs} from '@atproto/api'
import {OTHER_REPORT_REASONS} from '#/components/moderation/ReportDialog/const'
import { import {
OtherReportReasons, type ReportCategoryConfig,
type ReportOption, type ReportOption,
type ReportOptionCategory, } from '#/components/moderation/ReportDialog/utils/useReportOptions'
} from './utils/useReportOptions'
export type ReportState = { export type ReportState = {
selectedCategory?: ReportOptionCategory selectedCategory?: ReportCategoryConfig
selectedOption?: ReportOption selectedOption?: ReportOption
selectedLabeler?: AppBskyLabelerDefs.LabelerViewDetailed selectedLabeler?: AppBskyLabelerDefs.LabelerViewDetailed
details?: string details?: string
@@ -19,7 +19,7 @@ export type ReportState = {
export type ReportAction = export type ReportAction =
| { | {
type: 'selectCategory' type: 'selectCategory'
option: ReportOptionCategory option: ReportCategoryConfig
otherOption: ReportOption otherOption: ReportOption
} }
| { | {
@@ -87,7 +87,7 @@ export function reducer(state: ReportState, action: ReportAction): ReportState {
...state, ...state,
selectedOption: action.option, selectedOption: action.option,
activeStepIndex1: 3, activeStepIndex1: 3,
detailsOpen: OtherReportReasons.has(action.option.reason), detailsOpen: OTHER_REPORT_REASONS.has(action.option.reason),
} }
case 'clearOption': case 'clearOption':
return { return {
@@ -102,7 +102,9 @@ export function reducer(state: ReportState, action: ReportAction): ReportState {
...state, ...state,
selectedLabeler: action.labeler, selectedLabeler: action.labeler,
activeStepIndex1: 4, activeStepIndex1: 4,
detailsOpen: OtherReportReasons.has(state.selectedOption?.reason), detailsOpen: state.selectedOption
? OTHER_REPORT_REASONS.has(state.selectedOption?.reason)
: false,
} }
case 'clearLabeler': case 'clearLabeler':
return { return {
@@ -1,4 +1,5 @@
import {type ReasonType} from '@atproto/api/dist/client/types/com/atproto/moderation/defs' import * as RootReportDefs from '@atproto/api/dist/client/types/com/atproto/moderation/defs'
import * as OzoneReportDefs from '@atproto/api/dist/client/types/tools/ozone/report/defs'
import {msg} from '@lingui/macro' import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
@@ -12,7 +13,7 @@ export type ReportCategory =
| 'civicIntegrity' | 'civicIntegrity'
| 'other' | 'other'
export interface ReportOptionCategory { export type ReportCategoryConfig = {
key: ReportCategory key: ReportCategory
title: string title: string
description: string description: string
@@ -21,37 +22,15 @@ export interface ReportOptionCategory {
isOther?: boolean isOther?: boolean
} }
export interface ReportOptionCategories { export type ReportOption = {
childSafety: ReportOptionCategory
violencePhysicalHarm: ReportOptionCategory
sexualAdultContent: ReportOptionCategory
harassmentHate: ReportOptionCategory
misleading: ReportOptionCategory
ruleBreaking: ReportOptionCategory
civicIntegrity: ReportOptionCategory
other: ReportOptionCategory
}
export interface ReportOption {
title: string title: string
reason: ReasonType reason: RootReportDefs.ReasonType
} }
export const OtherReportReasons = new Set<ReasonType | undefined>([
'com.atproto.moderation.defs#reasonOther',
'tools.ozone.report.defs#reasonChildSafetyOther',
'tools.ozone.report.defs#reasonViolenceOther',
'tools.ozone.report.defs#reasonSexualOther',
'tools.ozone.report.defs#reasonHarassmentOther',
'tools.ozone.report.defs#reasonMisleadingOther',
'tools.ozone.report.defs#reasonRuleOther',
'tools.ozone.report.defs#reasonChildSafetyOther',
])
export function useReportOptions() { export function useReportOptions() {
const {_} = useLingui() const {_} = useLingui()
const categories: ReportOptionCategories = { const categories: Record<ReportCategory, ReportCategoryConfig> = {
childSafety: { childSafety: {
key: 'childSafety', key: 'childSafety',
title: _(msg`Child Safety`), title: _(msg`Child Safety`),
@@ -62,31 +41,31 @@ export function useReportOptions() {
options: [ options: [
{ {
title: _(msg`Child Sexual Abuse Material (CSAM)`), title: _(msg`Child Sexual Abuse Material (CSAM)`),
reason: 'tools.ozone.report.defs#reasonChildSafetyCSAM', reason: OzoneReportDefs.REASONCHILDSAFETYCSAM,
}, },
{ {
title: _(msg`Grooming or Predatory Behavior`), title: _(msg`Grooming or Predatory Behavior`),
reason: 'tools.ozone.report.defs#reasonChildSafetyGroom', reason: OzoneReportDefs.REASONCHILDSAFETYGROOM,
}, },
{ {
title: _(msg`Minor Privacy Violation`), title: _(msg`Minor Privacy Violation`),
reason: 'tools.ozone.report.defs#reasonChildSafetyMinorPrivacy', reason: OzoneReportDefs.REASONCHILDSAFETYMINORPRIVACY,
}, },
{ {
title: _(msg`Child Endangerment`), title: _(msg`Child Endangerment`),
reason: 'tools.ozone.report.defs#reasonChildSafetyEndangerment', reason: OzoneReportDefs.REASONCHILDSAFETYENDANGERMENT,
}, },
{ {
title: _(msg`Minor Harassment or Bullying`), title: _(msg`Minor Harassment or Bullying`),
reason: 'tools.ozone.report.defs#reasonChildSafetyHarassment', reason: OzoneReportDefs.REASONCHILDSAFETYHARASSMENT,
}, },
{ {
title: _(msg`Promotion of Child Exploitation`), title: _(msg`Promotion of Child Exploitation`),
reason: 'tools.ozone.report.defs#reasonChildSafetyPromotion', reason: OzoneReportDefs.REASONCHILDSAFETYPROMOTION,
}, },
{ {
title: _(msg`Other Child Safety Issue`), title: _(msg`Other Child Safety Issue`),
reason: 'tools.ozone.report.defs#reasonChildSafetyOther', reason: OzoneReportDefs.REASONCHILDSAFETYOTHER,
}, },
], ],
}, },
@@ -98,35 +77,35 @@ export function useReportOptions() {
options: [ options: [
{ {
title: _(msg`Animal Welfare`), title: _(msg`Animal Welfare`),
reason: 'tools.ozone.report.defs#reasonViolenceAnimalWelfare', reason: OzoneReportDefs.REASONVIOLENCEANIMALWELFARE,
}, },
{ {
title: _(msg`Threats or Incitement`), title: _(msg`Threats or Incitement`),
reason: 'tools.ozone.report.defs#reasonViolenceThreats', reason: OzoneReportDefs.REASONVIOLENCETHREATS,
}, },
{ {
title: _(msg`Graphic Violent Content`), title: _(msg`Graphic Violent Content`),
reason: 'tools.ozone.report.defs#reasonViolenceGraphicContent', reason: OzoneReportDefs.REASONVIOLENCEGRAPHICCONTENT,
}, },
{ {
title: _(msg`Self Harm`), title: _(msg`Self Harm`),
reason: 'tools.ozone.report.defs#reasonViolenceSelfHarm', reason: OzoneReportDefs.REASONVIOLENCESELFHARM,
}, },
{ {
title: _(msg`Glorification of Violence`), title: _(msg`Glorification of Violence`),
reason: 'tools.ozone.report.defs#reasonViolenceGlorification', reason: OzoneReportDefs.REASONVIOLENCEGLORIFICATION,
}, },
{ {
title: _(msg`Extremist Content`), title: _(msg`Extremist Content`),
reason: 'tools.ozone.report.defs#reasonViolenceExtremistContent', reason: OzoneReportDefs.REASONVIOLENCEEXTREMISTCONTENT,
}, },
{ {
title: _(msg`Human Trafficking`), title: _(msg`Human Trafficking`),
reason: 'tools.ozone.report.defs#reasonViolenceTrafficking', reason: OzoneReportDefs.REASONVIOLENCETRAFFICKING,
}, },
{ {
title: _(msg`Other Violent Content`), title: _(msg`Other Violent Content`),
reason: 'tools.ozone.report.defs#reasonViolenceOther', reason: OzoneReportDefs.REASONVIOLENCEOTHER,
}, },
], ],
}, },
@@ -138,31 +117,31 @@ export function useReportOptions() {
options: [ options: [
{ {
title: _(msg`Adult Sexual Abuse Content`), title: _(msg`Adult Sexual Abuse Content`),
reason: 'tools.ozone.report.defs#reasonSexualAbuseContent', reason: OzoneReportDefs.REASONSEXUALABUSECONTENT,
}, },
{ {
title: _(msg`Non-Consensual Intimate Imagery`), title: _(msg`Non-Consensual Intimate Imagery`),
reason: 'tools.ozone.report.defs#reasonSexualNCII', reason: OzoneReportDefs.REASONSEXUALNCII,
}, },
{ {
title: _(msg`Sextortion`), title: _(msg`Sextortion`),
reason: 'tools.ozone.report.defs#reasonSexualSextortion', reason: OzoneReportDefs.REASONSEXUALSEXTORTION,
}, },
{ {
title: _(msg`Deepfake Adult Content`), title: _(msg`Deepfake Adult Content`),
reason: 'tools.ozone.report.defs#reasonSexualDeepfake', reason: OzoneReportDefs.REASONSEXUALDEEPFAKE,
}, },
{ {
title: _(msg`Animal Sexual Abuse`), title: _(msg`Animal Sexual Abuse`),
reason: 'tools.ozone.report.defs#reasonSexualAnimal', reason: OzoneReportDefs.REASONSEXUALANIMAL,
}, },
{ {
title: _(msg`Unlabeled Adult Content`), title: _(msg`Unlabeled Adult Content`),
reason: 'tools.ozone.report.defs#reasonSexualUnlabeled', reason: OzoneReportDefs.REASONSEXUALUNLABELED,
}, },
{ {
title: _(msg`Other Sexual Violence Content`), title: _(msg`Other Sexual Violence Content`),
reason: 'tools.ozone.report.defs#reasonSexualOther', reason: OzoneReportDefs.REASONSEXUALOTHER,
}, },
], ],
}, },
@@ -176,23 +155,23 @@ export function useReportOptions() {
options: [ options: [
{ {
title: _(msg`Trolling`), title: _(msg`Trolling`),
reason: 'tools.ozone.report.defs#reasonHarassmentTroll', reason: OzoneReportDefs.REASONHARASSMENTTROLL,
}, },
{ {
title: _(msg`Targeted Harassment`), title: _(msg`Targeted Harassment`),
reason: 'tools.ozone.report.defs#reasonHarassmentTargeted', reason: OzoneReportDefs.REASONHARASSMENTTARGETED,
}, },
{ {
title: _(msg`Hate Speech`), title: _(msg`Hate Speech`),
reason: 'tools.ozone.report.defs#reasonHarassmentHateSpeech', reason: OzoneReportDefs.REASONHARASSMENTHATESPEECH,
}, },
{ {
title: _(msg`Doxxing`), title: _(msg`Doxxing`),
reason: 'tools.ozone.report.defs#reasonHarassmentDoxxing', reason: OzoneReportDefs.REASONHARASSMENTDOXXING,
}, },
{ {
title: _(msg`Other Harassing or Hateful Content`), title: _(msg`Other Harassing or Hateful Content`),
reason: 'tools.ozone.report.defs#reasonHarassmentOther', reason: OzoneReportDefs.REASONHARASSMENTOTHER,
}, },
], ],
}, },
@@ -204,31 +183,31 @@ export function useReportOptions() {
options: [ options: [
{ {
title: _(msg`Fake Account or Bot`), title: _(msg`Fake Account or Bot`),
reason: 'tools.ozone.report.defs#reasonMisleadingBot', reason: OzoneReportDefs.REASONMISLEADINGBOT,
}, },
{ {
title: _(msg`Impersonation`), title: _(msg`Impersonation`),
reason: 'tools.ozone.report.defs#reasonMisleadingImpersonation', reason: OzoneReportDefs.REASONMISLEADINGIMPERSONATION,
}, },
{ {
title: _(msg`Spam`), title: _(msg`Spam`),
reason: 'com.atproto.moderation.defs#reasonSpam', reason: OzoneReportDefs.REASONMISLEADINGSPAM,
}, },
{ {
title: _(msg`Scam`), title: _(msg`Scam`),
reason: 'tools.ozone.report.defs#reasonMisleadingScam', reason: OzoneReportDefs.REASONMISLEADINGSCAM,
}, },
{ {
title: _(msg`Unlabeled Generative AI or Synthetic Content`), title: _(msg`Unlabeled Generative AI or Synthetic Content`),
reason: 'tools.ozone.report.defs#reasonMisleadingSyntheticContent', reason: OzoneReportDefs.REASONMISLEADINGSYNTHETICCONTENT,
}, },
{ {
title: _(msg`Harmful False Claims`), title: _(msg`Harmful False Claims`),
reason: 'tools.ozone.report.defs#reasonMisleadingMisinformation', reason: OzoneReportDefs.REASONMISLEADINGMISINFORMATION,
}, },
{ {
title: _(msg`Other Misleading Content`), title: _(msg`Other Misleading Content`),
reason: 'tools.ozone.report.defs#reasonMisleadingOther', reason: OzoneReportDefs.REASONMISLEADINGOTHER,
}, },
], ],
}, },
@@ -240,23 +219,23 @@ export function useReportOptions() {
options: [ options: [
{ {
title: _(msg`Hacking or System Attacks`), title: _(msg`Hacking or System Attacks`),
reason: 'tools.ozone.report.defs#reasonRuleSiteSecurity', reason: OzoneReportDefs.REASONRULESITESECURITY,
}, },
{ {
title: _(msg`Stolen Content`), title: _(msg`Stolen Content`),
reason: 'tools.ozone.report.defs#reasonRuleStolenContent', reason: OzoneReportDefs.REASONRULESTOLENCONTENT,
}, },
{ {
title: _(msg`Promoting or Selling Prohibited Items or Services`), title: _(msg`Promoting or Selling Prohibited Items or Services`),
reason: 'tools.ozone.report.defs#reasonRuleProhibitedSales', reason: OzoneReportDefs.REASONRULEPROHIBITEDSALES,
}, },
{ {
title: _(msg`Banned User Returning`), title: _(msg`Banned User Returning`),
reason: 'tools.ozone.report.defs#reasonRuleBanEvasion', reason: OzoneReportDefs.REASONRULEBANEVASION,
}, },
{ {
title: _(msg`Other Network Rule-breaking`), title: _(msg`Other Network Rule-breaking`),
reason: 'tools.ozone.report.defs#reasonRuleOther', reason: OzoneReportDefs.REASONRULEOTHER,
}, },
], ],
}, },
@@ -270,27 +249,23 @@ export function useReportOptions() {
options: [ options: [
{ {
title: _(msg`Electoral Process Violations`), title: _(msg`Electoral Process Violations`),
reason: 'tools.ozone.report.defs#reasonCivicElectoralProcess', reason: OzoneReportDefs.REASONCIVICELECTORALPROCESS,
}, },
{ {
title: _(msg`Disclosure and Transparency Violations`), title: _(msg`Disclosure and Transparency Violations`),
reason: 'tools.ozone.report.defs#reasonCivicDisclosure', reason: OzoneReportDefs.REASONCIVICDISCLOSURE,
}, },
{ {
title: _(msg`Voter Intimidation or Interference`), title: _(msg`Voter Intimidation or Interference`),
reason: 'tools.ozone.report.defs#reasonCivicInterference', reason: OzoneReportDefs.REASONCIVICINTERFERENCE,
}, },
{ {
title: _(msg`Election Misinformation`), title: _(msg`Election Misinformation`),
reason: 'tools.ozone.report.defs#reasonCivicMisinformation', reason: OzoneReportDefs.REASONCIVICMISINFORMATION,
}, },
{ {
title: _(msg`Impersonation of Electoral Officials or Entities`), title: _(msg`Impersonation of Electoral Officials or Entities`),
reason: 'tools.ozone.report.defs#reasonCivicImpersonation', reason: OzoneReportDefs.REASONCIVICIMPERSONATION,
},
{
title: _(msg`Other Civic Integrity Issue`),
reason: 'tools.ozone.report.defs#reasonViolenceOther',
}, },
], ],
}, },
@@ -302,7 +277,7 @@ export function useReportOptions() {
options: [ options: [
{ {
title: _(msg`Other`), title: _(msg`Other`),
reason: 'com.atproto.moderation.defs#reasonOther', reason: RootReportDefs.REASONOTHER,
}, },
], ],
isOther: true, isOther: true,
@@ -310,7 +285,7 @@ export function useReportOptions() {
} }
const sortedCategories = ( const sortedCategories = (
Object.values(categories) as ReportOptionCategory[] Object.values(categories) as ReportCategoryConfig[]
).sort((a, b) => a.sort - b.sort) ).sort((a, b) => a.sort - b.sort)
const getCategory = (reasonName: ReportCategory) => { const getCategory = (reasonName: ReportCategory) => {
@@ -319,28 +294,3 @@ export function useReportOptions() {
return {categories, sortedCategories, getCategory} return {categories, sortedCategories, getCategory}
} }
const DeprecatedReportReasonMapping: Partial<Record<ReasonType, ReasonType>> = {
'tools.ozone.report.defs#reasonMisleadingSpam':
'com.atproto.moderation.defs#reasonSpam',
'tools.ozone.report.defs#reasonRuleOther':
'com.atproto.moderation.defs#reasonViolation',
'tools.ozone.report.defs#reasonMisleadingOther':
'com.atproto.moderation.defs#reasonMisleading',
'tools.ozone.report.defs#reasonSexualUnlabeled':
'com.atproto.moderation.defs#reasonSexual',
'tools.ozone.report.defs#reasonHarassmentOther':
'com.atproto.moderation.defs#reasonRude',
'tools.ozone.report.defs#reasonAppeal':
'com.atproto.moderation.defs#reasonAppeal',
}
export function newReportReasonToDeprecatedReason(
newReason: ReasonType,
): ReasonType {
const maybeReason = DeprecatedReportReasonMapping[newReason]
if (maybeReason) {
return maybeReason
}
return 'com.atproto.moderation.defs#reasonOther'
}