Skip to content

Content state machine + scheduled publisher + GC jobs #143

Description

@tayebmokni

Summary

Implement the content-state machine for posts. Enforce allowed transitions, fire post.transitioned hooks, and integrate the scheduled publisher (Asynq job that scans WHERE status='scheduled' AND publish_at <= now() every 30s).

Design reference

  • docs/01-core-cms.md §5 (Content States)
  • docs/01-core-cms.md §5.2 (State machine diagram)
  • docs/01-core-cms.md §5.3 (Implementation — Go-side validation, scheduler)

Acceptance criteria

  • internal/content/states.go defines AllowedTransition(from, to Status) bool matching §5.2
  • Repository's Transition(ctx, id, to, by) validates the transition before UPDATE
  • On every successful transition, a post.transitioned hook fires with {from, to, post_id, user_id} payload
  • Term counts update on transitions affecting public visibility (draft→published increments terms.count for attached terms)
  • Asynq cron job runs every 30s, batches eligible scheduled posts, transitions to published
  • Auto-draft GC job: removes auto-draft posts older than 24h
  • Trash GC job: purges trash posts older than 30 days
  • Integration tests cover every legal transition and reject every illegal one

Dependencies

#22, #24

Complexity

M

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:apiGo HTTP API serverarea:jobsBackground jobs, cronphase:P1-cms-corePhase 1 — CMS Corepriority:P1Important — should land in phaseskill:goGo programmingtype:featNew feature or implementation task

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions