mirror of
				https://github.com/abhinavxd/libredesk.git
				synced 2025-11-03 21:43:35 +00:00 
			
		
		
		
	- feat: adds csrf token check - feat: adds conversation sub and unsub for WS updates. - Clean up and remove unncessary code - refactor and simplify auth middlewares - fix: automation rules - Update schema.sql
		
			
				
	
	
		
			35 lines
		
	
	
		
			947 B
		
	
	
	
		
			SQL
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			947 B
		
	
	
	
		
			SQL
		
	
	
	
	
	
-- name: get-enabled-rules
 | 
						|
select
 | 
						|
    type,
 | 
						|
    rules
 | 
						|
from automation_rules where disabled is not TRUE;
 | 
						|
 | 
						|
-- name: get-all
 | 
						|
SELECT id, created_at, updated_at, name, description, type, rules, disabled from automation_rules where type = $1;
 | 
						|
 | 
						|
-- name: get-rule
 | 
						|
SELECT id, created_at, updated_at, name, description, type, rules from automation_rules where id = $1;
 | 
						|
 | 
						|
-- name: update-rule
 | 
						|
INSERT INTO automation_rules(id, name, description, type, rules)
 | 
						|
VALUES($1, $2, $3, $4, $5)
 | 
						|
ON CONFLICT (id)
 | 
						|
DO UPDATE SET
 | 
						|
    name = EXCLUDED.name,
 | 
						|
    description = EXCLUDED.description,
 | 
						|
    type = EXCLUDED.type,
 | 
						|
    rules = EXCLUDED.rules,
 | 
						|
    updated_at = now()
 | 
						|
WHERE $1 > 0;
 | 
						|
 | 
						|
-- name: insert-rule
 | 
						|
INSERT into automation_rules (name, description, type, rules) VALUES ($1, $2, $3, $4);
 | 
						|
 | 
						|
-- name: delete-rule
 | 
						|
delete from automation_rules where id = $1;
 | 
						|
 | 
						|
-- name: toggle-rule
 | 
						|
UPDATE automation_rules 
 | 
						|
SET disabled = NOT disabled, updated_at = NOW() 
 | 
						|
WHERE id = $1;
 |