feat(publish): 30-min slot grid with silent slots and loud morning/evening anchors
This commit is contained in:
+12
-2
@@ -3,12 +3,20 @@
|
||||
# публикатор очереди (scripts/publish_runner.py), которому незачем поднимать app.
|
||||
import json
|
||||
|
||||
from config import BASE_DIR
|
||||
from config import BASE_DIR, PUBLISH_LOUD_SLOTS
|
||||
from publisher.card import make_card
|
||||
from web.db import db
|
||||
|
||||
|
||||
def impl_approve(post_id: int, comment: str = "", dirs_selected: list[str] | None = None) -> str | None:
|
||||
def _silent_for(scheduled_at: str | None) -> bool:
|
||||
"""Тихий режим: посты из очереди в не-«якорные» слоты. Ручная публикация всегда со звуком."""
|
||||
if not scheduled_at:
|
||||
return False
|
||||
return str(scheduled_at)[11:16] not in PUBLISH_LOUD_SLOTS
|
||||
|
||||
|
||||
def impl_approve(post_id: int, comment: str = "", dirs_selected: list[str] | None = None,
|
||||
silent: bool | None = None) -> str | None:
|
||||
"""Публикация поста: publisher + бандл + статус published. Возвращает None при успехе,
|
||||
строку ошибки при неудаче (для bulk — собираем ошибки, для POST — редирект с error)."""
|
||||
from web.publisher_client import publish as http_publish
|
||||
@@ -53,6 +61,8 @@ def impl_approve(post_id: int, comment: str = "", dirs_selected: list[str] | Non
|
||||
card = make_card(post, comment)
|
||||
card["direction"] = dirn
|
||||
card["lang"] = lang
|
||||
# тихий слот — без звука; кнопка «🚀 сейчас» передаёт silent=False и всегда гремит
|
||||
card["silent"] = _silent_for(post.get("scheduled_at")) if silent is None else silent
|
||||
|
||||
try:
|
||||
res = http_publish(card)
|
||||
|
||||
Reference in New Issue
Block a user