also apply domain filter to topics

This commit is contained in:
rimu 2024-02-05 07:36:48 +13:00
parent f6a382d0a7
commit 7f66e4b722

View file

@ -4,7 +4,7 @@ from random import randint
from flask import request, flash, json, url_for, current_app, redirect, abort
from flask_login import login_required, current_user
from flask_babel import _
from sqlalchemy import text, desc
from sqlalchemy import text, desc, or_
from app.activitypub.signature import post_request
from app.constants import SUBSCRIPTION_NONMEMBER, POST_TYPE_IMAGE, POST_TYPE_LINK
@ -14,7 +14,7 @@ from app.topic import bp
from app import db, celery, cache
from app.topic.forms import ChooseTopicsForm
from app.utils import render_template, user_filters_posts, moderating_communities, joined_communities, \
community_membership
community_membership, blocked_domains
@bp.route('/topic/<topic_name>', methods=['GET'])
@ -45,6 +45,10 @@ def show_topic(topic_name):
posts = posts.filter(Post.nsfw == False)
content_filters = user_filters_posts(current_user.id)
domains_ids = blocked_domains(current_user.id)
if domains_ids:
posts = posts.filter(or_(Post.domain_id.not_in(domains_ids), Post.domain_id == None))
# sorting
if sort == '' or sort == 'hot':
posts = posts.order_by(desc(Post.ranking))