diff options
author | Yorhel <git@yorhel.nl> | 2020-10-04 17:00:56 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2020-10-05 16:46:32 +0200 |
commit | 0472ab49f1a9136283ef43e56e1c36ce739cc84b (patch) | |
tree | 0b0e07959c3ffab487c178ae329df86fdb2c08da /util/updates/wip-notifications.sql | |
parent | 8c35d3ad42096856e8243aa081d7a9be03b4d693 (diff) |
notifications: Consolidate and simplify creation of notifications
Preparing to extend the notification types, but with the old
individual-trigger-for-each-type that would easily turn into an
unmanagaeble mess. The new approach also correctly handles events that
may trigger multiple notification types.
Also removed the title and uid cache from the notifications table,
they don't simplify things and aren't necessary for performance. On the
other hand, doing a generic information lookup for vndbids is kind of
annoying. I now wrote an item_type() function to help with that, but
it's not sufficient to solve the broader problem.
One regression(?): Users will keep getting notifications for new posts
on threads even if they haven't read older notifications for the same
thread yet. I /think/ this behavior is more intuitive and expected, so
maybe I'll keep it.
(And possibly more regressions as well, who knows...)
Diffstat (limited to 'util/updates/wip-notifications.sql')
-rw-r--r-- | util/updates/wip-notifications.sql | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/util/updates/wip-notifications.sql b/util/updates/wip-notifications.sql new file mode 100644 index 00000000..31dababa --- /dev/null +++ b/util/updates/wip-notifications.sql @@ -0,0 +1,17 @@ +-- Simplified triggers, all the logic is consolidated in notify(). +DROP TRIGGER notify_pm ON threads_posts; +DROP TRIGGER notify_announce ON threads_posts; +DROP FUNCTION notify_pm(); +DROP FUNCTION notify_announce(); + +DROP FUNCTION notify_dbdel(dbentry_type, edit_rettype); +DROP FUNCTION notify_dbedit(dbentry_type, edit_rettype); +DROP FUNCTION notify_listdel(dbentry_type, edit_rettype); + +-- Table changes +ALTER TABLE notifications ALTER COLUMN ntype TYPE notification_ntype[] USING ARRAY[ntype]; +ALTER TABLE notifications DROP COLUMN c_title; +ALTER TABLE notifications DROP COLUMN c_byuser; + +\i sql/func.sql +\i sql/triggers.sql |