Remove initial mentions from edited posts

main
Bob Mottram 2022-11-16 11:25:06 +00:00
parent 2289eaba44
commit 9172337315
1 changed files with 20 additions and 0 deletions

View File

@ -229,6 +229,24 @@ def _get_date_from_tags(tags: []) -> (str, str):
return '', '' return '', ''
def _remove_initial_mentions_from_content(content: str) -> str:
""" Removes initial @mentions from content
This happens when a the html content is converted back to plain text
"""
if not content.startswith('@'):
return content
words = content.split(' ')
new_content = ''
for wrd in words:
if wrd.startswith('@'):
continue
if new_content:
new_content += ' ' + wrd
else:
new_content += wrd
return new_content
def html_new_post(edit_post_params: {}, def html_new_post(edit_post_params: {},
media_instance: bool, translate: {}, media_instance: bool, translate: {},
base_dir: str, http_prefix: str, base_dir: str, http_prefix: str,
@ -1058,6 +1076,8 @@ def html_new_post(edit_post_params: {},
languages_understood, "content") languages_understood, "content")
if content_str: if content_str:
default_message = remove_html(content_str) default_message = remove_html(content_str)
default_message = \
_remove_initial_mentions_from_content(default_message)
new_post_form += \ new_post_form += \
' <textarea id="message" name="message" style="height:' + \ ' <textarea id="message" name="message" style="height:' + \