From 8f7f4e42247b224c46eb26a1f9d01ebf7137927f Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 16 Sep 2023 14:17:52 +0100 Subject: [PATCH] Include unavailable sites within inactive accounts feed --- daemon.py | 11 +++++++---- relationships.py | 19 +++++++++++++++---- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/daemon.py b/daemon.py index 24887f6ca..228243c2b 100644 --- a/daemon.py +++ b/daemon.py @@ -15564,14 +15564,15 @@ class PubServer(BaseHTTPRequestHandler): domain: str, port: int, getreq_start_time, proxy_type: str, cookie: str, debug: str, curr_session, - dormant_months: int) -> bool: + dormant_months: int, + sites_unavailable: []) -> bool: """Shows the inactive accounts feed """ following = \ get_inactive_feed(base_dir, domain, port, path, http_prefix, authorized, dormant_months, - FOLLOWS_PER_PAGE) + FOLLOWS_PER_PAGE, sites_unavailable) if following: if self._request_http(): page_number = 1 @@ -15582,7 +15583,8 @@ class PubServer(BaseHTTPRequestHandler): get_inactive_feed(base_dir, domain, port, path, http_prefix, authorized, dormant_months, - FOLLOWS_PER_PAGE) + FOLLOWS_PER_PAGE, + sites_unavailable) else: page_number_str = path.split('?page=')[1] if ';' in page_number_str: @@ -20994,7 +20996,8 @@ class PubServer(BaseHTTPRequestHandler): proxy_type, cookie, self.server.debug, curr_session, - self.server.dormant_months): + self.server.dormant_months, + self.server.sites_unavailable): self.server.getreq_busy = False return diff --git a/relationships.py b/relationships.py index 61f421d5c..ad6fdd123 100644 --- a/relationships.py +++ b/relationships.py @@ -308,7 +308,8 @@ def update_moved_actors(base_dir: str, debug: bool) -> None: def _get_inactive_accounts(base_dir: str, nickname: str, domain: str, - dormant_months: int) -> []: + dormant_months: int, + sites_unavailable: []) -> []: """returns a list of inactive accounts """ # get the list of followers @@ -332,6 +333,9 @@ def _get_inactive_accounts(base_dir: str, nickname: str, domain: str, if '@' in handle: follower_nickname = handle.split('@')[0] follower_domain = handle.split('@')[1] + if follower_domain in sites_unavailable: + result.append(handle) + continue found = False for http_prefix in ('https://', 'http://'): for users_str in users_list: @@ -355,16 +359,22 @@ def _get_inactive_accounts(base_dir: str, nickname: str, domain: str, break elif '://' in handle: actor = handle + follower_domain = actor.split('://')[1] + if '/' in follower_domain: + follower_domain = follower_domain.split('/')[0] + if follower_domain in sites_unavailable: + result.append(actor) + continue if is_dormant(base_dir, nickname, domain, actor, dormant_months): - result.append(handle) + result.append(actor) return result def get_inactive_feed(base_dir: str, domain: str, port: int, path: str, http_prefix: str, authorized: bool, dormant_months: int, - follows_per_page=12) -> {}: + follows_per_page: int, sites_unavailable: []) -> {}: """Returns the inactive accounts feed from GET requests. """ # Don't show inactive accounts to non-authorized viewers @@ -410,7 +420,8 @@ def get_inactive_feed(base_dir: str, domain: str, port: int, path: str, domain = get_full_domain(domain, port) lines = _get_inactive_accounts(base_dir, nickname, domain, - dormant_months) + dormant_months, + sites_unavailable) if header_only: first_str = \