diff --git a/.env.example b/.env.example index b1ccdbc95d..592cac6762 100644 --- a/.env.example +++ b/.env.example @@ -4,6 +4,7 @@ APP_KEY= APP_DEBUG=true APP_URL=http://localhost:8000 ADMINS= +MODERATORS= APP_LOCALE=en APP_FALLBACK_LOCALE=en diff --git a/app/Actions/CreateCommitEscalation.php b/app/Actions/CreateCommitEscalation.php new file mode 100644 index 0000000000..12052ba043 --- /dev/null +++ b/app/Actions/CreateCommitEscalation.php @@ -0,0 +1,53 @@ +escalated_at !== null) { + return; + } + + /** @var Collection $admins */ + $admins = User::query()->get()->filter(fn (User $user): bool => $user->isAdmin()); + + if ($admins->isEmpty()) { + $commit->forceFill(['escalated_at' => now()])->save(); + + return; + } + + $notifications = $admins->map(fn (User $admin): array => [ + 'id' => Str::uuid7()->toString(), + 'recipient_id' => $admin->id, + 'actor_id' => $moderator->id, + 'type' => NotificationType::Escalated->value, + 'commit_id' => $commit->id, + 'key' => 'escalated:'.$commit->id, + 'created_at' => now(), + 'updated_at' => now(), + ])->all(); + + DB::transaction(function () use ($commit, $notifications): void { + $commit->forceFill(['escalated_at' => now()])->save(); + + Notification::query()->upsert($notifications, ['recipient_id', 'key']); + }); + + event(new UsersUpdated($admins->pluck('id')->all(), UserUpdate::Notifications)); + } +} diff --git a/app/Actions/DeleteCommitEscalation.php b/app/Actions/DeleteCommitEscalation.php new file mode 100644 index 0000000000..ba5d815682 --- /dev/null +++ b/app/Actions/DeleteCommitEscalation.php @@ -0,0 +1,40 @@ +escalated_at === null) { + return; + } + + /** @var Collection $admins */ + $admins = User::query()->get()->filter(fn (User $user): bool => $user->isAdmin()); + + DB::transaction(function () use ($commit): void { + $commit->forceFill(['escalated_at' => null])->save(); + + Notification::query() + ->where('type', NotificationType::Escalated) + ->where('key', 'escalated:'.$commit->id) + ->delete(); + }); + + if ($admins->isNotEmpty()) { + event(new UsersUpdated($admins->pluck('id')->all(), UserUpdate::Notifications)); + } + } +} diff --git a/app/Enums/NotificationType.php b/app/Enums/NotificationType.php index 4f091a3409..6595591096 100644 --- a/app/Enums/NotificationType.php +++ b/app/Enums/NotificationType.php @@ -16,4 +16,5 @@ enum NotificationType: string case LeveledUp = 'leveled_up'; case FirstCommit = 'first_commit'; case TimedOut = 'timed_out'; + case Escalated = 'escalated'; } diff --git a/app/Http/Controllers/CommitEscalationController.php b/app/Http/Controllers/CommitEscalationController.php new file mode 100644 index 0000000000..a93ef76aa8 --- /dev/null +++ b/app/Http/Controllers/CommitEscalationController.php @@ -0,0 +1,31 @@ +handle($user, $commit); + + return back(); + } + + public function destroy(DeleteCommitEscalationRequest $request, Commit $commit, DeleteCommitEscalation $action): RedirectResponse + { + $action->handle($commit); + + return back(); + } +} diff --git a/app/Http/Controllers/ModerationController.php b/app/Http/Controllers/ModerationController.php index b6ca5bf8e1..79dd68d03d 100644 --- a/app/Http/Controllers/ModerationController.php +++ b/app/Http/Controllers/ModerationController.php @@ -41,7 +41,7 @@ public function show(ShowModerationRequest $request, #[CurrentUser] User $user): ->oldest() ->oldest('id') ->cursorPaginate(20) - ->through($this->forModerators(...)))), + ->through($this->forModerators(...))))->matchOn('id'), // Of the commits a queue showed, those no longer waiting: decided, deleted or gone. 'decidedCommitIds' => Inertia::optional(function () use ($request): array { $waiting = Commit::query()->pending()->whereKey($request->loaded())->pluck('id'); diff --git a/app/Http/Controllers/ReportedCommitController.php b/app/Http/Controllers/ReportedCommitController.php index e9ff2b120c..2891c768b6 100644 --- a/app/Http/Controllers/ReportedCommitController.php +++ b/app/Http/Controllers/ReportedCommitController.php @@ -19,7 +19,7 @@ public function index(ListReportedCommitsRequest $request, #[CurrentUser] User $user, ReportedCommitsQuery $reports): Response { return Inertia::render('moderation/reports', [ - 'reports' => Inertia::scroll(fn (): CursorPaginator => ShownStreams::reports($reports->paginate($user))), + 'reports' => Inertia::scroll(fn (): CursorPaginator => ShownStreams::reports($reports->paginate($user)))->matchOn('id'), 'reportChanges' => Inertia::optional(fn (): array => $reports->changedSince($user, $request->since())), 'reasons' => CommitReport::REASONS, ]); diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 0eaaefc559..074f984539 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -63,7 +63,7 @@ public function show(ShowUserRequest $request, #[CurrentUser] ?User $currentUser // viewer's relationship to them on the viewer's own. $profile = new Channel('profiles.'.$user->id); $relationship = fn (Closure $value): Closure|LiveProp => $currentUser instanceof User ? Inertia::live($value, UserUpdate::Account->value, new PrivateChannel($currentUser)) : $value; - $canSeeModerationHistory = $currentUser instanceof User && ($currentUser->is($user) || ($currentUser->isAdmin() && ! $user->isAdmin())); + $canSeeModerationHistory = $currentUser instanceof User && ($currentUser->is($user) || ($currentUser->canModerate() && ! $user->isAdmin())); return Inertia::render('user/show', [ 'user' => Inertia::live(fn (): ?array => ShownStreams::user($getCountedUser()), 'profile', $profile), diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php index 3990f2f6a1..fb1987c543 100644 --- a/app/Http/Middleware/HandleInertiaRequests.php +++ b/app/Http/Middleware/HandleInertiaRequests.php @@ -87,6 +87,7 @@ public function onVersionChange(Request $request, Response $response): Response public function share(Request $request): array { $isAdmin = $request->user()?->isAdmin() ?? false; + $canModerate = $request->user()?->canModerate() ?? false; $user = $request->user(); $showsWhoToFollow = $user instanceof User && $request->cookie('who_to_follow') !== 'false'; $context = match (true) { @@ -140,6 +141,7 @@ public function share(Request $request): array ->map(fn (Organization $organization): array => ['type' => 'organization', ...$organization->toArray()]) ->all() : [], UserUpdate::Account), 'isAdmin' => $isAdmin, + 'canModerate' => $canModerate, 'automaticTranslation' => $live(fn (): bool => $user->automatic_translation ?? true, UserUpdate::Account), // The language translations are read in, saved or from the browser, so a change saved elsewhere reaches // the translations already shown. @@ -163,7 +165,7 @@ public function share(Request $request): array ], // Guests see how many developers are here, next to the sign-in button... 'developersCount' => fn (): ?int => $user instanceof User ? null : resolve(DevelopersCountQuery::class)->get(), - 'hasUnmoderatedCommits' => $isAdmin ? $live(fn (): bool => Commit::query()->awaitingModerator()->exists(), UserUpdate::Moderation) : false, + 'hasUnmoderatedCommits' => $canModerate ? $live(fn (): bool => Commit::query()->awaitingModerator()->exists(), UserUpdate::Moderation) : false, // The lite mobile app, which draws its own tab bar (see resources/js/lib/lite-mobile-app.ts). Any browser can send this // token, so it only ever changes the UI... 'isLiteMobileApp' => str_contains((string) $request->userAgent(), 'DevNullLite/'), diff --git a/app/Http/Requests/CreateCommitApprovalRequest.php b/app/Http/Requests/CreateCommitApprovalRequest.php index 65dd2473c7..37b43da3d0 100644 --- a/app/Http/Requests/CreateCommitApprovalRequest.php +++ b/app/Http/Requests/CreateCommitApprovalRequest.php @@ -14,7 +14,7 @@ public function authorize(): bool $user = $this->user(); assert($user instanceof User); - return $user->isAdmin(); + return $user->canModerate(); } /** diff --git a/app/Http/Requests/CreateCommitEscalationRequest.php b/app/Http/Requests/CreateCommitEscalationRequest.php new file mode 100644 index 0000000000..521d967c3b --- /dev/null +++ b/app/Http/Requests/CreateCommitEscalationRequest.php @@ -0,0 +1,27 @@ +user(); + assert($user instanceof User); + + return $user->canModerate(); + } + + /** + * @return array{} + */ + public function rules(): array + { + return []; + } +} diff --git a/app/Http/Requests/CreateCommitRejectionRequest.php b/app/Http/Requests/CreateCommitRejectionRequest.php index 70a261930c..0f958ade92 100644 --- a/app/Http/Requests/CreateCommitRejectionRequest.php +++ b/app/Http/Requests/CreateCommitRejectionRequest.php @@ -14,7 +14,7 @@ public function authorize(): bool $user = $this->user(); assert($user instanceof User); - return $user->isAdmin(); + return $user->canModerate(); } /** diff --git a/app/Http/Requests/DeleteCommitEscalationRequest.php b/app/Http/Requests/DeleteCommitEscalationRequest.php new file mode 100644 index 0000000000..12bef01515 --- /dev/null +++ b/app/Http/Requests/DeleteCommitEscalationRequest.php @@ -0,0 +1,27 @@ +user(); + assert($user instanceof User); + + return $user->canModerate(); + } + + /** + * @return array{} + */ + public function rules(): array + { + return []; + } +} diff --git a/app/Http/Requests/DeleteCommitReportRequest.php b/app/Http/Requests/DeleteCommitReportRequest.php index bcbcc803ed..eff481bfd9 100644 --- a/app/Http/Requests/DeleteCommitReportRequest.php +++ b/app/Http/Requests/DeleteCommitReportRequest.php @@ -20,7 +20,7 @@ public function authorize(): Response $user = $this->user(); assert($user instanceof User); - if (! $user->isAdmin()) { + if (! $user->canModerate()) { return Response::deny(); } diff --git a/app/Http/Requests/ListNotificationsRequest.php b/app/Http/Requests/ListNotificationsRequest.php index ea4d1b5d30..3b1f7c0008 100644 --- a/app/Http/Requests/ListNotificationsRequest.php +++ b/app/Http/Requests/ListNotificationsRequest.php @@ -12,7 +12,7 @@ final class ListNotificationsRequest extends FormRequest { - public const string TYPE_RULE = 'regex:/\A(?:all|none|(?:replies|quotes|stars|mentions|follows|moderation)(?:,(?:replies|quotes|stars|mentions|follows|moderation))*)\z/'; + public const string TYPE_RULE = 'regex:/\A(?:all|none|(?:replies|quotes|stars|mentions|follows|moderation|escalations)(?:,(?:replies|quotes|stars|mentions|follows|moderation|escalations))*)\z/'; public static function rememberedType(Request $request, User $user): string { diff --git a/app/Http/Requests/ListReportedCommitsRequest.php b/app/Http/Requests/ListReportedCommitsRequest.php index ccaac007f4..b4178e1265 100644 --- a/app/Http/Requests/ListReportedCommitsRequest.php +++ b/app/Http/Requests/ListReportedCommitsRequest.php @@ -15,7 +15,7 @@ public function authorize(): bool $user = $this->user(); assert($user instanceof User); - return $user->isAdmin(); + return $user->canModerate(); } /** diff --git a/app/Http/Requests/ShowCommitReportImageRequest.php b/app/Http/Requests/ShowCommitReportImageRequest.php index a25b8cfff2..a8473fd26a 100644 --- a/app/Http/Requests/ShowCommitReportImageRequest.php +++ b/app/Http/Requests/ShowCommitReportImageRequest.php @@ -20,7 +20,7 @@ public function authorize(): Response assert($report instanceof CommitReport); $image = $report->images[(int) $this->route('image')] ?? null; - return ($user->isAdmin() || $report->reporter_id === $user->id) && $image !== null && Storage::disk()->exists($image['path']) + return ($user->canModerate() || $report->reporter_id === $user->id) && $image !== null && Storage::disk()->exists($image['path']) ? Response::allow() : Response::denyAsNotFound(); } diff --git a/app/Http/Requests/ShowModerationRequest.php b/app/Http/Requests/ShowModerationRequest.php index 16f54047e9..307db4dda6 100644 --- a/app/Http/Requests/ShowModerationRequest.php +++ b/app/Http/Requests/ShowModerationRequest.php @@ -15,7 +15,7 @@ public function authorize(): bool $user = $this->user(); assert($user instanceof User); - return $user->isAdmin(); + return $user->canModerate(); } /** diff --git a/app/Http/Resources/CommitResource.php b/app/Http/Resources/CommitResource.php index 39eff8373d..3dbef07424 100644 --- a/app/Http/Resources/CommitResource.php +++ b/app/Http/Resources/CommitResource.php @@ -85,6 +85,7 @@ public function toArray(Request $request): array ...resolve(CommitBodies::class)->segments($this->body), 'mentions' => resolve(Mentions::class)->positions($this->body, $this->organization_mentions ?? []), 'status' => $this->status, + 'escalated_at' => $this->escalated_at?->toIso8601ZuluString(), 'is_pinned' => $this->author?->user?->pinned_commit_id === $this->id, 'starred' => $this->whenHas('starred'), 'pasteis_count' => $this->pasteis_count, diff --git a/app/Models/Commit.php b/app/Models/Commit.php index 93adc3ffd7..5711097156 100644 --- a/app/Models/Commit.php +++ b/app/Models/Commit.php @@ -42,6 +42,7 @@ * @property-read list|null $ai_categories * @property-read list|null $embedding * @property-read CarbonInterface|null $headlines_classified_at + * @property-read CarbonInterface|null $escalated_at * @property-read CarbonInterface $created_at * @property-read CarbonInterface $updated_at * @property-read CarbonInterface|null $deleted_at @@ -143,6 +144,7 @@ public function casts(): array 'ai_categories' => 'array', 'embedding' => AsVector::class, 'headlines_classified_at' => 'datetime', + 'escalated_at' => 'datetime', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'deleted_at' => 'datetime', @@ -369,7 +371,7 @@ public function imagesAreVisibleTo(?User $user): bool return true; } - return $user instanceof User && ($this->user_id === $user->id || $user->isAdmin() || $this->isOwnedBy($user)); + return $user instanceof User && ($this->user_id === $user->id || $user->canModerate() || $this->isOwnedBy($user)); } /** diff --git a/app/Models/User.php b/app/Models/User.php index 30b5b8716f..ecf2ba7bb1 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -509,6 +509,22 @@ public function isAdmin(): bool return in_array(mb_strtolower($this->handle), array_map(mb_strtolower(...), $admins), true); } + /** + * Moderators review the pending queue and user reports, but cannot timeout or ban anyone. + */ + public function isModerator(): bool + { + /** @var list $moderators */ + $moderators = config('app.moderators'); + + return in_array(mb_strtolower($this->handle), array_map(mb_strtolower(...), $moderators), true); + } + + public function canModerate(): bool + { + return $this->isAdmin() || $this->isModerator(); + } + /** * Unlike loadCount(), counts follows on the pivot tables alone: the self-referencing * relations would otherwise join the users table for every follow. Commits are diff --git a/app/Queries/CommitBuilder.php b/app/Queries/CommitBuilder.php index 5ebb4ac9da..55d173cdf6 100644 --- a/app/Queries/CommitBuilder.php +++ b/app/Queries/CommitBuilder.php @@ -38,7 +38,7 @@ final class CommitBuilder extends Builder private const array COLUMNS_BUT_EMBEDDING = [ 'id', 'user_id', 'body', 'created_at', 'updated_at', 'status', 'parent_id', 'deleted_at', 'link_preview_id', 'quoted_commit_id', 'mentions', 'ai_decision', 'ai_categories', 'root_id', 'hot_score', 'pasteis_count', 'author_id', - 'headlines_classified_at', 'guild_id', + 'headlines_classified_at', 'escalated_at', 'guild_id', ]; /** diff --git a/app/Queries/NotificationBuilder.php b/app/Queries/NotificationBuilder.php index 52404c1171..2fb2e51679 100644 --- a/app/Queries/NotificationBuilder.php +++ b/app/Queries/NotificationBuilder.php @@ -48,7 +48,7 @@ public function relevant(): self ->whereColumn('organization_members.organization_id', 'notifications.organization_id') ->whereColumn('organization_members.user_id', 'notifications.recipient_id'))) ->offset(0))) - ->orWhereIn('type', [NotificationType::LeveledUp, NotificationType::TimedOut])) + ->orWhereIn('type', [NotificationType::LeveledUp, NotificationType::TimedOut, NotificationType::Escalated])) ->withoutSilencedActors(); } @@ -59,14 +59,19 @@ public function unread(): self /** * Leaves out what actors the recipient mutes did, and anything from across a block. Moderation - * notifications are their own actor, and nobody can mute or block themselves. + * notifications are their own actor, and nobody can mute or block themselves. Escalations stay + * visible even when the escalating moderator is silenced: they are addressed to admins, not the + * moderator, so muting the moderator must not swallow them. */ private function withoutSilencedActors(): self { $silenced = new SilencedActorQuery('notifications.recipient_id', 'notifications.actor_id'); - return $this->whereNotExists($silenced->mutes(...)) - ->whereNotExists($silenced->blocking(...)) - ->whereNotExists($silenced->blockers(...)); + return $this->where(fn (Builder $query): Builder => $query + ->where('type', NotificationType::Escalated) + ->orWhere(fn (Builder $query): Builder => $query + ->whereNotExists($silenced->mutes(...)) + ->whereNotExists($silenced->blocking(...)) + ->whereNotExists($silenced->blockers(...)))); } } diff --git a/app/Queries/NotificationGroupsQuery.php b/app/Queries/NotificationGroupsQuery.php index bda5e2b45a..fde327f29a 100644 --- a/app/Queries/NotificationGroupsQuery.php +++ b/app/Queries/NotificationGroupsQuery.php @@ -38,7 +38,7 @@ public function paginate(User $user, string $type = 'all', ?CarbonImmutable $thr ->with([ 'actor.user' => fn (HasOne $query): HasOne => $query ->withExists(['followers as is_followed' => fn (Builder $query): Builder => $query->whereKey($user->id)]), - 'commit', + 'commit.author', 'timeout', 'organization', ]) @@ -151,7 +151,8 @@ private function group(NotificationBuilder $visible, string $type = 'all', ?Noti 'stars' => ['starred'], 'mentions' => ['mentioned'], 'follows' => ['followed'], - 'moderation' => ['approved', 'rejected', 'timed_out'], + 'moderation' => ['approved', 'rejected', 'timed_out', 'escalated'], + 'escalations' => ['escalated'], default => [], }, explode(',', $type))))); diff --git a/config/app.php b/config/app.php index 566fd9cb4a..81dfb16d0f 100644 --- a/config/app.php +++ b/config/app.php @@ -48,6 +48,22 @@ explode(',', (string) env('ADMINS', '')), ))), + /* + |-------------------------------------------------------------------------- + | Application Moderators + |-------------------------------------------------------------------------- + | + | The GitHub usernames listed here can review the pending queue and user + | reports, without the power to timeout or ban anyone. Admins can do + | everything moderators can, so they never need to be listed here too. + | + */ + + 'moderators' => array_values(array_filter(array_map( + trim(...), + explode(',', (string) env('MODERATORS', '')), + ))), + /* |-------------------------------------------------------------------------- | Application Debug Mode diff --git a/database/migrations/2026_11_13_074040_add_escalated_at_to_commits_table.php b/database/migrations/2026_11_13_074040_add_escalated_at_to_commits_table.php new file mode 100644 index 0000000000..bbc9aaaf12 --- /dev/null +++ b/database/migrations/2026_11_13_074040_add_escalated_at_to_commits_table.php @@ -0,0 +1,20 @@ +timestamp('escalated_at')->nullable()->after('updated_at'); + }); + } +}; diff --git a/resources/js/components/app-nav.tsx b/resources/js/components/app-nav.tsx index 9f3974d286..9e120dbc40 100644 --- a/resources/js/components/app-nav.tsx +++ b/resources/js/components/app-nav.tsx @@ -119,7 +119,7 @@ function useNavItems(): (NavItem & { isActive: boolean })[] { ...(guilds !== null && guilds !== undefined ? [{ title: 'Guilds', href: guildIndex(), icon: UsersRound }] : []), - ...(auth.isAdmin + ...(auth.canModerate ? [ { title: 'Moderation', @@ -127,11 +127,15 @@ function useNavItems(): (NavItem & { isActive: boolean })[] { icon: ShieldCheck, hasIndicator: hasUnmoderatedCommits, }, - { - title: 'Operations', - href: OperationsController.show(), - icon: Activity, - }, + ...(auth.isAdmin + ? [ + { + title: 'Operations', + href: OperationsController.show(), + icon: Activity, + }, + ] + : []), ] : []), { diff --git a/resources/js/components/moderation-tabs.tsx b/resources/js/components/moderation-tabs.tsx index abbf332fbb..9139d09e31 100644 --- a/resources/js/components/moderation-tabs.tsx +++ b/resources/js/components/moderation-tabs.tsx @@ -11,6 +11,7 @@ export function ModerationTabs({ }: { active: 'pending' | 'reports' | 'people' | 'bulk' | 'guilds'; }) { + const { auth } = usePage().props; const hasGuilds = usePage().props.guilds != null; return ( diff --git a/resources/js/pages/moderation/reports.tsx b/resources/js/pages/moderation/reports.tsx index 380996ee44..a966ec7f40 100644 --- a/resources/js/pages/moderation/reports.tsx +++ b/resources/js/pages/moderation/reports.tsx @@ -1,7 +1,11 @@ import { Head, InfiniteScroll, router, usePage } from '@inertiajs/react'; -import { Check, X } from 'lucide-react'; +import { Check, Flag, Undo2, X } from 'lucide-react'; import { useEffect, useRef, useState } from 'react'; import { toast } from 'sonner'; +import { + destroy as undoEscalateRoute, + store as escalateRoute, +} from '@/actions/App/Http/Controllers/CommitEscalationController'; import { store as reject } from '@/actions/App/Http/Controllers/CommitRejectionController'; import { destroy } from '@/actions/App/Http/Controllers/CommitReportController'; import { CommitCard } from '@/components/commit-card'; @@ -197,6 +201,25 @@ export default function Reports({ }, ); + // Unlike a dismissal, an escalation keeps the report: it flags the commit for an admin. + const escalate = (report: Report) => + router.visit(escalateRoute(report.commit), { + preserveScroll: true, + only: ['reports'], + reset: ['reports'], + onError: () => + toast.error('Could not escalate this commit. Try again.'), + }); + + const undoEscalate = (report: Report) => + router.visit(undoEscalateRoute(report.commit), { + preserveScroll: true, + only: ['reports'], + reset: ['reports'], + onError: () => + toast.error('Could not undo the escalation. Try again.'), + }); + return ( <> @@ -301,6 +324,42 @@ export default function Reports({ Dismiss report + {report.commit.escalated_at != + null ? ( + auth.isAdmin ? ( + + + Escalated + + ) : ( + + ) + ) : ( + !auth.isAdmin && ( + + ) + )} )} + {commit.escalated_at != null ? ( + auth.isAdmin ? ( + + + Escalated + + ) : ( + + ) + ) : ( + !auth.isAdmin && ( + + ) + )} {showReason && (
@@ -360,6 +399,25 @@ export default function Show({ }); }; + // An escalation stays in the queue: it flags the commit for an admin without deciding it. + const escalate = (commit: Commit) => + router.visit(CommitEscalationController.store(commit), { + preserveScroll: true, + only: ['commits', 'hasUnmoderatedCommits'], + reset: ['commits'], + onError: () => + toast.error('Could not escalate this commit. Try again.'), + }); + + const undoEscalate = (commit: Commit) => + router.visit(CommitEscalationController.destroy(commit), { + preserveScroll: true, + only: ['commits', 'hasUnmoderatedCommits'], + reset: ['commits'], + onError: () => + toast.error('Could not undo the escalation. Try again.'), + }); + const [selected, setSelected] = useState>(new Set()); const selectedIds = commits.data @@ -474,6 +532,7 @@ export default function Show({ toggle(commit.id, isSelected) @@ -481,6 +540,8 @@ export default function Show({ onModerate={(route, reason) => moderate(commit, route, reason) } + onEscalate={() => escalate(commit)} + onUndoEscalate={() => undoEscalate(commit)} /> )} diff --git a/resources/js/pages/notification/index.tsx b/resources/js/pages/notification/index.tsx index 1428874df4..0c3d315d7c 100644 --- a/resources/js/pages/notification/index.tsx +++ b/resources/js/pages/notification/index.tsx @@ -14,6 +14,7 @@ import { Check, ChevronDown, ChevronsUp, + Flag, GitCommitVertical, Hourglass, MessageSquareReply, @@ -119,6 +120,11 @@ const filterOptions: { label: 'Moderation', empty: 'No moderation updates. Approved, rejected, and timeout notices show up here.', }, + { + type: 'escalations', + label: 'Escalations', + empty: 'No escalations. When a moderator flags a commit for admin review, it shows up here.', + }, ]; const isNewSince = ( @@ -1164,6 +1170,7 @@ export function NotificationContent({ const moderation = notification.type === 'approved' || notification.type === 'rejected' || + notification.type === 'escalated' || notification.type === 'timed_out'; const isOwnCommit = notification.type === 'starred' || @@ -1194,6 +1201,7 @@ export function NotificationContent({ first_commit: GitCommitVertical, approved: Check, rejected: X, + escalated: Flag, timed_out: Hourglass, }[notification.type]; const icon = ( @@ -1207,17 +1215,22 @@ export function NotificationContent({ /> ); const href = - notification.type === 'followed' || - notification.type === 'timed_out' || - notification.type === 'leveled_up' || - (!summary && notification.type === 'starred') - ? show(actor) - : CommitController.show({ - profile: isOwnCommit - ? (notification.organization ?? user) - : actor, + notification.type === 'escalated' + ? CommitController.show({ + profile: notification.commit.author, commit: notification.commit, - }); + }) + : notification.type === 'followed' || + notification.type === 'timed_out' || + notification.type === 'leveled_up' || + (!summary && notification.type === 'starred') + ? show(actor) + : CommitController.show({ + profile: isOwnCommit + ? (notification.organization ?? user) + : actor, + commit: notification.commit, + }); const time = (