Deal with 404 in get_redirect_url

This should address #1
This commit is contained in:
Michael Thomas 2023-03-07 11:20:39 +00:00
parent 23382cca67
commit 43bd2a2825

View file

@ -255,6 +255,9 @@ def parse_pleroma_url(url):
if match is not None:
server = match.group("server")
url = get_redirect_url(url)
if url is None:
return None
match = re.match(r"/notice/(?P<toot_id>.*)", url)
if match is not None:
return (server, match.group("toot_id"))
@ -271,7 +274,7 @@ def get_redirect_url(url):
return None
if resp.status_code == 200:
return None
return url
elif resp.status_code == 302:
redirect_url = resp.headers["Location"]
print(f"Discovered redirect for URL {url}")