From 142d1810487ca667d00b1c88bd2181eece7026e7 Mon Sep 17 00:00:00 2001 From: jesopo Date: Sun, 8 Mar 2020 18:43:49 +0000 Subject: tolerate a server not having a host-meta --- modules/fediverse/ap_utils.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/fediverse/ap_utils.py b/modules/fediverse/ap_utils.py index 0d44d523..f77e800d 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"] -- cgit v1.3.1-10-gc9f91