Skip to content

feat(admin): atomic expected-status guard and pre-launch recovery queue (#77) - #306

Merged
JOY (JOY) merged 2 commits into
devfrom
antigravity/give-77-sendback-suspended-recovery
Nov 22, 2026
Merged

JOY (JOY) merged 2 commits into
devfrom
antigravity/give-77-sendback-suspended-recovery

Conversation

@JOY

@JOY JOY (JOY) commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Refs #77

Summary

Phase 2 (apps/web) companion to merged DB PR DOS/DOS.Me#1872 (20261130120000_give_campaign_sendback_and_suspended_recovery.sql, squash-merged at a280fcf01c2181c7a74ba6d3f5d79c88cbc8fa8b, Beta Supabase Preview green check-run 137157543189), closing the remaining items of #77:

  1. Atomic moderator transition race guard (apps/web/src/app/admin/actions.ts, apps/web/src/lib/errors.ts):
    • approveCampaign passes p_expected_status: "in_review" on approval and p_expected_status: "approved" on immediate live opening, preventing stale approvals and accidental un-suspension if another moderator suspended the campaign in between.
    • requestChanges accepts from_status in ("in_review", "approved", "suspended"), passes p_expected_status: fromStatus atomically to give.transition_campaign, and keeps read-error vs not-found distinction.
    • Maps GIVE_CAMPAIGN_STATUS_CHANGED (40001) and suspended -> changes_requested refusals (SUSPENDED_SEND_BACK_MESSAGES) to clear Vietnamese messages.
  2. Pre-launch recovery queue on /admin (apps/web/src/lib/campaigns.ts, apps/web/src/app/admin/page.tsx):
    • Adds listCampaignsNeedingRecovery (backed by give.campaigns_needing_recovery(), disjoint from give.campaigns_waiting_for_account()) and recoveryAdvice covering:
      • approved_past_end: approved campaigns past ends_at whose receiving account is usable (skipped by activation cron and absent from #waiting);
      • suspended_before_start: campaigns suspended with starts_at > now() (never live, no contributions), with tailored guidance for usable accounts, unusable accounts without transactions (release & rebind), give accounts with transactions (#55 swap, with #organizers re-verification guidance when unverified), foreign accounts with transactions (admin/cancel), and back accounts with transactions (no dead-end send-back).
    • Renders #recovery ("Cần xử lý trước khi mở") on /admin with error isolation, self-review guards, <StatusHistory>, secondary submit buttons (DESIGN.md 6), and from_status="suspended" / "approved" hidden inputs.
  3. Changelog & Tests:
    • Updated CHANGELOG.md, apps/web/src/app/admin/actions.test.ts, apps/web/src/lib/campaigns.test.ts, and apps/web/src/app/admin/page.test.ts.

Verification (8a3421b218c583929460d7dc5d46bed43f33f247)

  • pnpm format:check: PASS
  • pnpm lint: PASS
  • pnpm typecheck: PASS
  • pnpm test: PASS (180 Vitest files / 2,631 tests)
  • pnpm build: PASS (Next.js 16.4.6 production build)
  • GitHub Checks: Lint SUCCESS, Build all apps SUCCESS, Vercel SUCCESS, DOScout SUCCESS (mergeable: MERGEABLE, mergeStateStatus: CLEAN).

Review Record (8a3421b218c583929460d7dc5d46bed43f33f247)

  • DOS Code Review (dos[bot]): APPROVED (CLEAN_PASS, 0 findings) on both 1913c4ab and 8a3421b2.
  • Fresh-context independent reviewer (9e65e286-829c-422b-a970-6beb714b6ce0):
    • Round 1 (1913c4ab): 2 P2 + 1 P3 findings in recoveryAdvice (money && account_not_owned, money && give && !verified, organizer_not_verified && money).
    • Round 2 (8a3421b2): all 3 fixed with unit test coverage -> CLEAN_PASS (0 remaining findings).

@vercel

vercel Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
give Ready Ready Preview Nov 22, 2026 9:22am UTC

Request Review

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 53334146-91fe-4529-80c7-9c44f3b98338

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

dos[bot]
dos Bot approved these changes Nov 22, 2026

@dos dos Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱️ Code Review completed (8 eligible files · 45,682 chars · 2 model call(s) · 2 PR unit(s))

Whole diff with bounded context at base c0202ef / head 1913c4a.

✅ CLEAN_PASS: Complete diff reviewed

Context investigation was bounded to the explicitly requested snapshot paths.

dos[bot]
dos Bot approved these changes Nov 22, 2026

@dos dos Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱️ Code Review completed (8 eligible files · 49,676 chars · 3 model call(s) · 2 PR unit(s))

Whole diff with bounded context at base c0202ef / head 8a3421b.

✅ CLEAN_PASS: Complete diff reviewed

Context investigation was bounded to the explicitly requested snapshot paths.

@JOY JOY (JOY) added line:campaigns Product line: campaigns po:agy Owned by Antigravity PO (mutual-exclusion parallel PO label) labels Nov 22, 2026
@JOY

Copy link
Copy Markdown
Contributor Author

PO acceptance: merge at 8a3421b

Verified on GitHub:

  • Required checks green: Verify build/Lint, Verify build/Build all apps (plus Vercel preview & DOScout green)
  • mergeStateStatus: CLEAN, 0 unresolved review threads; dos[bot] APPROVED
  • Two independent fresh-context reviews approved at 8a3421b218c583929460d7dc5d46bed43f33f247 (zero blocking findings; atomic p_expected_status CAS, campaigns_needing_recovery() contract, self-review guards, and complete Vietnamese recoveryAdvice verified).

@JOY
JOY (JOY) merged commit 9deab36 into dev Nov 22, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

line:campaigns Product line: campaigns po:agy Owned by Antigravity PO (mutual-exclusion parallel PO label)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant