From 91b8bb26b76072c60c903eaf6afbe9174eb52192 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Tue, 13 Sep 2022 21:02:47 +0200 Subject: [PATCH] Bugfixes --- app/incoming_activities.py | 2 +- app/utils/opengraph.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/incoming_activities.py b/app/incoming_activities.py index b1135cc..dc5beda 100644 --- a/app/incoming_activities.py +++ b/app/incoming_activities.py @@ -26,7 +26,7 @@ async def new_ap_incoming_activity( raw_object: ap.RawObject, ) -> models.IncomingActivity | None: ap_id: str - if "id" not in raw_object: + if "id" not in raw_object or ap.as_list(raw_object["type"])[0] in ap.ACTOR_TYPES: if "@context" not in raw_object: logger.warning(f"Dropping invalid object: {raw_object}") return None diff --git a/app/utils/opengraph.py b/app/utils/opengraph.py index 00571e7..02fdf87 100644 --- a/app/utils/opengraph.py +++ b/app/utils/opengraph.py @@ -81,6 +81,9 @@ async def external_urls( soup = BeautifulSoup(ro.content, "html5lib") for link in soup.find_all("a"): h = link.get("href") + if not h: + continue + ph = urlparse(h) mimetype, _ = mimetypes.guess_type(h) if (