feat: add deterministic Anwarpy publisher
This commit is contained in:
@@ -129,10 +129,18 @@ def same_meta(expected_raw: str, actual_raw: str) -> bool:
|
||||
|
||||
def mark_publishing(raw: str, slug: str) -> str:
|
||||
meta = parse_meta(raw)
|
||||
if meta["status"] != "pending":
|
||||
raise ValueError("only pending markers can be claimed")
|
||||
meta["status"] = "publishing"
|
||||
meta["slug"] = clean(slug)
|
||||
if meta["status"] not in ("pending", "republish"):
|
||||
raise ValueError("only pending or republish markers can be claimed")
|
||||
normalized_slug = clean(slug)
|
||||
if meta["status"] == "republish" and normalized_slug != meta["slug"]:
|
||||
raise ValueError("republish slug cannot change")
|
||||
meta = {
|
||||
"status": "publishing",
|
||||
"access": meta["access"],
|
||||
"category": meta["category"],
|
||||
"queued_at": meta["queued_at"],
|
||||
"slug": normalized_slug,
|
||||
}
|
||||
return render_meta(meta)
|
||||
|
||||
|
||||
@@ -148,8 +156,13 @@ def mark_published(raw: str, published_at: str, url: str) -> str:
|
||||
|
||||
def mark_blocked(raw: str, reason: str) -> str:
|
||||
meta = parse_meta(raw)
|
||||
if meta["status"] != "pending":
|
||||
raise ValueError("only pending markers can be blocked")
|
||||
meta["status"] = "blocked"
|
||||
meta["blocked_reason"] = clean(reason)
|
||||
if meta["status"] not in ("pending", "publishing"):
|
||||
raise ValueError("only pending or publishing markers can be blocked")
|
||||
meta = {
|
||||
"status": "blocked",
|
||||
"access": meta["access"],
|
||||
"category": meta["category"],
|
||||
"queued_at": meta["queued_at"],
|
||||
"blocked_reason": clean(reason),
|
||||
}
|
||||
return render_meta(meta)
|
||||
|
||||
Reference in New Issue
Block a user