d1ba666495
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 12s
CI / ui (pull_request) Successful in 45s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m10s
Operator-driven hard block, the counterpart to the soft high-rate flag: permanent or until a date, with an optional reason chosen from an editable en+ru picklist (snapshotted onto the block). A block forfeits the player's active games (opponent wins, as a resignation) and cancels their open matchmaking games. A backend gate refuses a blocked account on every /api/v1/user/* route except the block-status probe with 403 account_blocked, which threads through the gateway as the Execute result_code; the UI surfaces it as a terminal blocked screen and stops all push/poll. Temporary blocks self-expire; the operator can unblock at any time (lost games stay lost). Sessions are not revoked, so the blocked client can still reach the exempt block-status endpoint. Backend: migration 00003 (account_suspensions + suspension_reasons) + jet regen; account suspension store; game.ForfeitAllForAccount; requireNotSuspended gate + block-status endpoint; admin console block/unblock + Reasons CRUD. Wire: fbs BlockStatus + account.block_status gateway op. UI: blocked screen, app state, transport/codec, i18n. Docs: ARCHITECTURE, FUNCTIONAL(+ru), PRERELEASE (AB).
28 lines
965 B
TypeScript
28 lines
965 B
TypeScript
// Pure helpers for the terminal blocked screen, kept out of the .svelte component so they are
|
|
// unit-testable in the node vitest env.
|
|
|
|
import type { Locale } from './i18n/index.svelte';
|
|
|
|
/**
|
|
* formatBlockUntil renders a temporary block's RFC3339 UTC expiry in the user's locale and
|
|
* timezone, e.g. "1 Jul 2026, 15:00". It falls back to UTC formatting when the timezone is
|
|
* unknown/invalid, and to the raw string when the instant cannot be parsed at all.
|
|
*/
|
|
export function formatBlockUntil(until: string, locale: Locale, timeZone: string): string {
|
|
const d = new Date(until);
|
|
if (Number.isNaN(d.getTime())) return until;
|
|
try {
|
|
return new Intl.DateTimeFormat(locale, {
|
|
dateStyle: 'medium',
|
|
timeStyle: 'short',
|
|
timeZone: timeZone || undefined,
|
|
}).format(d);
|
|
} catch {
|
|
try {
|
|
return new Intl.DateTimeFormat(locale, { dateStyle: 'medium', timeStyle: 'short' }).format(d);
|
|
} catch {
|
|
return until;
|
|
}
|
|
}
|
|
}
|