forked from fahrPool/fahrPool
23 lines
997 B
SQL
23 lines
997 B
SQL
-- Minuetlicher Anstoss der Dispatch-Route. URL und Secret stehen bewusst
|
|
-- NICHT hier (umgebungsabhaengig, kein Secret in Git), sondern in den
|
|
-- DB-Settings app.notification_dispatch_url / app.notification_dispatch_secret,
|
|
-- die pro Stack out-of-band gesetzt werden. Ist die URL leer/ungesetzt (z.B.
|
|
-- lokaler CLI-Dev-Stack), verhindert die where-Bedingung jeden http_post --
|
|
-- der Job existiert dann, tut aber nichts.
|
|
create extension if not exists pg_cron;
|
|
create extension if not exists pg_net;
|
|
|
|
select cron.schedule(
|
|
'notification-dispatch',
|
|
'* * * * *',
|
|
$$
|
|
select net.http_post(
|
|
url := current_setting('app.notification_dispatch_url', true),
|
|
headers := jsonb_build_object(
|
|
'Content-Type', 'application/json',
|
|
'Authorization', 'Bearer ' || current_setting('app.notification_dispatch_secret', true)),
|
|
body := '{}'::jsonb)
|
|
where coalesce(current_setting('app.notification_dispatch_url', true), '') <> ''
|
|
$$
|
|
);
|