Fediverse: Better error on unknown profile.

This commit is contained in:
Valentin Lorentz 2020-05-09 19:28:37 +02:00
parent e87a14826e
commit 70fa18d155
3 changed files with 9 additions and 3 deletions

View File

@ -133,7 +133,7 @@ def webfinger(hostname, uri):
template = _get_webfinger_url(hostname)
assert template
with convert_exceptions(WebfingerError):
with convert_exceptions(ActorNotFound):
content = web.getUrlContent(
template.replace("{uri}", uri),
headers={"Accept": "application/json"},

View File

@ -145,9 +145,9 @@ class Fediverse(callbacks.Plugin):
try:
actor = ap.get_actor(localuser, hostname)
except ap.WebfingerError as e:
except ap.ActorNotFound as e:
# Usually a 404
irc.error(e.args[0], Raise=True)
irc.error("Unknown user %s." % username, Raise=True)
irc.reply(
_("\x02%s\x02 (@%s@%s): %s")

View File

@ -86,5 +86,11 @@ class FediverseTestCase(PluginTestCase):
# TODO: add a test with an instance which only allows fetches
# with valid signatures.
def testProfileUnknown(self):
self.assertResponse(
"profile @nonexistinguser@oc.todon.fr",
"Error: Unknown user @nonexistinguser@oc.todon.fr.",
)
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: