MED-88: add doctor email notifications (#65)
* MED-88: add doctor email notifications * add logging, send open jobs notification on partial analysis response * update permissions * fix import, permissions * casing, let email be null * unused import
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
create extension if not exists pg_cron;
|
||||
create extension if not exists pg_net;
|
||||
|
||||
select
|
||||
cron.schedule(
|
||||
'send emails with new unassigned jobs 4x a day',
|
||||
'0 4,9,14,18 * * 1-5', -- Run at 07:00, 12:00, 17:00 and 21:00 (GMT +3) on weekdays only
|
||||
$$
|
||||
select
|
||||
net.http_post(
|
||||
url := 'https://test.medreport.ee/api/job/send-open-jobs-emails',
|
||||
headers := jsonb_build_object(
|
||||
'x-jobs-api-key', 'fd26ec26-70ed-11f0-9e95-431ac3b15a84'
|
||||
)
|
||||
) as request_id;
|
||||
$$
|
||||
);
|
||||
@@ -0,0 +1,8 @@
|
||||
grant select on table "medreport"."doctor_analysis_feedback" to "service_role";
|
||||
|
||||
create policy "service_role_select"
|
||||
on "medreport"."doctor_analysis_feedback"
|
||||
as permissive
|
||||
for select
|
||||
to service_role
|
||||
using (true);
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
create trigger "trigger_doctor_notification" after update
|
||||
on "medreport"."analysis_orders" for each row
|
||||
execute function "supabase_functions"."http_request"(
|
||||
'http://host.docker.internal:3000/api/db/webhook',
|
||||
'POST',
|
||||
'{"Content-Type":"application/json", "X-Supabase-Event-Signature":"WEBHOOKSECRET"}',
|
||||
'{}',
|
||||
'5000'
|
||||
);
|
||||
@@ -0,0 +1,10 @@
|
||||
alter table audit.notification_entries enable row level security;
|
||||
|
||||
create policy "service_role_insert"
|
||||
on "audit"."notification_entries"
|
||||
as permissive
|
||||
for insert
|
||||
to service_role
|
||||
with check (true);
|
||||
|
||||
grant insert on table "audit"."notification_entries" to "service_role";
|
||||
Reference in New Issue
Block a user