From add834f2425202206830af1eacb91aecce760e1d Mon Sep 17 00:00:00 2001 From: Aditya Thebe Date: Tue, 10 Sep 2024 10:58:22 +0545 Subject: [PATCH] feat: send action payloads on pg notify --- views/018_playbooks.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/018_playbooks.sql b/views/018_playbooks.sql index 69d45783..9dc8db0e 100644 --- a/views/018_playbooks.sql +++ b/views/018_playbooks.sql @@ -2,10 +2,10 @@ CREATE OR REPLACE FUNCTION notify_playbook_action_update() RETURNS TRIGGER AS $$ BEGIN IF TG_OP = 'INSERT' THEN - NOTIFY playbook_action_updates; + PERFORM pg_notify('playbook_action_updates', json_build_object('id', NEW.id, 'agent_id', NEW.agent_id)::TEXT); ELSEIF TG_OP = 'UPDATE' THEN IF OLD.status != NEW.status AND NEW.status = 'scheduled' THEN - NOTIFY playbook_action_updates; + PERFORM pg_notify('playbook_action_updates', json_build_object('id', NEW.id, 'agent_id', NEW.agent_id)::TEXT); END IF; END IF;