mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
server/posts: include thumbnail URLs in relations
This commit is contained in:
@ -90,7 +90,15 @@ def serialize_post(post, authenticated_user, options=None):
|
||||
tag.category.name,
|
||||
tag.names[0].name)
|
||||
)],
|
||||
'relations': lambda: [rel.post_id for rel in post.relations],
|
||||
'relations': lambda: sorted(
|
||||
{
|
||||
post['id']:
|
||||
post for post in [
|
||||
serialize_micro_post(rel) \
|
||||
for rel in post.related_by + post.relating_to
|
||||
]
|
||||
}.values(),
|
||||
key=lambda post: post['id']),
|
||||
'user': lambda: users.serialize_micro_user(post.user),
|
||||
'score': lambda: post.score,
|
||||
'ownScore': lambda: scores.get_score(post, authenticated_user),
|
||||
@ -120,6 +128,12 @@ def serialize_post(post, authenticated_user, options=None):
|
||||
},
|
||||
options)
|
||||
|
||||
def serialize_micro_post(post):
|
||||
return serialize_post(
|
||||
post,
|
||||
authenticated_user=None,
|
||||
options=['id', 'thumbnailUrl'])
|
||||
|
||||
def get_post_count():
|
||||
return db.session.query(sqlalchemy.func.count(db.Post.post_id)).one()[0]
|
||||
|
||||
|
Reference in New Issue
Block a user