kopia lustrzana https://github.com/snarfed/bridgy-fed
Activity => Object: user dashboard UI bug fixes, add missing Object index
rodzic
9680f6f83e
commit
2a1b199558
|
@ -20,6 +20,13 @@ indexes:
|
|||
- name: updated
|
||||
direction: desc
|
||||
|
||||
- kind: Object
|
||||
properties:
|
||||
- name: domains
|
||||
- name: labels
|
||||
- name: created
|
||||
direction: desc
|
||||
|
||||
- kind: Follower
|
||||
properties:
|
||||
- name: dest
|
||||
|
|
13
models.py
13
models.py
|
@ -334,15 +334,16 @@ class Object(StringIdModel):
|
|||
return common.host_url('render?' +
|
||||
urllib.parse.urlencode({'id': self.key.id()}))
|
||||
|
||||
def actor_link(self, as1=None):
|
||||
def actor_link(self):
|
||||
"""Returns a pretty actor link with their name and profile picture."""
|
||||
if self.direction == 'out' and self.domains:
|
||||
if self.source_protocol == 'webmention' and self.domains:
|
||||
# TODO: why do we do this?!
|
||||
return User.get_by_id(self.domains[0]).user_page_link()
|
||||
|
||||
if not as1:
|
||||
as1 = self.to_as1()
|
||||
|
||||
actor = util.get_first(as1, 'actor') or util.get_first(as1, 'author') or {}
|
||||
activity = json_loads(self.as1)
|
||||
actor = (util.get_first(activity, 'actor')
|
||||
or util.get_first(activity, 'author')
|
||||
or {})
|
||||
if isinstance(actor, str):
|
||||
return util.pretty_link(actor)
|
||||
|
||||
|
|
12
pages.py
12
pages.py
|
@ -63,11 +63,6 @@ def check_web_site():
|
|||
return redirect(f'/user/{user.key.id()}')
|
||||
|
||||
|
||||
@app.get(f'/responses/<regex("{DOMAIN_RE}"):domain>') # deprecated
|
||||
def user_deprecated(domain):
|
||||
return redirect(f'/user/{domain}', code=301)
|
||||
|
||||
|
||||
@app.get(f'/user/<regex("{DOMAIN_RE}"):domain>')
|
||||
def user(domain):
|
||||
user = User.get_by_id(domain)
|
||||
|
@ -80,7 +75,7 @@ def user(domain):
|
|||
|
||||
query = Object.query(
|
||||
Object.domains == domain,
|
||||
Object.labels == 'notification',
|
||||
Object.labels.IN(('notification', 'user')),
|
||||
)
|
||||
objects, before, after = fetch_objects(query)
|
||||
|
||||
|
@ -173,12 +168,11 @@ def fetch_objects(query):
|
|||
new_before, new_after: str query param values for `before` and `after`
|
||||
to fetch the previous and next pages, respectively
|
||||
"""
|
||||
orig_objects, new_before, new_after = common.fetch_page(query, Object)
|
||||
objects = []
|
||||
objects, new_before, new_after = common.fetch_page(query, Object)
|
||||
seen = set()
|
||||
|
||||
# synthesize human-friendly content for objects
|
||||
for i, obj in enumerate(orig_objects):
|
||||
for i, obj in enumerate(objects):
|
||||
obj_as1 = json_loads(obj.as1)
|
||||
|
||||
# synthesize text snippet
|
||||
|
|
|
@ -174,6 +174,23 @@ class ObjectTest(testutil.TestCase):
|
|||
obj = Object(id='abc', as1='{}')
|
||||
self.assertEqual('http://localhost/render?id=abc', obj.proxy_url())
|
||||
|
||||
def test_actor_url(self):
|
||||
for expected, as1 in (
|
||||
('<a href=""></a>', {}),
|
||||
('<a href="http://foo">foo</a>', {'actor': 'http://foo'}),
|
||||
('<a href="">Alice</a>', {'actor': {'displayName': 'Alice'}}),
|
||||
('<a href="http://foo">Alice</a>', {'actor': {
|
||||
'displayName': 'Alice',
|
||||
'url': 'http://foo',
|
||||
}}),
|
||||
("""\
|
||||
<a href="" title="Alice">
|
||||
<img class="profile" src="http://pic" />
|
||||
Alice
|
||||
</a>""", {'actor': {'displayName': 'Alice', 'image': 'http://pic'}}),
|
||||
):
|
||||
self.assertEqual(expected, Object(id='x', as1=json_dumps(as1)).actor_link())
|
||||
|
||||
|
||||
class FollowerTest(testutil.TestCase):
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue