kopia lustrzana https://github.com/snarfed/bridgy-fed
rodzic
b1b2478b66
commit
bd19cab870
14
models.py
14
models.py
|
@ -840,13 +840,15 @@ class Object(StringIdModel):
|
|||
# outbound; show a nice link to the user
|
||||
return g.user.user_link()
|
||||
|
||||
actor = {}
|
||||
actor = None
|
||||
if self.as1:
|
||||
actor = (util.get_first(self.as1, 'actor')
|
||||
or util.get_first(self.as1, 'author')
|
||||
or {})
|
||||
if isinstance(actor, str):
|
||||
return common.pretty_link(actor, attrs=attrs)
|
||||
actor = (as1.get_object(self.as1, 'actor')
|
||||
or as1.get_object(self.as1, 'author'))
|
||||
|
||||
if not actor:
|
||||
return ''
|
||||
elif set(actor.keys()) == {'id'}:
|
||||
return common.pretty_link(actor['id'], attrs=attrs)
|
||||
|
||||
url = util.get_first(actor, 'url') or ''
|
||||
name = actor.get('displayName') or actor.get('username') or ''
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
{% block subtabs %}
|
||||
<div class="row">
|
||||
Subscribe:
|
||||
<a href="{{ g.user.user_page_path('feed') }}">HTML</a>
|
||||
<a href="{{ g.user.user_page_path('feed?format=html') }}">HTML</a>
|
||||
· <a href="{{ g.user.user_page_path('feed?format=atom') }}">Atom</a>
|
||||
· <a href="{{ g.user.user_page_path('feed?format=rss') }}">RSS</a>
|
||||
</div>
|
||||
|
|
|
@ -385,8 +385,9 @@ class ObjectTest(TestCase):
|
|||
|
||||
def test_actor_link(self):
|
||||
for expected, as2 in (
|
||||
('href="">', {}),
|
||||
('', {}),
|
||||
('href="http://foo">foo', {'actor': 'http://foo'}),
|
||||
('href="http://foo">foo', {'actor': {'id': 'http://foo'}}),
|
||||
('href="">Alice', {'actor': {'name': 'Alice'}}),
|
||||
('href="http://foo/">Alice', {'actor': {
|
||||
'name': 'Alice',
|
||||
|
@ -404,6 +405,10 @@ class ObjectTest(TestCase):
|
|||
obj = Object(id='x', as2=as2)
|
||||
self.assert_multiline_in(expected, obj.actor_link())
|
||||
|
||||
self.assertEqual(
|
||||
'<a class="h-card u-author" href="http://foo">foo</a>',
|
||||
Object(id='x', our_as1={'actor': {'id': 'http://foo'}}).actor_link())
|
||||
|
||||
def test_actor_link_user(self):
|
||||
g.user = Fake(id='fake:user', obj=Object(id='a', as2={"name": "Alice"}))
|
||||
obj = Object(id='x', source_protocol='ui', users=[g.user.key])
|
||||
|
|
Ładowanie…
Reference in New Issue