summaryrefslogtreecommitdiff
path: root/util/sql/func.sql
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2010-12-23 14:25:37 +0100
committerYorhel <git@yorhel.nl>2010-12-23 14:25:37 +0100
commit3eb574e4e26162aa754372fff806e4c6de8f4754 (patch)
tree32b08348512dc2f16d932676bb9b1b61fab16f3a /util/sql/func.sql
parent6ff1efe0d07e24e9fb2db199c308c6cbed51e578 (diff)
Converted the notify_announce and notify_dbedit preferences
And renamed notify_dbedit to notify_nodbedit, since the default is to provide a notify on a database edit. Also fixed a few bugs along the way.
Diffstat (limited to 'util/sql/func.sql')
-rw-r--r--util/sql/func.sql8
1 files changed, 3 insertions, 5 deletions
diff --git a/util/sql/func.sql b/util/sql/func.sql
index 3f1372b5..0248c69a 100644
--- a/util/sql/func.sql
+++ b/util/sql/func.sql
@@ -790,12 +790,10 @@ BEGIN
) x(id, title) ON c.id = x.id
-- join info about the deletion itself
JOIN changes c2 ON c2.id = NEW.latest
- -- join info about the user who should get this notification
- JOIN users u ON u.id = c.requester
-- exclude the user who edited the entry
WHERE c.requester <> c2.requester
-- exclude users who don't want this notify
- AND u.notify_dbedit;
+ AND NOT EXISTS(SELECT 1 FROM users_prefs up WHERE uid = c.requester AND key = 'notify_nodbedit');
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
@@ -805,11 +803,11 @@ $$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION notify_announce() RETURNS trigger AS $$
BEGIN
INSERT INTO notifications (ntype, ltype, uid, iid, subid, c_title, c_byuser)
- SELECT 'announce', 't', u.id, t.id, 1, t.title, NEw.uid
+ SELECT 'announce', 't', up.uid, t.id, 1, t.title, NEw.uid
FROM threads t
JOIN threads_boards tb ON tb.tid = t.id
-- get the users who want this announcement
- JOIN users u ON u.notify_announce
+ JOIN users_prefs up ON up.key = 'notify_announce'
WHERE t.id = NEW.tid
AND tb.type = 'an' -- announcement board
AND NOT t.hidden;