This commit is contained in:
nanos 2024-06-27 17:13:37 +01:00
parent e0faafb37a
commit e7da9a1f61

View file

@ -751,22 +751,13 @@ def get_redirect_url(url):
def get_all_context_urls(server, replied_toot_ids, seen_hosts): def get_all_context_urls(server, replied_toot_ids, seen_hosts):
"""get the URLs of the context toots of the given toots""" """get the URLs of the context toots of the given toots"""
known_context_urls = set() return filter(
for (url, (server, toot_id)) in replied_toot_ids: lambda url: not url.startswith(f"https://{server}/"),
if(toot_context_should_be_fetched(toot)): itertools.chain.from_iterable(
recently_checked_context[toot['uri']]['lastSeen'] = datetime.now(datetime.now().astimezone().tzinfo) get_toot_context(server, toot_id, url, seen_hosts)
context = get_toot_context(server, toot_id, url, seen_hosts) for (url, (server, toot_id)) in replied_toot_ids
if context is not None: ),
for item in context: )
known_context_urls.add(item)
else:
logger.error(f"Error getting context for toot {url}")
known_context_urls = set(filter(lambda url: not url.startswith(f"https://{server}/"), known_context_urls))
logger.info(f"Found {len(known_context_urls)} known context toots")
return known_context_urls
def get_toot_context(server, toot_id, toot_url, seen_hosts): def get_toot_context(server, toot_id, toot_url, seen_hosts):