kopia lustrzana https://github.com/snarfed/bridgy-fed
user pages: only hide indirect AP users, not ATProto
rodzic
0d549dc039
commit
817ef1d5d6
13
pages.py
13
pages.py
|
@ -60,17 +60,16 @@ def load_user(protocol, id):
|
||||||
:class:`werkzeug.exceptions.HTTPException` on error or redirect
|
:class:`werkzeug.exceptions.HTTPException` on error or redirect
|
||||||
"""
|
"""
|
||||||
assert id
|
assert id
|
||||||
if protocol == 'ap' and not id.startswith('@'):
|
|
||||||
id = '@' + id
|
|
||||||
|
|
||||||
cls = PROTOCOLS[protocol]
|
cls = PROTOCOLS[protocol]
|
||||||
|
|
||||||
|
if cls.ABBREV == 'ap' and not id.startswith('@'):
|
||||||
|
id = '@' + id
|
||||||
user = cls.get_by_id(id)
|
user = cls.get_by_id(id)
|
||||||
|
|
||||||
if protocol != 'web':
|
if cls.ABBREV != 'web':
|
||||||
if not user:
|
if not user:
|
||||||
user = cls.query(OR(cls.handle == id,
|
user = cls.query(OR(cls.handle == id, cls.handle == id)).get()
|
||||||
cls.readable_id == id),
|
|
||||||
).get()
|
|
||||||
if user and user.use_instead:
|
if user and user.use_instead:
|
||||||
user = user.use_instead.get()
|
user = user.use_instead.get()
|
||||||
|
|
||||||
|
@ -80,7 +79,7 @@ def load_user(protocol, id):
|
||||||
elif user and id != user.key.id(): # use_instead redirect
|
elif user and id != user.key.id(): # use_instead redirect
|
||||||
error('', status=302, location=user.user_page_path())
|
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
|
assert not user.use_instead
|
||||||
return user
|
return user
|
||||||
|
|
||||||
|
|
|
@ -99,11 +99,12 @@ class PagesTest(TestCase):
|
||||||
self.assert_equals(404, got.status_code)
|
self.assert_equals(404, got.status_code)
|
||||||
|
|
||||||
def test_user_not_direct(self):
|
def test_user_not_direct(self):
|
||||||
fake = self.make_user('fake:foo', cls=Fake)
|
fake = self.make_user('fake:foo', cls=Fake, direct=False)
|
||||||
fake.direct = False
|
|
||||||
fake.put()
|
|
||||||
|
|
||||||
got = self.client.get('/fake/fake:foo')
|
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)
|
self.assert_equals(404, got.status_code)
|
||||||
|
|
||||||
def test_user_opted_out(self):
|
def test_user_opted_out(self):
|
||||||
|
|
|
@ -303,8 +303,8 @@ class TestCase(unittest.TestCase, testutil.Asserts):
|
||||||
mf2=obj_mf2, source_protocol=cls.LABEL
|
mf2=obj_mf2, source_protocol=cls.LABEL
|
||||||
).key
|
).key
|
||||||
|
|
||||||
|
kwargs.setdefault('direct', True)
|
||||||
user = cls(id=id,
|
user = cls(id=id,
|
||||||
direct=True,
|
|
||||||
mod=global_user.mod,
|
mod=global_user.mod,
|
||||||
public_exponent=global_user.public_exponent,
|
public_exponent=global_user.public_exponent,
|
||||||
private_exponent=global_user.private_exponent,
|
private_exponent=global_user.private_exponent,
|
||||||
|
|
Ładowanie…
Reference in New Issue