mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
API: fix for queries by community name
This commit is contained in:
parent
ea1564cc87
commit
506becc41c
2 changed files with 4 additions and 2 deletions
|
@ -13,7 +13,8 @@ from sqlalchemy import desc
|
|||
def cached_post_list(type, sort, user_id, community_id, community_name, person_id):
|
||||
if type == "All":
|
||||
if community_name:
|
||||
posts = Post.query.filter_by(deleted=False).join(Community, Community.id == Post.community_id).filter_by(show_all=True, name=community_name)
|
||||
name, ap_domain = community_name.split('@')
|
||||
posts = Post.query.filter_by(deleted=False).join(Community, Community.id == Post.community_id).filter_by(show_all=True, name=name, ap_domain=ap_domain)
|
||||
elif community_id:
|
||||
posts = Post.query.filter_by(deleted=False).join(Community, Community.id == Post.community_id).filter_by(show_all=True, id=community_id)
|
||||
elif person_id:
|
||||
|
|
|
@ -172,7 +172,8 @@ def community_view(community: Community | int | str, variant, stub=False, user_i
|
|||
if isinstance(community, int):
|
||||
community = Community.query.get(community)
|
||||
elif isinstance(community, str):
|
||||
community = Community.query.filter_by(name=community).first()
|
||||
name, ap_domain = community.split('@')
|
||||
community = Community.query.filter_by(name=name, ap_domain=ap_domain).first()
|
||||
if not community:
|
||||
raise Exception('community_not_found')
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue