Olyno
12/20/2022, 1:34 PMdasha^sasha20/02
12/20/2022, 1:39 PMOlyno
12/20/2022, 1:41 PMsilentworks
12/20/2022, 1:50 PMOlyno
12/20/2022, 1:50 PMdasha^sasha20/02
12/20/2022, 2:47 PMdasha^sasha20/02
12/20/2022, 2:47 PMFrah🔥
12/20/2022, 5:22 PMElfhild
12/20/2022, 9:51 PMElfhild
12/20/2022, 9:52 PMOlyno
12/20/2022, 10:17 PMElfhild
12/20/2022, 10:17 PMElfhild
12/20/2022, 10:17 PMOlyno
12/20/2022, 10:20 PMOlyno
12/20/2022, 10:21 PMSue
12/20/2022, 10:39 PMgaryaustin
12/20/2022, 10:46 PMElfhild
12/21/2022, 2:43 AMizurugi
12/21/2022, 9:58 AMsilentworks
12/21/2022, 1:16 PMHuntedman
12/21/2022, 3:09 PMOlyno
12/21/2022, 3:36 PMHuntedman
12/21/2022, 3:44 PMHuntedman
12/21/2022, 3:46 PMsilentworks
12/21/2022, 3:54 PMHuntedman
12/21/2022, 4:47 PMcreate or replace function notify_webhook() returns trigger AS $trigger$
DECLARE
rec RECORD;
notify_url TEXT;
request_id BIGINT;
payload_items JSONB;
payload JSONB;
BEGIN
-- Set record row depending on operation
CASE TG_OP
WHEN 'INSERT', 'UPDATE' THEN
rec := NEW;
WHEN 'DELETE' THEN
rec := OLD;
ELSE
RAISE EXCEPTION 'Unknown TG_OP: "%". Should not occur!', TG_OP;
END CASE;
payload_items := coalesce(row_to_json(rec),'{}')::jsonb;
payload := json_build_object(
'record', payload_items
);
-- Retrieve the URL and body from the trigger arguments
notify_url := TG_ARGV[0];
-- Call the net.http_post function with the URL and body
request_id := net.http_post(notify_url, payload);
-- Return the request_id
RETURN rec;
END;
$trigger$ LANGUAGE plpgsql;
create trigger user_profiles_webhook
after insert on public.user_profiles
for each row execute procedure
notify_webhook('http://127.0.0.1:3000/api/stripe-create-new-customer');
muttonia
12/21/2022, 9:23 PMClay
12/22/2022, 3:07 AMLukas
12/22/2022, 3:42 AM