Problem
PR #807 introduced deadline enforcement but has two bugs:
Bug 1: has_deadline not checked (critical)
The deadline expiry logic is applied unconditionally to ALL storylines. Storylines created with has_deadline=false (no 7-day deadline) would be incorrectly blocked from creating new plots if their last_plot_time is old.
Affected locations:
src/components/AddPlotButton.tsx — isDeadlineExpired() doesn't check has_deadline
src/app/create/page.tsx — isStorylineExpired() doesn't check has_deadline
src/app/api/index/plot/route.ts — API query selects last_plot_time, sunset but not has_deadline
Bug 2: API uses Date.now() instead of block timestamp (edge case)
The API indexer checks Date.now() > deadline but this runs AFTER the on-chain tx already succeeded. A plot submitted at T-1 minute that the contract accepted could fail indexing if Date.now() has moved past the deadline by the time the API processes it.
Fix: Compare against the block timestamp (already fetched in the route) instead of Date.now().
Solution
- All three locations must check
has_deadline === true before applying deadline logic
AddPlotButton needs hasDeadline as a prop
isStorylineExpired in create page should check s.has_deadline
- API route should select
has_deadline and skip check when false
- API should compare block timestamp vs deadline, not
Date.now()
Acceptance Criteria
Branch
task/<issue>-deadline-has-deadline-fix
Problem
PR #807 introduced deadline enforcement but has two bugs:
Bug 1:
has_deadlinenot checked (critical)The deadline expiry logic is applied unconditionally to ALL storylines. Storylines created with
has_deadline=false(no 7-day deadline) would be incorrectly blocked from creating new plots if theirlast_plot_timeis old.Affected locations:
src/components/AddPlotButton.tsx—isDeadlineExpired()doesn't checkhas_deadlinesrc/app/create/page.tsx—isStorylineExpired()doesn't checkhas_deadlinesrc/app/api/index/plot/route.ts— API query selectslast_plot_time, sunsetbut nothas_deadlineBug 2: API uses
Date.now()instead of block timestamp (edge case)The API indexer checks
Date.now() > deadlinebut this runs AFTER the on-chain tx already succeeded. A plot submitted at T-1 minute that the contract accepted could fail indexing ifDate.now()has moved past the deadline by the time the API processes it.Fix: Compare against the block timestamp (already fetched in the route) instead of
Date.now().Solution
has_deadline === truebefore applying deadline logicAddPlotButtonneedshasDeadlineas a propisStorylineExpiredin create page should checks.has_deadlinehas_deadlineand skip check when falseDate.now()Acceptance Criteria
has_deadline=falseare never blocked by deadline logicAddPlotButtonreceives and checkshasDeadlinepropisStorylineExpiredcheckshas_deadlinehas_deadlineDate.now()for deadline comparisonBranch
task/<issue>-deadline-has-deadline-fix