republisher/repub/web/publisher/actions.py

28 lines
830 B
Python
Raw Normal View History

2026-06-02 10:18:59 +02:00
from __future__ import annotations
from collections.abc import Awaitable, Callable
from typing import Any
from quart import Quart, Response
from repub.web.app import run_job_now_response
RouteGuard = Callable[[Callable[..., Awaitable[Any]]], Callable[..., Awaitable[Any]]]
def register_publisher_actions(
app: Quart,
*,
publisher_required: RouteGuard,
admin_required: RouteGuard,
) -> None:
@app.post("/publisher/actions/jobs/<int:job_id>/run-now")
@publisher_required
async def publisher_run_job_now_action(job_id: int) -> Response:
return run_job_now_response(app, job_id)
@app.post("/admin/publisher/actions/jobs/<int:job_id>/run-now")
@admin_required
async def admin_publisher_run_job_now_action(job_id: int) -> Response:
return run_job_now_response(app, job_id)