Index: openacs-4/packages/notifications/tcl/sweep-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/tcl/sweep-procs-oracle.xql,v diff -u -N --- openacs-4/packages/notifications/tcl/sweep-procs-oracle.xql 15 Nov 2017 10:40:28 -0000 1.22 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,52 +0,0 @@ - - - - oracle8.1.6 - - - - select nnr.* - from (select notifications.notification_id, - notifications.notif_subject, - notifications.notif_text, - notifications.notif_html, - notifications.file_ids, - notification_requests.user_id, - notification_requests.object_id, - notification_requests.type_id, - notification_requests.delivery_method_id, - notification_requests.request_id, - notifications.response_id, - notifications.notif_date, - notifications.notif_user - from notifications, notification_requests - where notifications.type_id = notification_requests.type_id - and notifications.object_id = notification_requests.object_id - and notification_requests.interval_id = :interval_id) nnr, - notification_user_map, acs_objects - where nnr.notification_id = notification_user_map.notification_id(+) - and nnr.user_id = notification_user_map.user_id(+) - and notification_user_map.sent_date is null - and (nnr.notif_date is null or nnr.notif_date < sysdate) - and acs_objects.object_id = nnr.request_id - and acs_objects.creation_date <= nnr.notif_date - and exists (select 1 from acs_object_party_privilege_map ppm - where ppm.object_id = nnr.object_id - and ppm.privilege = 'read' - and ppm.party_id = nnr.user_id) - order by nnr.user_id, nnr.type_id, nnr.notif_date - - - - - - select request_id - from notification_requests - where not exists (select 1 from acs_object_party_privilege_map ppm - where ppm.object_id = notification_requests.object_id - and ppm.privilege = 'read' - and ppm.party_id = notification_requests.user_id) - - - - Index: openacs-4/packages/notifications/tcl/sweep-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/tcl/sweep-procs-postgresql.xql,v diff -u -N --- openacs-4/packages/notifications/tcl/sweep-procs-postgresql.xql 15 Nov 2017 10:40:28 -0000 1.14 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,40 +0,0 @@ - - - - postgresql7.1 - - - - select notification_id, - notif_subject, - notif_text, - notif_html, - file_ids, - user_id, - type_id, - delivery_method_id, - response_id, - notif_date, - notif_user - from notifications inner join notification_requests using (type_id, object_id) - inner join acs_objects on (notification_requests.request_id = acs_objects.object_id) - left outer join notification_user_map using (notification_id, user_id) - where sent_date is null - and creation_date <= notif_date - and (notif_date is null or notif_date < current_timestamp) - and interval_id = :interval_id - and acs_permission__permission_p(notification_requests.object_id, notification_requests.user_id, 'read') - order by user_id, type_id, notif_date - - - - - postgresql8.4 - - select request_id - from notification_requests - where acs_permission__permission_p(object_id, user_id, 'read') is false; - - - - Index: openacs-4/packages/notifications/tcl/sweep-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/tcl/sweep-procs.tcl,v diff -u -N -r1.28 -r1.28.2.1 --- openacs-4/packages/notifications/tcl/sweep-procs.tcl 7 May 2018 14:55:20 -0000 1.28 +++ openacs-4/packages/notifications/tcl/sweep-procs.tcl 15 Mar 2019 16:48:50 -0000 1.28.2.1 @@ -18,7 +18,11 @@ db_dml delete_dynamic_requests {} # before the killing starts, remove invalid requests - foreach request_id [db_list select_invalid_request_ids {}] { + foreach request_id [db_list select_invalid_request_ids { + select request_id + from notification_requests + where not acs_permission.permission_p(object_id, user_id, 'read') + }] { notification::request::delete -request_id $request_id } @@ -42,7 +46,28 @@ # order it by user_id # make sure the users have not yet received this notification with outer join # on the mapping table and a null check - set notifications [db_list_of_ns_sets select_notifications {}] + set notifications [db_list_of_ns_sets select_notifications { + select notification_id, + notif_subject, + notif_text, + notif_html, + file_ids, + user_id, + type_id, + delivery_method_id, + response_id, + notif_date, + notif_user + from notifications inner join notification_requests using (type_id, object_id) + inner join acs_objects on (notification_requests.request_id = acs_objects.object_id) + left outer join notification_user_map using (notification_id, user_id) + where sent_date is null + and creation_date <= notif_date + and (notif_date is null or notif_date < current_timestamp) + and interval_id = :interval_id + and acs_permission.permission_p(notification_requests.object_id, notification_requests.user_id, 'read') + order by user_id, type_id, notif_date + }] if {$batched_p} { set prev_user_id 0