Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show comment in email #1658

Merged
merged 3 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions helpdesk/helpdesk/doctype/hd_notification/hd_notification.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"references_section",
"reference_ticket",
"column_break_ibly",
"reference_comment"
"reference_comment",
"message"
],
"fields": [
{
Expand Down Expand Up @@ -72,11 +73,16 @@
"fieldname": "read",
"fieldtype": "Check",
"label": "Read"
},
{
"fieldname": "message",
"fieldtype": "Text",
"label": "Message"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-09-19 23:49:50.165958",
"modified": "2023-12-19 15:31:37.669662",
"modified_by": "Administrator",
"module": "Helpdesk",
"name": "HD Notification",
Expand Down
11 changes: 11 additions & 0 deletions helpdesk/helpdesk/doctype/hd_notification/hd_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,23 @@
res += "#" + self.reference_comment
return frappe.utils.get_url(res)

def parse_html(self):
from bs4 import BeautifulSoup

Check warning on line 35 in helpdesk/helpdesk/doctype/hd_notification/hd_notification.py

View check run for this annotation

Codecov / codecov/patch

helpdesk/helpdesk/doctype/hd_notification/hd_notification.py#L34-L35

Added lines #L34 - L35 were not covered by tests

soup = BeautifulSoup(self.message, "html.parser")
if soup.find("img"):
img = soup.find("img")
img["src"] = ("").join([frappe.utils.get_url(), img["src"]])
return str(soup)
return str(soup)

Check warning on line 42 in helpdesk/helpdesk/doctype/hd_notification/hd_notification.py

View check run for this annotation

Codecov / codecov/patch

helpdesk/helpdesk/doctype/hd_notification/hd_notification.py#L37-L42

Added lines #L37 - L42 were not covered by tests

def get_args(self):
if self.notification_type == "Mention":
return {
"title": self.format_message(),
"button_label": self.get_button_label(),
"callback_url": self.get_url(),
"comment": self.parse_html(),
}

def after_insert(self):
Expand Down
1 change: 1 addition & 0 deletions helpdesk/mixins/mentions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def notify_mentions(self):
user_from=self.owner,
user_to=mention.email,
notification_type="Mention",
message=self.content,
)
# Why mention oneself?
if values.user_from == values.user_to:
Expand Down
2 changes: 1 addition & 1 deletion helpdesk/setup/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def after_install():


def add_support_redirect_to_tickets():
website_settings = frappe.get_doc("Website Settings")
website_settings = frappe.new_doc("Website Settings")

for route_redirects in website_settings.route_redirects:
if route_redirects.source == "support":
Expand Down
3 changes: 2 additions & 1 deletion helpdesk/templates/emails/notification.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ <h2>
{{ title }}
</h2>
<p>
<div>{{ comment }}</div>
<a class="btn btn-primary" href="{{ callback_url }}">
{{ button_label }}
</a>
</p>
</p>
Loading