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: Convert HTML instead of stripping html tags #650

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
2 changes: 1 addition & 1 deletion raven/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
[post_model_sync]
raven.patches.v1_2.create_raven_users
raven.patches.v1_3.create_raven_message_indexes #23
raven.patches.v1_3.update_all_messages_to_include_message_content #1
raven.patches.v1_3.update_all_messages_to_include_message_content #2
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import frappe
from frappe.utils import strip_html_tags

from frappe.core.utils import html2text

def execute():
update_old_messages_to_include_message_content()
Expand All @@ -18,8 +17,7 @@ def update_old_messages_to_include_message_content():
'name', 'text', 'message_type'])
for message in messages:
if message.text:
cleaned_text = strip_html_tags(message.text).replace(
'\ufeff', '').replace(' ', ' ')
cleaned_text = html2text(message.text)
content = cleaned_text
frappe.db.set_value(
'Raven Message', message.name, 'content', content)
Expand Down
6 changes: 2 additions & 4 deletions raven/raven_messaging/doctype/raven_message/raven_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import frappe
from frappe import _
from frappe.model.document import Document
from frappe.utils import strip_html_tags
from raven.api.raven_message import track_visit

from frappe.core.utils import html2text

class RavenMessage(Document):
# begin: auto-generated types
Expand Down Expand Up @@ -37,8 +36,7 @@ class RavenMessage(Document):
def before_validate(self):
try:
if self.text:
self.content = strip_html_tags(self.text).replace(
'\ufeff', '').replace(' ', ' ')
self.content = html2text(self.text)
except Exception:
pass
def validate(self):
Expand Down
Loading