mirror of https://gitlab.com/bashrc2/epicyon
Truncate status strings if needed
parent
351b45b282
commit
9908896ada
19
utils.py
19
utils.py
|
|
@ -23,6 +23,8 @@ from cryptography.hazmat.backends import default_backend
|
||||||
from cryptography.hazmat.primitives import hashes
|
from cryptography.hazmat.primitives import hashes
|
||||||
from followingCalendar import add_person_to_calendar
|
from followingCalendar import add_person_to_calendar
|
||||||
|
|
||||||
|
MAX_STATUS_LENGTH = 100
|
||||||
|
|
||||||
VALID_HASHTAG_CHARS = \
|
VALID_HASHTAG_CHARS = \
|
||||||
set('_0123456789' +
|
set('_0123456789' +
|
||||||
'abcdefghijklmnopqrstuvwxyz' +
|
'abcdefghijklmnopqrstuvwxyz' +
|
||||||
|
|
@ -5556,10 +5558,17 @@ def get_actor_status(profile_json: {}) -> str:
|
||||||
"""
|
"""
|
||||||
if not profile_json.get('sm:status'):
|
if not profile_json.get('sm:status'):
|
||||||
return ''
|
return ''
|
||||||
|
status = ''
|
||||||
if isinstance(profile_json['sm:status'], str):
|
if isinstance(profile_json['sm:status'], str):
|
||||||
return profile_json['sm:status']
|
status = profile_json['sm:status']
|
||||||
if isinstance(profile_json['sm:status'], dict):
|
elif isinstance(profile_json['sm:status'], dict):
|
||||||
if profile_json['sm:status'].get('content'):
|
if profile_json['sm:status'].get('content'):
|
||||||
if isinstance(profile_json['sm:status']['content'], str):
|
possible_status = profile_json['sm:status']['content']
|
||||||
return profile_json['sm:status']['content']
|
if isinstance(status, str):
|
||||||
return ''
|
status = possible_status
|
||||||
|
if status:
|
||||||
|
status = remove_html(status)
|
||||||
|
if len(status) > MAX_STATUS_LENGTH:
|
||||||
|
status = status[:MAX_STATUS_LENGTH]
|
||||||
|
status = standardize_text(status)
|
||||||
|
return status
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ from person import is_person_snoozed
|
||||||
from posts import is_moderator
|
from posts import is_moderator
|
||||||
from flags import is_featured_writer
|
from flags import is_featured_writer
|
||||||
from flags import is_dormant
|
from flags import is_dormant
|
||||||
from utils import standardize_text
|
|
||||||
from utils import data_dir
|
from utils import data_dir
|
||||||
from utils import quote_toots_allowed
|
from utils import quote_toots_allowed
|
||||||
from utils import get_full_domain
|
from utils import get_full_domain
|
||||||
|
|
@ -403,8 +402,6 @@ def html_person_options(default_timeline: str,
|
||||||
if status:
|
if status:
|
||||||
# https://codeberg.org/fediverse/fep/src/branch/main/
|
# https://codeberg.org/fediverse/fep/src/branch/main/
|
||||||
# fep/82f6/fep-82f6.md
|
# fep/82f6/fep-82f6.md
|
||||||
if len(status) < 100:
|
|
||||||
status = standardize_text(status)
|
|
||||||
if is_filtered(base_dir, nickname, domain, status,
|
if is_filtered(base_dir, nickname, domain, status,
|
||||||
system_language):
|
system_language):
|
||||||
status_str = 'Status'
|
status_str = 'Status'
|
||||||
|
|
|
||||||
|
|
@ -364,9 +364,6 @@ def html_profile_after_search(authorized: bool,
|
||||||
|
|
||||||
profile_status = get_actor_status(profile_json)
|
profile_status = get_actor_status(profile_json)
|
||||||
if profile_status:
|
if profile_status:
|
||||||
profile_status = remove_html(profile_status)
|
|
||||||
if len(profile_status) < 100:
|
|
||||||
profile_status = standardize_text(profile_status)
|
|
||||||
profile_status = \
|
profile_status = \
|
||||||
remove_link_trackers_from_content(profile_status)
|
remove_link_trackers_from_content(profile_status)
|
||||||
profile_status = \
|
profile_status = \
|
||||||
|
|
@ -1124,9 +1121,6 @@ def html_profile(signing_priv_key_pem: str,
|
||||||
domain_full = get_full_domain(domain, port)
|
domain_full = get_full_domain(domain, port)
|
||||||
profile_status = get_actor_status(profile_json)
|
profile_status = get_actor_status(profile_json)
|
||||||
if profile_status:
|
if profile_status:
|
||||||
profile_status = remove_html(profile_status)
|
|
||||||
if len(profile_status) < 100:
|
|
||||||
profile_status = standardize_text(profile_status)
|
|
||||||
profile_status = \
|
profile_status = \
|
||||||
remove_link_trackers_from_content(profile_status)
|
remove_link_trackers_from_content(profile_status)
|
||||||
profile_status = \
|
profile_status = \
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue