Skip to content

Commit

Permalink
fix: Permission error while processing role based notifications (#20315
Browse files Browse the repository at this point in the history
…) (#20427)

(cherry picked from commit 9430b6a)

Co-authored-by: Ankush Menat <ankush@frappe.io>
  • Loading branch information
mergify[bot] and ankush committed Mar 22, 2023
1 parent 750059b commit f909a5a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion frappe/core/doctype/role/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ def on_update(self):
user.save()


def get_info_based_on_role(role, field="email"):
def get_info_based_on_role(role, field="email", ignore_permissions=False):
"""Get information of all users that have been assigned this role"""
users = frappe.get_list(
"Has Role",
filters={"role": role, "parenttype": "User"},
parent_doctype="User",
fields=["parent as user_name"],
ignore_permissions=ignore_permissions,
)

return get_user_info(users, field)
Expand Down
2 changes: 1 addition & 1 deletion frappe/email/doctype/notification/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def get_list_of_recipients(self, doc, context):

# For sending emails to specified role
if recipient.receiver_by_role:
emails = get_info_based_on_role(recipient.receiver_by_role, "email")
emails = get_info_based_on_role(recipient.receiver_by_role, "email", ignore_permissions=True)

for email in emails:
recipients = recipients + email.split("\n")
Expand Down

0 comments on commit f909a5a

Please sign in to comment.