chore: refactor get_all_known_context_urls
This commit is contained in:
parent
c1f0e8ac61
commit
b7ef2be02e
1 changed files with 13 additions and 14 deletions
|
@ -356,21 +356,20 @@ def get_reply_toots(user_id, server, access_token, seen_urls, reply_since):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_all_known_context_urls(server, reply_toots,parsed_urls):
|
def get_all_known_context_urls(server, reply_toots, parsed_urls):
|
||||||
"""get the context toots of the given toots from their original server"""
|
"""get the context toots of the given toots from their original server"""
|
||||||
known_context_urls = set(
|
known_context_urls = set()
|
||||||
filter(
|
|
||||||
lambda url: not url.startswith(f"https://{server}/"),
|
for toot in reply_toots:
|
||||||
itertools.chain.from_iterable(
|
if toot_has_parseable_url(toot, parsed_urls):
|
||||||
get_toot_context(*parse_url(toot["url"] if toot["reblog"] is None else toot["reblog"]["url"],parsed_urls), toot["url"])
|
url = toot["url"] if toot["reblog"] is None else toot["reblog"]["url"]
|
||||||
for toot in filter(
|
parsed_url = parse_url(url, parsed_urls)
|
||||||
lambda toot: toot_has_parseable_url(toot,parsed_urls),
|
context = get_toot_context(parsed_url[0], parsed_url[1], url)
|
||||||
reply_toots
|
known_context_urls.update(context) # type: ignore
|
||||||
)
|
|
||||||
),
|
known_context_urls = set(filter(lambda url: not url.startswith(f"https://{server}/"), known_context_urls))
|
||||||
)
|
|
||||||
)
|
|
||||||
log(f"Found {len(known_context_urls)} known context toots")
|
log(f"Found {len(known_context_urls)} known context toots")
|
||||||
|
|
||||||
return known_context_urls
|
return known_context_urls
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue