fix: Optional parameter for setting extracted image as private

This commit is contained in:
MitulDavid 2021-10-07 16:41:44 +05:30
parent d254ca2f50
commit 05cb2c16cd
2 changed files with 2 additions and 3 deletions

View file

@ -813,7 +813,7 @@ def extract_images_from_doc(doc, fieldname):
doc.set(fieldname, content)
def extract_images_from_html(doc, content):
def extract_images_from_html(doc, content, is_private=False):
frappe.flags.has_dataurl = False
def _save_file(match):
@ -839,7 +839,6 @@ def extract_images_from_html(doc, content):
doctype = doc.parenttype if doc.parent else doc.doctype
name = doc.parent or doc.name
is_private = True if doctype == "Comment" else False
_file = frappe.get_doc({
"doctype": "File",

View file

@ -66,7 +66,7 @@ def add_comment(reference_doctype, reference_name, content, comment_email, comme
comment_type='Comment',
comment_by=comment_by
))
doc.content = extract_images_from_html(doc, content)
doc.content = extract_images_from_html(doc, content, is_private=True)
doc.insert(ignore_permissions=True)
follow_document(doc.reference_doctype, doc.reference_name, frappe.session.user)