diff --git a/src/screens/ModerationInbox/Notice.tsx b/src/screens/ModerationInbox/Notice.tsx
index a77bb3ef7..777fd1e63 100644
--- a/src/screens/ModerationInbox/Notice.tsx
+++ b/src/screens/ModerationInbox/Notice.tsx
@@ -37,10 +37,16 @@ import * as Toast from '#/components/Toast'
import {Text} from '#/components/Typography'
import {useAnalytics} from '#/analytics'
import {tools} from '#/lexicons'
+import {AccountActionTimeline} from './components/AccountActionTimeline'
import {ActionSummaryText} from './components/ActionSummaryText'
import {ContentBlock} from './components/ContentBlock'
import {useActionedSubjectLabels} from './components/hooks/useActionedSubjectLabels'
import {ReportSubjectPreview} from './components/ReportSubjectPreview'
+import {
+ appealAction,
+ appealReference,
+ currentAccountAction,
+} from './components/util/accountActions'
import {getNoticeLabels} from './components/util/noticeLabels'
export function ModerationInboxNoticeDetailsScreen({
@@ -205,25 +211,22 @@ function NoticeDetails({
const ax = useAnalytics()
const appealDialogControl = Dialog.useDialogControl()
const labels = getNoticeLabels(data)
+ const isAccount = 'did' in data.subject
+ const currentAction =
+ isAccount &&
+ (data.enforcement.state === 'takendown' ||
+ data.enforcement.state === 'suspended')
+ ? currentAccountAction(data, actions)
+ : data.actions[0]
const actionLabels = useActionedSubjectLabels({
src: data.src,
subject: data.subject,
enforcement: data.enforcement,
- latestAction: data.actions[0],
+ latestAction: currentAction,
})
- const policies = data.actions[0]?.policies ?? []
+ const policies = currentAction?.policies ?? []
const canAppeal = data.availableActions?.includes('appeal') ?? false
- const isAccount = 'did' in data.subject
- const appealedAction = actions.find(
- action =>
- !action.reversedAt &&
- [
- 'contentRemoved',
- 'accountSuspended',
- 'accountTakedown',
- 'labelApplied',
- ].includes(action.type),
- )
+ const appealedAction = appealAction(data, actions)
return (
<>
@@ -237,8 +240,8 @@ function NoticeDetails({
Your appeal has been submitted and is awaiting review.
- ) : data.actions[0]?.type === 'contentRemoved' &&
- !data.actions[0]?.reversedAt ? (
+ ) : currentAction?.type === 'contentRemoved' &&
+ !currentAction.reversedAt ? (
{serviceName} removed your content for violating our{' '}
- {(data.actions[0]?.type === 'labelApplied' ||
- data.actions[0]?.type === 'labelRemoved') &&
+ {(currentAction?.type === 'labelApplied' ||
+ currentAction?.type === 'labelRemoved') &&
actionLabels?.summary ? (
{actionLabels.summary}
@@ -338,6 +341,7 @@ function NoticeDetails({
) : null}
+ {isAccount && }
+
+ {actions.map((action, index) => (
+
+ ))}
+
+
+ )
+}
+
+function AccountAction({
+ data,
+ action,
+ last,
+}: {
+ data: Detail
+ action: Action
+ last: boolean
+}) {
+ const t = useTheme()
+ const labels = useActionedSubjectLabels({
+ src: data.src,
+ subject: data.subject,
+ enforcement: data.enforcement,
+ latestAction: action,
+ })
+ if (!labels) return null
+ return (
+
+
+
+ {!last && (
+
+ )}
+
+
+
+ {labels.subject}
+
+ {(action.type === 'labelApplied' || action.type === 'labelRemoved') &&
+ labels.summary ? (
+
+ {labels.summary}
+
+ ) : null}
+ {action.policies?.map(policy => (
+
+
+ {policy.displayName}
+
+
+ ))}
+ {action.reversedAt ? (
+
+ Action reversed
+
+ ) : null}
+
+
+ )
+}
diff --git a/src/screens/ModerationInbox/components/AccountStatus.tsx b/src/screens/ModerationInbox/components/AccountStatus.tsx
index facbcf980..1c43738bf 100644
--- a/src/screens/ModerationInbox/components/AccountStatus.tsx
+++ b/src/screens/ModerationInbox/components/AccountStatus.tsx
@@ -9,55 +9,105 @@ import {ExclamationCircle_Stroke2_Corner0_Rounded as ExclamationCircleIcon} from
import * as Prompt from '#/components/Prompt'
import {Text} from '#/components/Typography'
import {useAnalytics} from '#/analytics'
+import {type AccountEnforcement} from './util/accountData'
export function AccountStatus({
status,
+ enforcement,
+ hasActiveStrikes,
}: {
status: 'good' | 'warning' | 'atRisk'
+ enforcement?: AccountEnforcement
+ hasActiveStrikes?: boolean
}) {
const t = useTheme()
- const {t: l} = useLingui()
+ const {i18n, t: l} = useLingui()
const ax = useAnalytics()
const markSeen = useUpdateModerationInboxSeenMutation({silent: true})
const control = Prompt.usePromptControl()
+ const isTakenDown = enforcement?.state === 'takendown'
+ const isSuspended = enforcement?.state === 'suspended'
if (status === 'good') return null
- const Icon = status === 'atRisk' ? ExclamationCircleIcon : CircleInfoIcon
- const iconColor =
- status === 'atRisk' ? t.palette.negative_500 : t.palette.yellow
+ const isSerious = status === 'atRisk' || isTakenDown || isSuspended
+ const Icon = isSerious ? ExclamationCircleIcon : CircleInfoIcon
+ const iconColor = isSerious ? t.palette.negative_500 : t.palette.yellow
- const title =
- status === 'atRisk'
- ? l`Your account is at risk of permanent suspension`
- : l`Your account has strikes against it`
- const description =
- status === 'atRisk' ? (
-
- We’ve taken action on your account for violating our Community
- Guidelines. Your record now carries enough strikes that another
- violation could lead to permanent suspension.
-
- ) : (
+ const title = isTakenDown
+ ? l`Your account has been suspended`
+ : isSuspended
+ ? l`Your account is temporarily suspended`
+ : status === 'atRisk' && enforcement
+ ? l`Your account is at risk of permanent suspension`
+ : status === 'atRisk'
+ ? l`Your account may be suspended or at risk of suspension`
+ : hasActiveStrikes
+ ? l`Your account has strikes against it`
+ : l`Your account has moderation actions`
+ const description = isTakenDown ? (
+
+ Your account is suspended on Bluesky. See your notices for details and
+ available appeal options.
+
+ ) : isSuspended ? (
+
+ Your account is temporarily suspended on Bluesky. See your notices for
+ details and available appeal options.
+
+ ) : status === 'atRisk' && enforcement && hasActiveStrikes ? (
+
+ We’ve taken action on your account for violating our Community Guidelines.
+ Your record now carries enough strikes that another violation could lead
+ to permanent suspension.
+
+ ) : status === 'atRisk' && enforcement ? (
+
+ Further violations of our Community Guidelines could lead to permanent
+ suspension.
+
+ ) : status === 'atRisk' ? (
+
+ Your account may already be suspended or at risk of suspension. See your
+ notices for details.
+
+ ) : hasActiveStrikes ? (
+
+ We’ve taken action on your account for violating our Community Guidelines,
+ and strikes have been added to your record. More violations will lead to
+ stronger enforcement, including suspension.
+
+ ) : (
+
+ We’ve taken action on your account. See your notices for details.
+
+ )
+ const scheduledEnd =
+ isSuspended && enforcement?.expiresAt ? (
- We’ve taken action on your account for violating our Community
- Guidelines, and strikes have been added to your record. More violations
- will lead to stronger enforcement, including suspension.
+ Scheduled end:{' '}
+ {i18n.date(new Date(enforcement.expiresAt), {
+ dateStyle: 'medium',
+ timeStyle: 'short',
+ })}
- )
- const disclaimer =
- status === 'atRisk' ? (
+ ) : null
+ const disclaimer = hasActiveStrikes ? (
+ isTakenDown || isSuspended ? (
- Your standing may restrict certain features on your account. Strikes
- come off your record over time.
+ Your account has strikes against it. Strikes come off your record over
+ time.
) : (
- Your standing doesn’t restrict your account right now, and strikes come
- off your record over time.
+ Some account features may be restricted. Strikes come off your record
+ over time.
)
+ ) : !isTakenDown && !isSuspended ? (
+ Some account features may be restricted.
+ ) : null
return (
<>
@@ -91,7 +141,12 @@ export function AccountStatus({
{title}
{description}
- {disclaimer}
+ {scheduledEnd ? (
+ {scheduledEnd}
+ ) : null}
+ {disclaimer ? (
+ {disclaimer}
+ ) : null}
control.close()} />
diff --git a/src/screens/ModerationInbox/components/ReportRow.tsx b/src/screens/ModerationInbox/components/ReportRow.tsx
index ed0cea487..b697a6022 100644
--- a/src/screens/ModerationInbox/components/ReportRow.tsx
+++ b/src/screens/ModerationInbox/components/ReportRow.tsx
@@ -12,6 +12,7 @@ export function ReportRow({
action,
date,
dateEnd,
+ dateLabel,
to,
unread,
}: {
@@ -19,6 +20,7 @@ export function ReportRow({
action?: string
date: Date
dateEnd?: Date
+ dateLabel?: string
to: React.ComponentProps['to']
unread?: boolean
}) {
@@ -57,6 +59,7 @@ export function ReportRow({
{action}
) : undefined}
+ {dateLabel ? `${dateLabel} ` : undefined}
{dateEnd
? `${i18n.date(date, {
month: 'short',
diff --git a/src/screens/ModerationInbox/components/ReportSubjectPreview/AccountSubjectPreview.tsx b/src/screens/ModerationInbox/components/ReportSubjectPreview/AccountSubjectPreview.tsx
index 65f2cae5c..94828df12 100644
--- a/src/screens/ModerationInbox/components/ReportSubjectPreview/AccountSubjectPreview.tsx
+++ b/src/screens/ModerationInbox/components/ReportSubjectPreview/AccountSubjectPreview.tsx
@@ -1,18 +1,44 @@
import {Trans, useLingui} from '@lingui/react/macro'
+import {sanitizeDisplayName} from '#/lib/strings/display-names'
+import {sanitizeHandle} from '#/lib/strings/handles'
import {UserAvatar} from '#/view/com/util/UserAvatar'
import {useSubjectPreviewProfile} from '#/screens/ModerationInbox/components/hooks/useSubjectPreviewProfile'
import {atoms as a} from '#/alf'
import {Text} from '#/components/Typography'
+import {app} from '#/lexicons'
+import {type AccountPreview} from '../util/accountData'
import {PreviewContent} from './PreviewContent'
-export function AccountSubjectPreview({did}: {did: string}) {
+export function AccountSubjectPreview({
+ did,
+ account,
+}: {
+ did: string
+ account?: AccountPreview
+}) {
const {i18n, t: l} = useLingui()
const {query, profile, moderation, name, handle} =
useSubjectPreviewProfile(did)
let content: React.ReactNode
let avatar: React.ReactNode
const metadataText: string[] = []
+ const snapshot = account?.profile
+ const displayName =
+ snapshot &&
+ typeof snapshot === 'object' &&
+ '$type' in snapshot &&
+ snapshot.$type === app.bsky.actor.profile.$type &&
+ 'displayName' in snapshot &&
+ typeof snapshot.displayName === 'string'
+ ? snapshot.displayName
+ : undefined
+ const fallbackName = displayName
+ ? sanitizeDisplayName(displayName)
+ : undefined
+ const fallbackHandle = account?.handle
+ ? sanitizeHandle(account.handle, '@')
+ : undefined
if (profile && moderation) {
avatar = (
@@ -36,8 +62,8 @@ export function AccountSubjectPreview({did}: {did: string}) {
}
} else {
content = (
-
- Account unavailable
+
+ {fallbackHandle || (account ? did : Account unavailable)}
)
}
@@ -45,9 +71,9 @@ export function AccountSubjectPreview({did}: {did: string}) {
return (
+ preview = (
+
+ )
} else {
switch (uri?.collection) {
case 'app.bsky.feed.post':
diff --git a/src/screens/ModerationInbox/components/YourAccountRow.tsx b/src/screens/ModerationInbox/components/YourAccountRow.tsx
index 89d2e8f9c..bf090a1f8 100644
--- a/src/screens/ModerationInbox/components/YourAccountRow.tsx
+++ b/src/screens/ModerationInbox/components/YourAccountRow.tsx
@@ -1,8 +1,11 @@
+import {useLingui} from '@lingui/react/macro'
+
import {
type ActionedSubject,
useActionedSubjectLabels,
} from './hooks/useActionedSubjectLabels'
import {ReportRow} from './ReportRow'
+import {isAppealDecision} from './util/accountActions'
export function YourAccountRow({
item,
@@ -11,8 +14,39 @@ export function YourAccountRow({
item: ActionedSubject
unread: boolean
}) {
- const labels = useActionedSubjectLabels(item)
+ const {t: l} = useLingui()
const action = item.latestAction
+ const labels = useActionedSubjectLabels(item)
+ const isAccount = 'did' in item.subject
+ const status =
+ isAccount && item.enforcement.state === 'takendown'
+ ? l`Your account is suspended`
+ : isAccount && item.enforcement.state === 'suspended'
+ ? l`Your account is temporarily suspended`
+ : undefined
+ const newerAction =
+ item.appeal?.state === 'resolved' &&
+ item.appeal.resolvedAt &&
+ action &&
+ Date.parse(action.createdAt) > Date.parse(item.appeal.resolvedAt)
+ const appealStatus = isAccount
+ ? item.appeal?.state === 'pending'
+ ? l`Appeal under review`
+ : item.appeal?.state === 'resolved' &&
+ (!newerAction || !action || !isAppealDecision(action))
+ ? newerAction
+ ? item.appeal.outcome === 'approved'
+ ? l`Previous appeal approved`
+ : item.appeal.outcome === 'denied'
+ ? l`Previous appeal denied`
+ : l`Previous appeal resolved`
+ : item.appeal.outcome === 'approved'
+ ? l`Appeal approved`
+ : item.appeal.outcome === 'denied'
+ ? l`Appeal denied`
+ : l`Appeal resolved`
+ : undefined
+ : undefined
const subject =
'did' in item.subject && typeof item.subject.did === 'string'
? item.subject.did
@@ -20,16 +54,17 @@ export function YourAccountRow({
? item.subject.uri
: undefined
- if (!action || !labels || !subject) return null
+ if (!subject || (!status && (!action || !labels))) return null
- const dateEnd = action.reversedAt ?? action.expiresAt
+ const dateEnd = status ? undefined : (action?.reversedAt ?? action?.expiresAt)
return (
@@ -51,8 +51,16 @@ export function useActionedSubjectLabels(
? l`Violates Community Guideline: ${policyLabel}`
: undefined
break
+ case 'contentRestored':
+ subject = isPost
+ ? l`Your post was restored`
+ : l`Your content was restored`
+ break
+ case 'accountRestored':
+ subject = l`Your account was restored`
+ break
case 'communicationSent':
- subject = l`We sent you an email about your account`
+ subject = l`An email was sent about your account`
summary = policyLabel
break
case 'labelApplied':
@@ -108,7 +116,8 @@ export function useActionedSubjectLabels(
summary = labelName ? l`Label: ${labelName}` : undefined
break
default:
- return
+ subject = l`Moderation notice`
+ break
}
return {subject, summary}
diff --git a/src/screens/ModerationInbox/components/util/accountActions.ts b/src/screens/ModerationInbox/components/util/accountActions.ts
new file mode 100644
index 000000000..a3d58858b
--- /dev/null
+++ b/src/screens/ModerationInbox/components/util/accountActions.ts
@@ -0,0 +1,56 @@
+import {type tools} from '#/lexicons'
+
+type Detail = tools.ozone.inbox.getActionedSubject.$OutputBody
+type Action = tools.ozone.inbox.defs.ActionView
+
+export function isAppealDecision(action: Action) {
+ return [
+ 'contentRemoved',
+ 'accountSuspended',
+ 'accountTakedown',
+ 'labelApplied',
+ ].includes(action.type)
+}
+
+export function currentAccountAction(data: Detail, actions: Action[]) {
+ if (!('did' in data.subject)) return
+ const type =
+ data.enforcement.state === 'takendown'
+ ? 'accountTakedown'
+ : data.enforcement.state === 'suspended'
+ ? 'accountSuspended'
+ : undefined
+ return type
+ ? actions.find(action => action.type === type && !action.reversedAt)
+ : undefined
+}
+
+export function appealAction(data: Detail, actions: Action[]) {
+ if (
+ 'did' in data.subject &&
+ (data.enforcement.state === 'takendown' ||
+ data.enforcement.state === 'suspended')
+ ) {
+ return currentAccountAction(data, actions)
+ }
+ return actions.find(action => !action.reversedAt && isAppealDecision(action))
+}
+
+export function appealReference(data: Detail, action?: Action) {
+ if (action) {
+ return {
+ $type: 'tools.ozone.inbox.appealActionedSubject#actionRef' as const,
+ id: action.id,
+ }
+ }
+ if (
+ 'did' in data.subject &&
+ (data.enforcement.state === 'takendown' ||
+ data.enforcement.state === 'suspended')
+ ) {
+ // Both temporary and permanent account restrictions use takedown events.
+ return {
+ $type: 'tools.ozone.inbox.appealActionedSubject#takedownRef' as const,
+ }
+ }
+}
diff --git a/src/screens/ModerationInbox/components/util/accountData.ts b/src/screens/ModerationInbox/components/util/accountData.ts
new file mode 100644
index 000000000..9fb0e345a
--- /dev/null
+++ b/src/screens/ModerationInbox/components/util/accountData.ts
@@ -0,0 +1,47 @@
+/** Optional fields sent by Ozone before the updated inbox Lexicons are published. */
+export type AccountPreview = {handle?: string; profile?: unknown}
+export type AccountEnforcement = {
+ state: 'none' | 'suspended' | 'takendown'
+ expiresAt?: string
+}
+
+export function getHasActiveStrikes(data: unknown): boolean | undefined {
+ if (!data || typeof data !== 'object' || !('hasActiveStrikes' in data)) return
+ return typeof data.hasActiveStrikes === 'boolean'
+ ? data.hasActiveStrikes
+ : undefined
+}
+
+export function getAccountPreview(data: unknown): AccountPreview | undefined {
+ if (!data || typeof data !== 'object' || !('account' in data)) return
+ const account = data.account
+ if (!account || typeof account !== 'object') return
+ return {
+ handle:
+ 'handle' in account && typeof account.handle === 'string'
+ ? account.handle
+ : undefined,
+ profile: 'profile' in account ? account.profile : undefined,
+ }
+}
+
+export function getAccountEnforcement(
+ data: unknown,
+): AccountEnforcement | undefined {
+ if (!data || typeof data !== 'object' || !('enforcement' in data)) return
+ const value = data.enforcement
+ if (!value || typeof value !== 'object' || !('state' in value)) return
+ if (
+ value.state !== 'none' &&
+ value.state !== 'suspended' &&
+ value.state !== 'takendown'
+ )
+ return
+ const expiresAt =
+ 'expiresAt' in value &&
+ typeof value.expiresAt === 'string' &&
+ Number.isFinite(Date.parse(value.expiresAt))
+ ? value.expiresAt
+ : undefined
+ return {state: value.state, expiresAt}
+}
diff --git a/src/screens/ModerationInbox/components/util/noticeLabels.ts b/src/screens/ModerationInbox/components/util/noticeLabels.ts
index 076c66b69..9ad68d250 100644
--- a/src/screens/ModerationInbox/components/util/noticeLabels.ts
+++ b/src/screens/ModerationInbox/components/util/noticeLabels.ts
@@ -2,6 +2,7 @@ import {AtUri, isAtUriString} from '@atproto/syntax'
import {msg, plural} from '@lingui/core/macro'
import {type tools} from '#/lexicons'
+import {currentAccountAction, isAppealDecision} from './accountActions'
import {getReportActionLabel} from './reportActionLabel'
/** Labels reflect explicit appeal outcomes and the current moderation state. */
@@ -9,6 +10,7 @@ export function getNoticeLabels(
data: tools.ozone.inbox.getActionedSubject.$OutputBody,
) {
const action = data.actions[0]
+ const latestDecision = data.actions.find(isAppealDecision)
const isAccount = 'did' in data.subject
const isPost =
'uri' in data.subject &&
@@ -23,8 +25,9 @@ export function getNoticeLabels(
const appealResolved =
data.appeal?.state === 'resolved' &&
(!data.appeal.resolvedAt ||
- !action ||
- Date.parse(data.appeal.resolvedAt) >= Date.parse(action.createdAt))
+ !latestDecision ||
+ Date.parse(data.appeal.resolvedAt) >=
+ Date.parse(latestDecision.createdAt))
let header =
getReportActionLabel({
status: '',
@@ -50,10 +53,16 @@ export function getNoticeLabels(
header = msg`Appeal resolved`
break
}
+ } else if (isAccount && data.enforcement.state === 'takendown') {
+ header = msg`Your account is suspended`
+ } else if (isAccount && data.enforcement.state === 'suspended') {
+ header = msg`Your account is temporarily suspended`
} else if (action?.reversedAt) {
header = isAccount
? msg`The action against your account was reversed`
: msg`The action against your content was reversed`
+ } else if (isAccount && action?.type === 'communicationSent') {
+ header = msg`An email was sent about your account`
} else if (action?.type === 'accountSuspended' && action.expiresAt) {
const hours = Math.max(
0,
@@ -98,7 +107,11 @@ export function getNoticeLabels(
? data.appeal.appealedAt
: appealResolved
? data.appeal?.resolvedAt
- : (action?.reversedAt ?? action?.createdAt)
+ : isAccount &&
+ (data.enforcement.state === 'takendown' ||
+ data.enforcement.state === 'suspended')
+ ? currentAccountAction(data, data.actions)?.createdAt
+ : (action?.reversedAt ?? action?.createdAt)
return {header, blockHeader, date, appealResolved, appealSummary}
}
diff --git a/src/screens/ModerationInbox/index.tsx b/src/screens/ModerationInbox/index.tsx
index 9fb685f26..6800e8358 100644
--- a/src/screens/ModerationInbox/index.tsx
+++ b/src/screens/ModerationInbox/index.tsx
@@ -17,6 +17,7 @@ import {logger} from '#/logger'
import {
useModerationInboxAccountStatusQuery,
useModerationInboxActionedSubjectsQuery,
+ useModerationInboxCacheMutation,
useModerationInboxReportsQuery,
useModerationInboxUnreadCountQuery,
useUpdateModerationInboxSeenMutation,
@@ -39,6 +40,10 @@ import {type tools} from '#/lexicons'
import {AccountStatus} from './components/AccountStatus'
import {FilterMenu} from './components/FilterMenu'
import {type ActionedSubject} from './components/hooks/useActionedSubjectLabels'
+import {
+ getAccountEnforcement,
+ getHasActiveStrikes,
+} from './components/util/accountData'
import {YourAccountRow} from './components/YourAccountRow'
import {YourReportRow} from './components/YourReportRow'
@@ -264,6 +269,7 @@ function YourAccount() {
const [isPTRing, setIsPTRing] = useState(false)
const [filter, setFilter] = useState('all')
const actionedSubjectsQuery = useModerationInboxActionedSubjectsQuery(filter)
+ const invalidateInbox = useModerationInboxCacheMutation()
const accountStatusQuery = useModerationInboxAccountStatusQuery()
const unreadCountQuery = useModerationInboxUnreadCountQuery()
const markSeen = useUpdateModerationInboxSeenMutation()
@@ -285,11 +291,7 @@ function YourAccount() {
const onRefresh = async () => {
setIsPTRing(true)
try {
- await Promise.all([
- actionedSubjectsQuery.refetch(),
- accountStatusQuery.refetch(),
- unreadCountQuery.refetch(),
- ])
+ await invalidateInbox()
} catch (err) {
logger.error('Failed to refresh moderation inbox account', {error: err})
} finally {
@@ -343,7 +345,13 @@ function YourAccount() {
) : undefined}
) : undefined}
- {accountStanding ? : undefined}
+ {accountStanding ? (
+
+ ) : undefined}
)
diff --git a/src/state/queries/moderation-inbox.ts b/src/state/queries/moderation-inbox.ts
index 9caf814a5..e5517af56 100644
--- a/src/state/queries/moderation-inbox.ts
+++ b/src/state/queries/moderation-inbox.ts
@@ -219,9 +219,9 @@ export function useModerationInboxCacheMutation() {
subject,
})
await queryClient.cancelQueries({queryKey: subjectQueryKey})
- queryClient.setQueryData<
+ queryClient.setQueriesData<
InfiniteData
- >(subjectQueryKey, data =>
+ >({queryKey: subjectQueryKey}, data =>
data
? {
...data,