From 9c89e0fbaf6ecc4c46e6963fe5edae2769f1cd06 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Mon, 9 Sep 2024 09:46:04 +1000 Subject: [PATCH 1/2] sign all AP requests We have been attempting unsigned GET requests and then if they fail, sending another signed request within the same loop. This not only causes single-threaded instances to fail, confusing new users, but is also unnecessary, since servers that don't require requests to be signed will just ignore the signed headers. Signing all AP requests simplifies things and should see a marginal increase in speed when interacting with new servers that require signed payloads. --- bookwyrm/activitypub/base_activity.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/bookwyrm/activitypub/base_activity.py b/bookwyrm/activitypub/base_activity.py index dc4b8f6ae1..9f1afda592 100644 --- a/bookwyrm/activitypub/base_activity.py +++ b/bookwyrm/activitypub/base_activity.py @@ -369,17 +369,13 @@ def resolve_remote_id( # load the data and create the object try: - data = get_data(remote_id) + data = get_activitypub_data(remote_id) except ConnectionError: logger.info("Could not connect to host for remote_id: %s", remote_id) return None except requests.HTTPError as e: - if (e.response is not None) and e.response.status_code == 401: - # This most likely means it's a mastodon with secure fetch enabled. - data = get_activitypub_data(remote_id) - else: - logger.info("Could not connect to host for remote_id: %s", remote_id) - return None + logger.info("Could not connect to host for remote_id: %s", remote_id) + return None # determine the model implicitly, if not provided # or if it's a model with subclasses like Status, check again if not model or hasattr(model.objects, "select_subclasses"): From cfe10fa87487283b922d815313df24b7fcf30a1a Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Mon, 9 Sep 2024 10:19:03 +1000 Subject: [PATCH 2/2] update error message --- bookwyrm/activitypub/base_activity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/activitypub/base_activity.py b/bookwyrm/activitypub/base_activity.py index 9f1afda592..8ba8c6e1a2 100644 --- a/bookwyrm/activitypub/base_activity.py +++ b/bookwyrm/activitypub/base_activity.py @@ -374,7 +374,7 @@ def resolve_remote_id( logger.info("Could not connect to host for remote_id: %s", remote_id) return None except requests.HTTPError as e: - logger.info("Could not connect to host for remote_id: %s", remote_id) + logger.exception("HTTP error - remote_id: %s - error: %s", remote_id, e) return None # determine the model implicitly, if not provided # or if it's a model with subclasses like Status, check again