actor status can be an activity

main
Bob Mottram 2025-05-15 20:09:45 +01:00
parent 9a41b51fd2
commit 783c598c26
3 changed files with 40 additions and 29 deletions

View File

@ -26,6 +26,7 @@ from blocking import is_blocked_nickname
from blocking import is_blocked_domain
from content import valid_url_lengths
from posts import add_to_field
from utils import get_actor_status
from utils import detect_mitm
from utils import data_dir
from utils import load_json
@ -702,11 +703,7 @@ def show_person_options(self, calling_domain: str, path: str,
if actor_json.get('alsoKnownAs'):
also_known_as = remove_html(actor_json['alsoKnownAs'])
repo_url = get_repo_url(actor_json)
# https://codeberg.org/fediverse/fep/src/branch/main/
# fep/82f6/fep-82f6.md
if actor_json.get('sm:status'):
if isinstance(actor_json['sm:status'], str):
status = actor_json['sm:status']
status = get_actor_status(actor_json)
access_keys = self.server.access_keys
nickname = 'instance'

View File

@ -5548,3 +5548,18 @@ def get_event_categories() -> []:
'THEATRE',
'WORKSHOPS_SKILL_SHARING'
)
def get_actor_status(profile_json: {}) -> str:
"""returns the actor status if it exists
https://codeberg.org/fediverse/fep/src/branch/main/fep/82f6/fep-82f6.md
"""
if not profile_json.get('sm:status'):
return ''
if isinstance(profile_json['sm:status'], str):
return profile_json['sm:status']
if isinstance(profile_json['sm:status'], dict):
if profile_json['sm:status'].get('content'):
if isinstance(profile_json['sm:status']['content'], str):
return profile_json['sm:status']['content']
return ''

View File

@ -16,6 +16,7 @@ from flags import is_system_account
from flags import is_group_account
from flags import is_valid_date
from flags import is_premium_account
from utils import get_actor_status
from utils import get_person_icon
from utils import text_mode_removals
from utils import replace_strings
@ -361,18 +362,17 @@ def html_profile_after_search(authorized: bool,
search_nickname,
search_domain_full)
profile_status = ''
if profile_json.get('sm:status'):
if isinstance(profile_json['sm:status'], str):
profile_status = remove_html(profile_json['sm:status'])
if len(profile_status) < 100:
profile_status = standardize_text(profile_status)
profile_status = \
remove_link_trackers_from_content(profile_status)
profile_status = \
add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain,
profile_status, False, translate)
profile_status = get_actor_status(profile_json)
if profile_status:
profile_status = remove_html(profile_status)
if len(profile_status) < 100:
profile_status = standardize_text(profile_status)
profile_status = \
remove_link_trackers_from_content(profile_status)
profile_status = \
add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain,
profile_status, False, translate)
profile_description = ''
if profile_json.get('summary'):
if not dangerous_markup(profile_json['summary'],
@ -1114,18 +1114,17 @@ def html_profile(signing_priv_key_pem: str,
nickname, domain,
display_name, False, translate)
domain_full = get_full_domain(domain, port)
profile_status = ''
if profile_json.get('sm:status'):
if isinstance(profile_json['sm:status'], str):
profile_status = remove_html(profile_json['sm:status'])
if len(profile_status) < 100:
profile_status = standardize_text(profile_status)
profile_status = \
remove_link_trackers_from_content(profile_status)
profile_status = \
add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain,
profile_status, False, translate)
profile_status = get_actor_status(profile_json)
if profile_status:
profile_status = remove_html(profile_status)
if len(profile_status) < 100:
profile_status = standardize_text(profile_status)
profile_status = \
remove_link_trackers_from_content(profile_status)
profile_status = \
add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain,
profile_status, False, translate)
if not dangerous_markup(profile_json['summary'], False, []):
profile_description = profile_json['summary']
else: