Skip to content

Commit 74f6858

Browse files
committed
Merge remote-tracking branch 'origin/hotfix/2.6.8' into develop
2 parents e8f931b + 9c2957e commit 74f6858

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

apps/desks.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ def __compare_members(self, original, updates):
275275

276276
def __send_notification(self, updates, desk):
277277
desk_id = desk[config.ID_FIELD]
278+
users_service = superdesk.get_resource_service("users")
278279

279280
if "members" in updates:
280281
added, removed = self.__compare_members(desk.get("members", {}), updates["members"])
@@ -284,7 +285,7 @@ def __send_notification(self, updates, desk):
284285
)
285286

286287
for added_user in added:
287-
user = superdesk.get_resource_service("users").find_one(req=None, _id=added_user)
288+
user = users_service.find_one(req=None, _id=added_user)
288289
activity = add_activity(
289290
ACTIVITY_UPDATE,
290291
"user {{user}} has been added to desk {{desk}}: Please re-login.",
@@ -295,8 +296,12 @@ def __send_notification(self, updates, desk):
295296
desk=desk.get("name"),
296297
)
297298
push_notification("activity", _dest=activity["recipients"])
299+
users_service.update_stage_visibility_for_user(user)
300+
301+
for removed_user in removed:
302+
user = users_service.find_one(req=None, _id=removed_user)
303+
users_service.update_stage_visibility_for_user(user)
298304

299-
get_resource_service("users").update_stage_visibility_for_users()
300305
else:
301306
push_notification(self.notification_key, updated=1, desk_id=str(desk.get(config.ID_FIELD)))
302307

superdesk/eve_backend.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,9 @@ def _change_request(self, endpoint_name, id, updates, original, change_request=F
260260
else:
261261
backend.update(endpoint_name, id, updates, original)
262262
if push_notification:
263-
self._push_resource_notification(
264-
"updated", endpoint_name, _id=str(id), fields=get_diff_keys(updates, original)
265-
)
263+
updated_fields = get_diff_keys(updates, original)
264+
if updated_fields:
265+
self._push_resource_notification("updated", endpoint_name, _id=str(id), fields=updated_fields)
266266
except eve.io.base.DataLayer.OriginalChangedError:
267267
if not backend.find_one(endpoint_name, req=None, _id=id) and search_backend:
268268
# item is in elastic, not in mongo - not good

0 commit comments

Comments
 (0)