kopia lustrzana https://github.com/snarfed/bridgy-fed
show Web user page even when direct is False
not other protocols thoughpull/799/head
rodzic
86079c3684
commit
907e6e7aeb
16
pages.py
16
pages.py
|
@ -79,15 +79,15 @@ 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 not user or not user.direct:
|
if user and (user.direct or protocol == 'web'):
|
||||||
# TODO: switch back to USER_NOT_FOUND_HTML
|
assert not user.use_instead
|
||||||
# not easy via exception/abort because this uses Werkzeug's built in
|
return user
|
||||||
# NotFound exception subclass, and we'd need to make it implement
|
|
||||||
# get_body to return arbitrary HTML.
|
|
||||||
error(f'{protocol} user {id} not found', status=404)
|
|
||||||
|
|
||||||
assert not user.use_instead
|
# TODO: switch back to USER_NOT_FOUND_HTML
|
||||||
return user
|
# not easy via exception/abort because this uses Werkzeug's built in
|
||||||
|
# NotFound exception subclass, and we'd need to make it implement
|
||||||
|
# get_body to return arbitrary HTML.
|
||||||
|
error(f'{protocol} user {id} not found', status=404)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
|
|
|
@ -98,9 +98,11 @@ 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):
|
||||||
self.user.direct = False
|
fake = self.make_user('fake:foo', cls=Fake)
|
||||||
self.user.put()
|
fake.direct = False
|
||||||
got = self.client.get('/web/user.com')
|
fake.put()
|
||||||
|
|
||||||
|
got = self.client.get('/fake/fake:foo')
|
||||||
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):
|
||||||
|
|
Ładowanie…
Reference in New Issue