From e059b8fe147022d8a7e1e55198a97221f081fdf7 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Tue, 7 Jul 2020 16:09:11 +0200 Subject: [PATCH 4/5] wf: do not notify inactive users (#42428) --- tests/test_workflows.py | 8 ++++++++ wcs/wf/notification.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/test_workflows.py b/tests/test_workflows.py index a411753b..e3bfd16b 100644 --- a/tests/test_workflows.py +++ b/tests/test_workflows.py @@ -4558,6 +4558,14 @@ def test_notifications(pub, http_requests): 'https://portal/api/notification/add/?NameID=xxy1', 'https://portal/api/notification/add/?NameID=xxy2']) + # test inactive users are ignored + user2.is_active = False + user2.store() + http_requests.empty() + item.perform(formdata) + assert http_requests.count() == 1 + assert set(x['url'] for x in http_requests.requests) == set(['https://portal/api/notification/add/?NameID=xxy1']) + def test_workflow_field_migration(pub): Workflow.wipe() diff --git a/wcs/wf/notification.py b/wcs/wf/notification.py index 1b7db312..00b27463 100644 --- a/wcs/wf/notification.py +++ b/wcs/wf/notification.py @@ -137,7 +137,7 @@ class SendNotificationWorkflowStatusItem(WebserviceCallStatusItem): role = Role.get(dest) except KeyError: continue - users.extend(get_publisher().user_class.get_users_with_role(role.id)) + users.extend(user for user in get_publisher().user_class.get_users_with_role(role.id) if user.is_active) for user in users: if not user: -- 2.26.2