-
Notifications
You must be signed in to change notification settings - Fork 10
/
pgfuncs1.sql
37 lines (31 loc) · 1.11 KB
/
pgfuncs1.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
CREATE OR REPLACE FUNCTION public.user_is_human(a_pubkey bytea) RETURNS bool
LANGUAGE 'sql' STABLE PARALLEL SAFE
AS $BODY$
SELECT (
EXISTS (SELECT 1 FROM pubkey_trustrank ptr WHERE ptr.pubkey = a_pubkey) OR
EXISTS (SELECT 1 FROM human_override ho WHERE ho.pubkey = a_pubkey AND ho.is_human)
)
$BODY$;
CREATE OR REPLACE FUNCTION public.notification_is_visible(type int8, arg1 bytea, arg2 bytea) RETURNS bool
LANGUAGE 'sql' STABLE PARALLEL SAFE
AS $BODY$
SELECT
CASE type
WHEN 1 THEN user_is_human(arg1)
WHEN 2 THEN user_is_human(arg1)
WHEN 3 THEN user_is_human(arg2)
WHEN 4 THEN user_is_human(arg2)
WHEN 5 THEN user_is_human(arg2)
WHEN 6 THEN user_is_human(arg2)
WHEN 7 THEN user_is_human(arg2)
/* WHEN 8 THEN user_is_human(arg3) */
WHEN 101 THEN user_is_human(arg2)
WHEN 102 THEN user_is_human(arg2)
WHEN 103 THEN user_is_human(arg2)
WHEN 104 THEN user_is_human(arg2)
/* WHEN 201 THEN user_is_human(arg3) */
/* WHEN 202 THEN user_is_human(arg3) */
/* WHEN 203 THEN user_is_human(arg3) */
/* WHEN 204 THEN user_is_human(arg3) */
END CASE
$BODY$;