authen
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
sp_notify_channel_response
Parameters
Name
Type
Mode
p_title
text
IN
p_conn
text
IN
p_trace
uuid
IN
p_response
text
IN
Definition
DECLARE v_http int := public.fn_http_post_status(p_response); v_has_warn boolean := false; v_need_send boolean := false; v_msg text; BEGIN -- ตรวจ warnings แบบ lightweight (ไม่ต้อง parse json ให้พัง) -- ถ้า response มีคำว่า "warnings" ถือว่ามีเรื่องให้แจ้ง v_has_warn := (position('"warnings"' in p_response) > 0); -- ส่งเฉพาะตอน fail หรือมี warning หรือ parse http ไม่ได้ v_need_send := (v_http >= 400) OR v_has_warn OR (v_http = 0); IF NOT v_need_send THEN RETURN; END IF; -- ส่งสั้นๆก่อน แล้วค่อยแนบ raw (เพื่อ debug) v_msg := format( 'Conn: %s | Trace: %s | HTTP: %s | HasWarnings: %s%sRAW=%s', p_conn, p_trace, v_http, v_has_warn, E'\n', p_response ); PERFORM public.sp_system_notify( p_title, v_msg, NULL, 'plain' ); END;