user pages: only hide indirect AP users, not ATProto

pull/953/head
Ryan Barrett 2024-04-11 14:24:18 -07:00
rodzic 0d549dc039
commit 817ef1d5d6
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
3 zmienionych plików z 12 dodań i 12 usunięć

Wyświetl plik

@ -60,17 +60,16 @@ def load_user(protocol, id):
:class:`werkzeug.exceptions.HTTPException` on error or redirect
"""
assert id
if protocol == 'ap' and not id.startswith('@'):
id = '@' + id
cls = PROTOCOLS[protocol]
if cls.ABBREV == 'ap' and not id.startswith('@'):
id = '@' + id
user = cls.get_by_id(id)
if protocol != 'web':
if cls.ABBREV != 'web':
if not user:
user = cls.query(OR(cls.handle == id,
cls.readable_id == id),
).get()
user = cls.query(OR(cls.handle == id, cls.handle == id)).get()
if user and user.use_instead:
user = user.use_instead.get()
@ -80,7 +79,7 @@ def load_user(protocol, id):
elif user and id != user.key.id(): # use_instead redirect
error('', status=302, location=user.user_page_path())
if user and (user.direct or protocol == 'web'):
if user and (user.direct or cls.ABBREV != 'ap'):
assert not user.use_instead
return user

Wyświetl plik

@ -99,11 +99,12 @@ class PagesTest(TestCase):
self.assert_equals(404, got.status_code)
def test_user_not_direct(self):
fake = self.make_user('fake:foo', cls=Fake)
fake.direct = False
fake.put()
fake = self.make_user('fake:foo', cls=Fake, direct=False)
got = self.client.get('/fake/fake:foo')
self.assert_equals(200, got.status_code)
fake = self.make_user('http://fo/o', cls=ActivityPub, direct=False)
got = self.client.get('/ap/@o@fo')
self.assert_equals(404, got.status_code)
def test_user_opted_out(self):

Wyświetl plik

@ -303,8 +303,8 @@ class TestCase(unittest.TestCase, testutil.Asserts):
mf2=obj_mf2, source_protocol=cls.LABEL
).key
kwargs.setdefault('direct', True)
user = cls(id=id,
direct=True,
mod=global_user.mod,
public_exponent=global_user.public_exponent,
private_exponent=global_user.private_exponent,