feat: Restrict user in mentions (#6520)

Avoid mentioning and accidentally sending email to Supplier or Customer or left employees
This commit is contained in:
KanchanChauhan 2018-11-22 11:50:46 +05:30 committed by Suraj Shetty
parent 9d18c76cfa
commit f581ebfbb8
4 changed files with 2199 additions and 2166 deletions

View file

@ -194,7 +194,7 @@ def load_translations(bootinfo):
def get_fullnames():
"""map of user fullnames"""
ret = frappe.db.sql("""select `name`, full_name as fullname,
user_image as image, gender, email, username, bio, location, interest, banner_image
user_image as image, gender, email, username, bio, location, interest, banner_image, allowed_in_mentions
from tabUser where enabled=1 and user_type!='Website User'""", as_dict=1)
d = {}

View file

@ -94,7 +94,7 @@ def notify_mentions(doc):
subject = _("{0} mentioned you in a comment in {1}").format(sender_fullname, parent_doc_label)
recipients = [frappe.db.get_value("User", {"enabled": 1, "name": name, "user_type": "System User"}, "email")
recipients = [frappe.db.get_value("User", {"enabled": 1, "name": name, "user_type": "System User", "allowed_in_mentions": 1}, "email")
for name in mentions]
frappe.sendmail(
recipients=recipients,

File diff suppressed because it is too large Load diff

View file

@ -730,7 +730,8 @@ frappe.ui.form.Timeline = class Timeline {
get_names_for_mentions() {
var valid_users = Object.keys(frappe.boot.user_info)
.filter(user => !["Administrator", "Guest"].includes(user));
valid_users = valid_users
.filter(user => frappe.boot.user_info[user].allowed_in_mentions==1);
return valid_users.map(user => frappe.boot.user_info[user].name);
}