Add Discord webhook refresh notifications
This commit is contained in:
@@ -28,6 +28,7 @@ from app_support import (
|
||||
remote_access_allowed,
|
||||
remote_access_token_configured,
|
||||
remote_access_token_matches,
|
||||
send_discord_webhook_event,
|
||||
)
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -45,6 +46,7 @@ class HandlerContext:
|
||||
runtime_state: object
|
||||
save_runtime_config: object
|
||||
search_anime: object
|
||||
test_discord_webhook_config: object
|
||||
thumbnail_file_path: object
|
||||
update_all_watchlist_statuses: object
|
||||
update_watchlist_category: object
|
||||
@@ -278,6 +280,9 @@ class Handler(BaseHTTPRequestHandler):
|
||||
self.ensure_client_access()
|
||||
if parsed.path == "/api/config":
|
||||
Handler.update_config(self, Handler.require_json_object(self, self.body_json()))
|
||||
elif parsed.path == "/api/config/webhook/test":
|
||||
payload = Handler.require_json_object(self, self.body_json())
|
||||
self.json(Handler._context(self).test_discord_webhook_config(payload))
|
||||
elif parsed.path == "/api/queue":
|
||||
runtime = Handler._runtime(self)
|
||||
self.json(runtime["download_queue"].add(self.body_json()), HTTPStatus.CREATED)
|
||||
@@ -465,6 +470,18 @@ class Handler(BaseHTTPRequestHandler):
|
||||
traceback.print_exc()
|
||||
else:
|
||||
debug_log("handler.exception", path=getattr(self, "path", ""), error=exc)
|
||||
try:
|
||||
send_discord_webhook_event(
|
||||
Handler._context(self).get_config_snapshot(),
|
||||
"runtime_error",
|
||||
{
|
||||
"source": "http_handler",
|
||||
"error": str(exc),
|
||||
"details": f"path={getattr(self, 'path', '')}",
|
||||
},
|
||||
)
|
||||
except Exception as notify_exc:
|
||||
debug_log("discord_webhook.runtime_error_failed", source="http_handler", error=notify_exc)
|
||||
self.error(HTTPStatus.INTERNAL_SERVER_ERROR, "Internal server error.")
|
||||
|
||||
def log_message(self, fmt, *args):
|
||||
|
||||
Reference in New Issue
Block a user