fix followers/ing UI page for AP users

fixes #718
pull/737/head
Ryan Barrett 2023-11-27 21:01:02 -08:00
rodzic ee373095e2
commit 004726d397
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
4 zmienionych plików z 23 dodań i 4 usunięć

Wyświetl plik

@ -744,7 +744,7 @@ def postprocess_as2_actor(actor, user=None):
# required by pixelfed. https://github.com/snarfed/bridgy-fed/issues/39
actor.setdefault('summary', '')
if not actor.get('publicKey'):
if not actor.get('publicKey') and not isinstance(user, ActivityPub):
# underspecified, inferred from this issue and Mastodon's implementation:
# https://github.com/w3c/activitypub/issues/203#issuecomment-297553229
# https://github.com/tootsuite/mastodon/blob/bc2c263504e584e154384ecc2d804aeb1afb1ba3/app/services/activitypub/process_account_service.rb#L77
@ -897,6 +897,12 @@ def follower_collection(id, collection):
TODO: unify page generation with outbox()
"""
if (request.path.startswith('/ap/')
and request.host in (PRIMARY_DOMAIN,) + LOCAL_DOMAINS):
# UI request. unfortunate that the URL paths overlap like this!
import pages
return pages.followers_or_following('ap', id, collection)
protocol = Protocol.for_request(fed='web')
assert protocol
user = protocol.get_by_id(id)

Wyświetl plik

@ -20,7 +20,6 @@ from oauth_dropins.webutil.flask_util import (
redirect,
)
from activitypub import ActivityPub
import common
from common import DOMAIN_RE
from flask_app import app, cache
@ -169,7 +168,8 @@ def followers_or_following(protocol, id, collection):
f'{collection}.html',
address=request.args.get('address'),
follow_url=request.values.get('url'),
ActivityPub=ActivityPub,
# TODO: remove
ActivityPub=PROTOCOLS['activitypub'],
**TEMPLATE_VARS,
**locals(),
)

Wyświetl plik

@ -11,7 +11,8 @@
{% endif %}
{% endwith %}
{{ user_as1.get('displayName') or '' }}
{{ as2.address(ActivityPub.convert(f.user.obj) or url) or url }}
<!-- TODO: genericize -->
{{ as2.address(ActivityPub.convert(f.user.obj, from_user=user) or url) or url }}
</a>
{% endwith %}

Wyświetl plik

@ -232,6 +232,18 @@ class PagesTest(TestCase):
got = self.client.get('/fake/fake:foo/followers')
self.assert_equals(200, got.status_code)
def test_followers_activitypub(self):
obj = Object(id='https://inst/user', as2={
'id': 'https://inst/user',
'preferredUsername': 'user',
})
obj.put()
self.make_user('https://inst/user', cls=ActivityPub, obj=obj)
got = self.client.get('/ap/@user@inst/followers')
self.assert_equals(200, got.status_code)
self.assert_equals('text/html', got.headers['Content-Type'].split(';')[0])
def test_followers_empty(self):
got = self.client.get('/web/user.com/followers')
self.assert_equals(200, got.status_code)