mirror of https://gitlab.com/bashrc2/epicyon
Check for actor status expiry
parent
8b5fc1a7ef
commit
b5f406fecf
|
@ -12,6 +12,8 @@ import json
|
||||||
from roles import get_actor_roles_list
|
from roles import get_actor_roles_list
|
||||||
from skills import no_of_actor_skills
|
from skills import no_of_actor_skills
|
||||||
from skills import get_skills_from_list
|
from skills import get_skills_from_list
|
||||||
|
from utils import get_actor_status
|
||||||
|
from utils import actor_status_expired
|
||||||
from utils import get_nickname_from_actor
|
from utils import get_nickname_from_actor
|
||||||
from utils import load_json
|
from utils import load_json
|
||||||
from utils import get_json_content_from_accept
|
from utils import get_json_content_from_accept
|
||||||
|
@ -171,6 +173,11 @@ def show_person_profile(self, authorized: bool,
|
||||||
if secure_mode(curr_session, proxy_type, False,
|
if secure_mode(curr_session, proxy_type, False,
|
||||||
self.server, self.headers, self.path):
|
self.server, self.headers, self.path):
|
||||||
accept_str = self.headers['Accept']
|
accept_str = self.headers['Accept']
|
||||||
|
# has the actor status expired?
|
||||||
|
if get_actor_status(actor_json):
|
||||||
|
if actor_status_expired(actor_json['sm:status']):
|
||||||
|
# remove actor status
|
||||||
|
del actor_json['sm:status']
|
||||||
msg_str = json.dumps(actor_json, ensure_ascii=False)
|
msg_str = json.dumps(actor_json, ensure_ascii=False)
|
||||||
msg_str = convert_domains(calling_domain,
|
msg_str = convert_domains(calling_domain,
|
||||||
referer_domain,
|
referer_domain,
|
||||||
|
|
|
@ -26,6 +26,7 @@ from blocking import is_blocked_nickname
|
||||||
from blocking import is_blocked_domain
|
from blocking import is_blocked_domain
|
||||||
from content import valid_url_lengths
|
from content import valid_url_lengths
|
||||||
from posts import add_to_field
|
from posts import add_to_field
|
||||||
|
from utils import actor_status_expired
|
||||||
from utils import get_actor_status
|
from utils import get_actor_status
|
||||||
from utils import detect_mitm
|
from utils import detect_mitm
|
||||||
from utils import data_dir
|
from utils import data_dir
|
||||||
|
@ -704,6 +705,9 @@ def show_person_options(self, calling_domain: str, path: str,
|
||||||
also_known_as = remove_html(actor_json['alsoKnownAs'])
|
also_known_as = remove_html(actor_json['alsoKnownAs'])
|
||||||
repo_url = get_repo_url(actor_json)
|
repo_url = get_repo_url(actor_json)
|
||||||
status = get_actor_status(actor_json)
|
status = get_actor_status(actor_json)
|
||||||
|
if status:
|
||||||
|
if actor_status_expired(actor_json['sm:status']):
|
||||||
|
status = ''
|
||||||
|
|
||||||
access_keys = self.server.access_keys
|
access_keys = self.server.access_keys
|
||||||
nickname = 'instance'
|
nickname = 'instance'
|
||||||
|
|
|
@ -11,6 +11,7 @@ import os
|
||||||
import time
|
import time
|
||||||
from flags import is_recent_post
|
from flags import is_recent_post
|
||||||
from flags import is_quote_toot
|
from flags import is_quote_toot
|
||||||
|
from utils import actor_status_expired
|
||||||
from utils import get_quote_toot_url
|
from utils import get_quote_toot_url
|
||||||
from utils import get_actor_from_post_id
|
from utils import get_actor_from_post_id
|
||||||
from utils import contains_invalid_actor_url_chars
|
from utils import contains_invalid_actor_url_chars
|
||||||
|
@ -1136,6 +1137,9 @@ def receive_actor_status(base_dir: str, person_cache: {}, message_json: {},
|
||||||
if not actor_json:
|
if not actor_json:
|
||||||
print('DEBUG: receive_actor_status actor not found ' + actor_url)
|
print('DEBUG: receive_actor_status actor not found ' + actor_url)
|
||||||
return True
|
return True
|
||||||
|
if actor_status_expired(message_json):
|
||||||
|
print('DEBUG: receive_actor_status expired ' + str(message_json))
|
||||||
|
return True
|
||||||
actor_json['sm:status'] = message_json
|
actor_json['sm:status'] = message_json
|
||||||
allow_write_to_file = True
|
allow_write_to_file = True
|
||||||
store_person_in_cache(base_dir, actor_url,
|
store_person_in_cache(base_dir, actor_url,
|
||||||
|
|
29
utils.py
29
utils.py
|
@ -5574,3 +5574,32 @@ def get_actor_status(profile_json: {}) -> str:
|
||||||
status = status[:MAX_STATUS_LENGTH]
|
status = status[:MAX_STATUS_LENGTH]
|
||||||
status = standardize_text(status)
|
status = standardize_text(status)
|
||||||
return status
|
return status
|
||||||
|
|
||||||
|
|
||||||
|
def actor_status_expired(actor_status_json: {}) -> bool:
|
||||||
|
"""Has the given actor status expired?
|
||||||
|
"""
|
||||||
|
if not actor_status_json.get('endTime'):
|
||||||
|
return False
|
||||||
|
if not isinstance(actor_status_json['endTime'], str):
|
||||||
|
return False
|
||||||
|
if 'T' not in actor_status_json['endTime'] or \
|
||||||
|
':' not in actor_status_json['endTime']:
|
||||||
|
return False
|
||||||
|
date_formats = (
|
||||||
|
"%Y-%m-%dT%H:%M:%S%z",
|
||||||
|
"%Y-%m-%dT%H:%M:%S%Z"
|
||||||
|
)
|
||||||
|
status_end_time = None
|
||||||
|
try:
|
||||||
|
status_end_time = \
|
||||||
|
date_from_string_format(actor_status_json['endTime'],
|
||||||
|
date_formats)
|
||||||
|
except BaseException:
|
||||||
|
return False
|
||||||
|
if not status_end_time:
|
||||||
|
return False
|
||||||
|
curr_time = date_utcnow()
|
||||||
|
if status_end_time < curr_time:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
|
@ -16,6 +16,7 @@ from flags import is_system_account
|
||||||
from flags import is_group_account
|
from flags import is_group_account
|
||||||
from flags import is_valid_date
|
from flags import is_valid_date
|
||||||
from flags import is_premium_account
|
from flags import is_premium_account
|
||||||
|
from utils import actor_status_expired
|
||||||
from utils import get_actor_status
|
from utils import get_actor_status
|
||||||
from utils import get_person_icon
|
from utils import get_person_icon
|
||||||
from utils import text_mode_removals
|
from utils import text_mode_removals
|
||||||
|
@ -365,6 +366,9 @@ def html_profile_after_search(authorized: bool,
|
||||||
search_domain_full)
|
search_domain_full)
|
||||||
|
|
||||||
profile_status = get_actor_status(profile_json)
|
profile_status = get_actor_status(profile_json)
|
||||||
|
if profile_status:
|
||||||
|
if actor_status_expired(profile_json['sm:status']):
|
||||||
|
profile_status = ''
|
||||||
if profile_status:
|
if profile_status:
|
||||||
profile_status = \
|
profile_status = \
|
||||||
remove_link_trackers_from_content(profile_status)
|
remove_link_trackers_from_content(profile_status)
|
||||||
|
@ -1137,6 +1141,9 @@ def html_profile(signing_priv_key_pem: str,
|
||||||
display_name, False, translate)
|
display_name, False, translate)
|
||||||
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 actor_status_expired(profile_json['sm:status']):
|
||||||
|
profile_status = ''
|
||||||
if profile_status:
|
if profile_status:
|
||||||
profile_status = \
|
profile_status = \
|
||||||
remove_link_trackers_from_content(profile_status)
|
remove_link_trackers_from_content(profile_status)
|
||||||
|
|
Loading…
Reference in New Issue