// workflow step: publish — flip the post to published. This docs::update fires // the existing posts_on_publish trigger → queue → reader notification emails, // so the workflow chains into the rest of the CMS event graph. let b = ctx.request.body; let posts = docs::collection("posts"); let post = posts.get(b.post_id); let d = post.data; if d.status != "published" { d.status = "published"; if d.publish_at == () { d.publish_at = time::now(); } posts.update(b.post_id, d); } #{ published: true, slug: d.slug }