Commit graph

2 commits

Author SHA1 Message Date
JohnBaumb
06220a5a83 fix: add periodic cleanup timer for api/request in-memory store
Inbound music requests are tracked in an in-memory _pending_requests

dict with a 1-hour TTL. Cleanup was only triggered inside

create_request(), so during quiet periods stale entries stayed in

memory until the next inbound request.

Add a background thread that wakes every 5 minutes and evicts any

entry older than _MAX_REQUEST_AGE. The thread is started once during

API blueprint registration (start_cleanup_thread is idempotent) and

is a daemon, so it exits automatically on process shutdown.

stop_cleanup_thread() is exposed for tests and future graceful-

shutdown hooks. It signals the stop event so the thread exits

without waiting for the next cleanup interval.
2026-04-19 15:22:25 -07:00
Broque Thomas
8866c4654b Add inbound music request API and webhook automation trigger
New POST /api/v1/request endpoint accepts a search query from external
sources (Discord bots, Home Assistant, curl) and triggers the
search-match-download pipeline asynchronously. Returns a request_id
for status polling via GET /api/v1/request/<id>. Optional notify_url
for callback on completion.

Also adds webhook_received trigger type and search_and_download action
type to the automation engine, so users can build custom flows like
"when webhook received → search & download → notify Discord".

Includes info panel in Settings showing endpoint URL and curl example.
2026-04-15 20:35:39 -07:00