Merge pull request #38942 from ShrihariMahabal/doc-follow-perm-check
fix: add perm check to document follow
This commit is contained in:
commit
961183f5a6
1 changed files with 6 additions and 0 deletions
|
|
@ -58,6 +58,9 @@ def follow_document(doctype: str, doc_name: str, user: str) -> Document | bool:
|
|||
frappe.toast(_("Administrator can't follow"))
|
||||
return False
|
||||
|
||||
if user != frappe.session.user and not frappe.has_permission("Document Follow", "write"):
|
||||
frappe.throw(_("You can only follow documents for yourself."), frappe.PermissionError)
|
||||
|
||||
if not frappe.db.get_value("User", user, "document_follow_notify", ignore=True, cache=True):
|
||||
frappe.toast(_("Document follow is not enabled for this user."))
|
||||
return False
|
||||
|
|
@ -74,6 +77,9 @@ def follow_document(doctype: str, doc_name: str, user: str) -> Document | bool:
|
|||
|
||||
@frappe.whitelist()
|
||||
def unfollow_document(doctype: str, doc_name: str, user: str) -> bool:
|
||||
if user != frappe.session.user and not frappe.has_permission("Document Follow", "write"):
|
||||
frappe.throw(_("You can only unfollow documents for yourself."), frappe.PermissionError)
|
||||
|
||||
doc = frappe.get_all(
|
||||
"Document Follow",
|
||||
filters={"ref_doctype": doctype, "ref_docname": doc_name, "user": user},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue