Ryan Barrett 2023-12-01 15:46:37 -08:00
rodzic d538928fe6
commit d0f7264db7
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 15 dodań i 2 usunięć

Wyświetl plik

@ -306,6 +306,15 @@ class WebfingerTest(TestCase):
base_url='https://web.brid.gy/')
self.assertEqual(400, got.status_code, got.get_data(as_text=True))
def test_no_handle(self):
class NoHandle(Fake):
ABBREV = 'noh'
handle = None
got = self.client.get(
'/.well-known/webfinger?resource=acct:nohandle:user@noh.brid.gy')
self.assertEqual(404, got.status_code)
@patch('requests.get')
def test_create_user(self, mock_get):
self.user.key.delete()

Wyświetl plik

@ -6,7 +6,7 @@
import logging
from urllib.parse import urljoin, urlparse
from flask import g, redirect, render_template, request
from flask import g, render_template, request
from granary import as2
from oauth_dropins.webutil import flask_util, util
from oauth_dropins.webutil.flask_util import error, flash, Found
@ -90,6 +90,10 @@ class Webfinger(flask_util.XrdOrJrd):
if not user:
error(f'No {cls.LABEL} user found for {id}', status=404)
ap_handle = user.handle_as('activitypub')
if not ap_handle:
error(f'{cls.LABEL} user {id} has no handle', status=404)
# backward compatibility for initial Web users whose AP actor ids are on
# fed.brid.gy, not web.brid.gy
subdomain = request.host.split('.')[0]
@ -111,7 +115,7 @@ class Webfinger(flask_util.XrdOrJrd):
# generate webfinger content
actor_id = user.id_as(activitypub.ActivityPub)
data = util.trim_nulls({
'subject': 'acct:' + user.handle_as('activitypub').lstrip('@'),
'subject': 'acct:' + ap_handle.lstrip('@'),
'aliases': urls,
'links':
[{