diff --git a/server/features/planning.feature b/server/features/planning.feature index ee60b96c9..bdd30c513 100644 --- a/server/features/planning.feature +++ b/server/features/planning.feature @@ -777,7 +777,7 @@ Feature: Planning } """ When we get "activity" - Then we get list with 3 items + Then we get list with 4 items """ {"_items":[ { diff --git a/server/planning/assignments/assignments.py b/server/planning/assignments/assignments.py index e3e730b89..29fff708e 100644 --- a/server/planning/assignments/assignments.py +++ b/server/planning/assignments/assignments.py @@ -68,6 +68,7 @@ from apps.content import push_content_notification from .assignments_history import ASSIGNMENT_HISTORY_ACTIONS from planning.utils import get_event_formatted_dates, get_formatted_contacts +from superdesk.preferences import get_user_notification_preferences logger = logging.getLogger(__name__) planning_type = deepcopy(superdesk.Resource.rel("planning", type="string")) @@ -345,12 +346,15 @@ def send_assignment_notification(self, updates, original=None, force=False): return assigned_to = updates.get("assigned_to", {}) + assigned_to_user = None + + if assigned_to.get("user"): + assigned_to_user = get_resource_service("users").find_one(req=None, _id=assigned_to.get("user")) # No assignment notification sent, if user is not enabled assignment notification - if assigned_to.get("user") and not superdesk.get_resource_service( - "preferences" - ).check_preference_email_notification_is_enabled("assignments", user_id=assigned_to.get("user")): + if assigned_to_user and get_user_notification_preferences(assigned_to_user, "assignments")["email"] is False: return + assignment_id = updates.get("_id") or assigned_to.get("assignment_id", "Unknown") if not original: original = {} @@ -378,7 +382,6 @@ def send_assignment_notification(self, updates, original=None, force=False): ) if assignee is None and assigned_to.get("user"): - assigned_to_user = get_resource_service("users").find_one(req=None, _id=assigned_to.get("user")) if assigned_to_user and assigned_to_user.get("slack_username"): assignee = "@" + assigned_to_user.get("slack_username") else: