mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-03 00:31:25 -08:00
Merge pull request 'hide nsfw communities on request and for unauthenticated users' (#230) from h3ndrik/pyfedi:nsfw3 into main
Reviewed-on: https://codeberg.org/rimu/pyfedi/pulls/230
This commit is contained in:
commit
8b474382b0
1 changed files with 12 additions and 0 deletions
|
@ -211,6 +211,12 @@ def list_communities():
|
|||
banned_from = communities_banned_from(current_user.id)
|
||||
if banned_from:
|
||||
communities = communities.filter(Community.id.not_in(banned_from))
|
||||
if not current_user.show_nsfw:
|
||||
communities = communities.filter(Community.nsfw == False)
|
||||
if not current_user.show_nsfl:
|
||||
communities = communities.filter(Community.nsfl == False)
|
||||
else:
|
||||
communities = communities.filter(and_(Community.nsfw == False, Community.nsfl == False))
|
||||
|
||||
communities = communities.order_by(text('community.' + sort_by))
|
||||
|
||||
|
@ -257,6 +263,12 @@ def list_local_communities():
|
|||
banned_from = communities_banned_from(current_user.id)
|
||||
if banned_from:
|
||||
communities = communities.filter(Community.id.not_in(banned_from))
|
||||
if not current_user.show_nsfw:
|
||||
communities = communities.filter(Community.nsfw == False)
|
||||
if not current_user.show_nsfl:
|
||||
communities = communities.filter(Community.nsfl == False)
|
||||
else:
|
||||
communities = communities.filter(and_(Community.nsfw == False, Community.nsfl == False))
|
||||
|
||||
communities = communities.order_by(text('community.' + sort_by))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue