aboutsummaryrefslogtreecommitdiff
path: root/modules/fediverse/ap_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'modules/fediverse/ap_utils.py')
-rw-r--r--modules/fediverse/ap_utils.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/modules/fediverse/ap_utils.py b/modules/fediverse/ap_utils.py
index 0d44d523..9174648c 100644
--- a/modules/fediverse/ap_utils.py
+++ b/modules/fediverse/ap_utils.py
@@ -39,15 +39,17 @@ class FindActorException(Exception):
pass
def find_actor(username, instance):
- hostmeta = HOSTMETA_TEMPLATE % instance
- hostmeta_request = utils.http.Request(HOSTMETA_TEMPLATE % instance)
+ hostmeta_url = HOSTMETA_TEMPLATE % instance
+ hostmeta_request = utils.http.Request(hostmeta_url)
try:
hostmeta = utils.http.request(hostmeta_request)
except:
- raise FindActorException("Failed to get host-meta for %s" % instance)
+ # failed to GET hostmeta; this is an optional step for servers that do
+ # not host their webfinger at the usual URL (see WEBFINGER_TEMPLATE)
+ hostmeta = None
webfinger_url = None
- if hostmeta.code == 200:
+ if hostmeta and hostmeta.code == 200:
for item in hostmeta.soup().find_all("link"):
if item["rel"] and item["rel"][0] == "lrdd":
webfinger_url = item["template"]
@@ -60,8 +62,9 @@ def find_actor(username, instance):
try:
webfinger = activity_request(webfinger_url, type=JRD_TYPE)
- except:
- raise FindActorException("Failed to get webfinger for %s" % instance)
+ except Exception as e:
+ raise FindActorException("Failed to get webfinger for %s: %s" %
+ (instance, str(e)))
actor_url = None
if webfinger.code == 200: