From 4a1c4e2d08ea91f159a421da8c6e5547e8241140 Mon Sep 17 00:00:00 2001
From: rimu <3310831+rimu@users.noreply.github.com>
Date: Mon, 11 Mar 2024 21:17:18 +1300
Subject: [PATCH 1/6] blocking tables inside tabs in user settings #91
---
app/templates/user/filters.html | 90 ++++++++++++++++++++++++++--
app/templates/user/show_profile.html | 6 +-
app/user/routes.py | 13 +++-
3 files changed, 101 insertions(+), 8 deletions(-)
diff --git a/app/templates/user/filters.html b/app/templates/user/filters.html
index b7e34f85..18a9a589 100644
--- a/app/templates/user/filters.html
+++ b/app/templates/user/filters.html
@@ -50,10 +50,92 @@
{% endif %}
Blocks
Manage what users, communities, domains or instances you want to block. Blocking them means you will no longer see any posts associated with them.
- Manage User Blocks
- Manage Communities Blocks
- Manage Domain Blocks
- Manage Instance Blocks
+
+
+
+ {% if blocked_users %}
+
+ {% else %}
+
{{ _('No blocked people') }}
+ {% endif %}
+
+
+ {% if blocked_communities %}
+
+ {% else %}
+
{{ _('No blocked communities') }}
+ {% endif %}
+
+
+ {% if blocked_domains %}
+
+ {% else %}
+
{{ _('No blocked domains') }}
+ {% endif %}
+
+
+ {% if blocked_instances %}
+
+ {% else %}
+
{{ _('No blocked instances') }}
+ {% endif %}
+
+
{% endblock %}
\ No newline at end of file
diff --git a/app/templates/user/show_profile.html b/app/templates/user/show_profile.html
index b39c2642..fc880048 100644
--- a/app/templates/user/show_profile.html
+++ b/app/templates/user/show_profile.html
@@ -49,11 +49,11 @@
{{ _('Send message using Matrix') }}
{% endif %}
{% if current_user.has_blocked_user(user.id) %}
- {{ _('Unblock user') }}
+ {{ _('Unblock') }}
{% else %}
- {{ _('Block user') }}
+ {{ _('Block') }}
{% endif %}
- {{ _('Report user') }}
+ {{ _('Report') }}
{% endif %}
{{ _('Joined') }}: {{ moment(user.created).fromNow(refresh=True) }}
diff --git a/app/user/routes.py b/app/user/routes.py
index 04c9af0b..78d0e774 100644
--- a/app/user/routes.py
+++ b/app/user/routes.py
@@ -11,7 +11,8 @@ from app.activitypub.util import default_context, find_actor_or_create
from app.community.util import save_icon_file, save_banner_file, retrieve_mods_and_backfill
from app.constants import SUBSCRIPTION_MEMBER, SUBSCRIPTION_PENDING
from app.models import Post, Community, CommunityMember, User, PostReply, PostVote, Notification, utcnow, File, Site, \
- Instance, Report, UserBlock, CommunityBan, CommunityJoinRequest, CommunityBlock, Filter
+ Instance, Report, UserBlock, CommunityBan, CommunityJoinRequest, CommunityBlock, Filter, Domain, DomainBlock, \
+ InstanceBlock
from app.user import bp
from app.user.forms import ProfileForm, SettingsForm, DeleteAccountForm, ReportUserForm, FilterEditForm
from app.user.utils import purge_user_then_delete
@@ -614,7 +615,17 @@ def import_settings_task(user_id, filename):
@login_required
def user_settings_filters():
filters = Filter.query.filter_by(user_id=current_user.id).order_by(Filter.title).all()
+ blocked_users = User.query.join(UserBlock, UserBlock.blocked_id == User.id).\
+ filter(UserBlock.blocker_id == current_user.id).order_by(User.user_name).all()
+ blocked_communities = Community.query.join(CommunityBlock, CommunityBlock.community_id == Community.id).\
+ filter(CommunityBlock.user_id == current_user.id).order_by(Community.title).all()
+ blocked_domains = Domain.query.join(DomainBlock, DomainBlock.domain_id == Domain.id).\
+ filter(DomainBlock.user_id == current_user.id).order_by(Domain.name).all()
+ blocked_instances = Instance.query.join(InstanceBlock, InstanceBlock.instance_id == Instance.id).\
+ filter(InstanceBlock.user_id == current_user.id).order_by(Instance.domain).all()
return render_template('user/filters.html', filters=filters, user=current_user,
+ blocked_users=blocked_users, blocked_communities=blocked_communities,
+ blocked_domains=blocked_domains, blocked_instances=blocked_instances,
moderating_communities=moderating_communities(current_user.get_id()),
joined_communities=joined_communities(current_user.get_id())
)
From 0f055f590d2036f11dcfd7460aa95e0383858b03 Mon Sep 17 00:00:00 2001
From: rimu <3310831+rimu@users.noreply.github.com>
Date: Tue, 12 Mar 2024 09:53:34 +1300
Subject: [PATCH 2/6] better image handling
---
app/activitypub/util.py | 5 ++++-
app/community/forms.py | 8 ++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/app/activitypub/util.py b/app/activitypub/util.py
index e3996ed5..683c35f7 100644
--- a/app/activitypub/util.py
+++ b/app/activitypub/util.py
@@ -1227,7 +1227,10 @@ def create_post(activity_log: ActivityPubLog, community: Community, request_json
post.url = request_json['object']['attachment'][0]['href']
if is_image_url(post.url):
post.type = POST_TYPE_IMAGE
- image = File(source_url=request_json['object']['image']['url'])
+ if 'image' in request_json['object'] and 'url' in request_json['object']['image']:
+ image = File(source_url=request_json['object']['image']['url'])
+ else:
+ image = File(source_url=post.url)
db.session.add(image)
post.image = image
else:
diff --git a/app/community/forms.py b/app/community/forms.py
index ee514ad6..4b287a2c 100644
--- a/app/community/forms.py
+++ b/app/community/forms.py
@@ -127,6 +127,14 @@ class ReportCommunityForm(FlaskForm):
report_remote = BooleanField('Also send report to originating instance')
submit = SubmitField(_l('Report'))
+ def reasons_to_string(self, reason_data) -> str:
+ result = []
+ for reason_id in reason_data:
+ for choice in self.reason_choices:
+ if choice[0] == reason_id:
+ result.append(str(choice[1]))
+ return ', '.join(result)
+
class DeleteCommunityForm(FlaskForm):
submit = SubmitField(_l('Delete community'))
From a20d706da3fe652e9246e2419690927e994aecbd Mon Sep 17 00:00:00 2001
From: rimu <3310831+rimu@users.noreply.github.com>
Date: Tue, 12 Mar 2024 19:33:26 +1300
Subject: [PATCH 3/6] rename cache route to avoid clash with caching mechanism
---
app/domain/routes.py | 4 ++--
app/templates/domain/domains.html | 10 +---------
app/templates/domain/domains_blocked.html | 2 +-
3 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/app/domain/routes.py b/app/domain/routes.py
index 54a74a38..84d5c055 100644
--- a/app/domain/routes.py
+++ b/app/domain/routes.py
@@ -8,7 +8,7 @@ from app import db, constants, cache
from app.inoculation import inoculation
from app.models import Post, Domain, Community, DomainBlock
from app.domain import bp
-from app.utils import get_setting, render_template, permission_required, joined_communities, moderating_communities, \
+from app.utils import render_template, permission_required, joined_communities, moderating_communities, \
user_filters_posts, blocked_domains
from sqlalchemy import desc
@@ -77,7 +77,7 @@ def domains():
@bp.route('/domains/banned', methods=['GET'])
@login_required
-def blocked_domains():
+def domains_blocked_list():
if not current_user.trustworthy():
abort(404)
diff --git a/app/templates/domain/domains.html b/app/templates/domain/domains.html
index e6fcd163..4eac8579 100644
--- a/app/templates/domain/domains.html
+++ b/app/templates/domain/domains.html
@@ -35,20 +35,12 @@
Domain |
- # Posts |
- {% if not current_user.is_anonymous %}{% if user_access('ban users', current_user.id) or user_access('manage users', current_user.id) %}Actions | {%endif%}{%endif%}
+ # Posts |
{% for domain in domains %}
{{ domain.name }} |
{{ domain.post_count }} |
- {% if not current_user.is_anonymous %}
- {% if user_access('ban users', current_user.id) or user_access('manage users', current_user.id) %}
-
- {{ _('Ban') }}
- |
- {% endif %}
- {% endif %}
{% endfor %}
diff --git a/app/templates/domain/domains_blocked.html b/app/templates/domain/domains_blocked.html
index 9bb9f1ca..460b203e 100644
--- a/app/templates/domain/domains_blocked.html
+++ b/app/templates/domain/domains_blocked.html
@@ -35,7 +35,7 @@
Domain |
- {% if user_access('ban users', current_user.id) or user_access('manage users', current_user.id) %}Actions | {%endif%}
+ {% if user_access('ban users', current_user.id) or user_access('manage users', current_user.id) %}Actions | {% endif %}
{% for domain in domains %}
From 5408c4b0608b8578c5a0121ce0a48b2f10fb9fc6 Mon Sep 17 00:00:00 2001
From: rimu <3310831+rimu@users.noreply.github.com>
Date: Tue, 12 Mar 2024 20:06:24 +1300
Subject: [PATCH 4/6] instance blocking
---
app/community/routes.py | 6 +++++-
app/domain/routes.py | 8 ++++++--
app/main/routes.py | 6 +++++-
app/post/routes.py | 7 +++++--
app/post/util.py | 12 +++++++++++-
app/topic/routes.py | 5 ++++-
app/utils.py | 8 +++++++-
7 files changed, 43 insertions(+), 9 deletions(-)
diff --git a/app/community/routes.py b/app/community/routes.py
index 9b9477d8..f9b58408 100644
--- a/app/community/routes.py
+++ b/app/community/routes.py
@@ -23,7 +23,7 @@ from app.community import bp
from app.utils import get_setting, render_template, allowlist_html, markdown_to_html, validation_required, \
shorten_string, gibberish, community_membership, ap_datetime, \
request_etag_matches, return_304, instance_banned, can_create_post, can_upvote, can_downvote, user_filters_posts, \
- joined_communities, moderating_communities, blocked_domains, mimetype_from_url
+ joined_communities, moderating_communities, blocked_domains, mimetype_from_url, blocked_instances
from feedgen.feed import FeedGenerator
from datetime import timezone, timedelta
@@ -152,9 +152,13 @@ def show_community(community: Community):
posts = posts.filter(Post.nsfw == False)
content_filters = user_filters_posts(current_user.id)
+ # filter domains and instances
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))
+ instance_ids = blocked_instances(current_user.id)
+ if instance_ids:
+ posts = posts.filter(or_(Post.instance_id.not_in(instance_ids), Post.instance_id == None))
if sort == '' or sort == 'hot':
posts = posts.order_by(desc(Post.ranking)).order_by(desc(Post.posted_at))
diff --git a/app/domain/routes.py b/app/domain/routes.py
index 84d5c055..2cd68e3e 100644
--- a/app/domain/routes.py
+++ b/app/domain/routes.py
@@ -9,8 +9,8 @@ from app.inoculation import inoculation
from app.models import Post, Domain, Community, DomainBlock
from app.domain import bp
from app.utils import render_template, permission_required, joined_communities, moderating_communities, \
- user_filters_posts, blocked_domains
-from sqlalchemy import desc
+ user_filters_posts, blocked_domains, blocked_instances
+from sqlalchemy import desc, or_
@bp.route('/d/', methods=['GET'])
@@ -31,6 +31,10 @@ def show_domain(domain_id):
else:
posts = Post.query.join(Community).filter(Post.domain_id == domain.id, Community.banned == False).order_by(desc(Post.posted_at))
+ instance_ids = blocked_instances(current_user.id)
+ if instance_ids:
+ posts = posts.filter(or_(Post.instance_id.not_in(instance_ids), Post.instance_id == None))
+
if current_user.is_authenticated:
content_filters = user_filters_posts(current_user.id)
else:
diff --git a/app/main/routes.py b/app/main/routes.py
index 9a2b3550..b2d292a0 100644
--- a/app/main/routes.py
+++ b/app/main/routes.py
@@ -23,7 +23,8 @@ from sqlalchemy import select, desc, text
from sqlalchemy_searchable import search
from app.utils import render_template, get_setting, gibberish, request_etag_matches, return_304, blocked_domains, \
ap_datetime, ip_address, retrieve_block_list, shorten_string, markdown_to_text, user_filters_home, \
- joined_communities, moderating_communities, parse_page, theme_list, get_request, markdown_to_html, allowlist_html
+ joined_communities, moderating_communities, parse_page, theme_list, get_request, markdown_to_html, allowlist_html, \
+ blocked_instances
from app.models import Community, CommunityMember, Post, Site, User, utcnow, Domain, Topic, File, Instance, \
InstanceRole, Notification
from PIL import Image
@@ -103,6 +104,9 @@ def home_page(type, sort):
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))
+ instance_ids = blocked_instances(current_user.id)
+ if instance_ids:
+ posts = posts.filter(or_(Post.instance_id.not_in(instance_ids), Post.instance_id == None))
content_filters = user_filters_home(current_user.id)
# Sorting
diff --git a/app/post/routes.py b/app/post/routes.py
index e418eb60..0c5ed613 100644
--- a/app/post/routes.py
+++ b/app/post/routes.py
@@ -7,7 +7,7 @@ from flask_login import login_user, logout_user, current_user, login_required
from flask_babel import _
from sqlalchemy import or_, desc
-from app import db, constants
+from app import db, constants, cache
from app.activitypub.signature import HttpSignature, post_request
from app.activitypub.util import default_context
from app.community.util import save_post, send_to_remote_instance
@@ -22,7 +22,8 @@ from app.post import bp
from app.utils import get_setting, render_template, allowlist_html, markdown_to_html, validation_required, \
shorten_string, markdown_to_text, gibberish, ap_datetime, return_304, \
request_etag_matches, ip_address, user_ip_banned, instance_banned, can_downvote, can_upvote, post_ranking, \
- reply_already_exists, reply_is_just_link_to_gif_reaction, confidence, moderating_communities, joined_communities
+ reply_already_exists, reply_is_just_link_to_gif_reaction, confidence, moderating_communities, joined_communities, \
+ blocked_instances, blocked_domains
def show_post(post_id: int):
@@ -848,6 +849,7 @@ def post_block_domain(post_id: int):
if not existing:
db.session.add(DomainBlock(user_id=current_user.id, domain_id=post.domain_id))
db.session.commit()
+ cache.delete_memoized(blocked_domains, current_user.id)
flash(_('Posts linking to %(name)s will be hidden.', name=post.domain.name))
return redirect(post.community.local_url())
@@ -860,6 +862,7 @@ def post_block_instance(post_id: int):
if not existing:
db.session.add(InstanceBlock(user_id=current_user.id, instance_id=post.instance_id))
db.session.commit()
+ cache.delete_memoized(blocked_instances, current_user.id)
flash(_('Content from %(name)s will be hidden.', name=post.instance.domain))
return redirect(post.community.local_url())
diff --git a/app/post/util.py b/app/post/util.py
index 1773c83b..948e3f1f 100644
--- a/app/post/util.py
+++ b/app/post/util.py
@@ -1,14 +1,20 @@
from typing import List
-from sqlalchemy import desc, text
+from flask_login import current_user
+from sqlalchemy import desc, text, or_
from app import db
from app.models import PostReply
+from app.utils import blocked_instances
# replies to a post, in a tree, sorted by a variety of methods
def post_replies(post_id: int, sort_by: str, show_first: int = 0) -> List[PostReply]:
comments = PostReply.query.filter_by(post_id=post_id)
+ if current_user.is_authenticated:
+ instance_ids = blocked_instances(current_user.id)
+ if instance_ids:
+ comments = comments.filter(or_(PostReply.instance_id.not_in(instance_ids), PostReply.instance_id == None))
if sort_by == 'hot':
comments = comments.order_by(desc(PostReply.ranking))
elif sort_by == 'top':
@@ -36,6 +42,10 @@ def get_comment_branch(post_id: int, comment_id: int, sort_by: str) -> List[Post
return []
comments = PostReply.query.filter(PostReply.post_id == post_id)
+ if current_user.is_authenticated:
+ instance_ids = blocked_instances(current_user.id)
+ if instance_ids:
+ comments = comments.filter(or_(PostReply.instance_id.not_in(instance_ids), PostReply.instance_id == None))
if sort_by == 'hot':
comments = comments.order_by(desc(PostReply.ranking))
elif sort_by == 'top':
diff --git a/app/topic/routes.py b/app/topic/routes.py
index db3ea61d..906ec7ee 100644
--- a/app/topic/routes.py
+++ b/app/topic/routes.py
@@ -16,7 +16,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, blocked_domains, validation_required, mimetype_from_url
+ community_membership, blocked_domains, validation_required, mimetype_from_url, blocked_instances
@bp.route('/topic/', methods=['GET'])
@@ -65,6 +65,9 @@ def show_topic(topic_path):
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))
+ instance_ids = blocked_instances(current_user.id)
+ if instance_ids:
+ posts = posts.filter(or_(Post.instance_id.not_in(instance_ids), Post.instance_id == None))
# sorting
if sort == '' or sort == 'hot':
diff --git a/app/utils.py b/app/utils.py
index 93cf3559..88b2ad6f 100644
--- a/app/utils.py
+++ b/app/utils.py
@@ -26,7 +26,7 @@ import re
from app.email import send_welcome_email
from app.models import Settings, Domain, Instance, BannedInstances, User, Community, DomainBlock, ActivityPubLog, IpBan, \
- Site, Post, PostReply, utcnow, Filter, CommunityMember
+ Site, Post, PostReply, utcnow, Filter, CommunityMember, InstanceBlock
# Flask's render_template function, with support for themes added
@@ -313,6 +313,12 @@ def blocked_domains(user_id) -> List[int]:
return [block.domain_id for block in blocks]
+@cache.memoize(timeout=86400)
+def blocked_instances(user_id) -> List[int]:
+ blocks = InstanceBlock.query.filter_by(user_id=user_id)
+ return [block.instance_id for block in blocks]
+
+
def retrieve_block_list():
try:
response = requests.get('https://raw.githubusercontent.com/rimu/no-qanon/master/domains.txt', timeout=1)
From 49db71e05d3e856d87d4be055ffb02ee8733adfd Mon Sep 17 00:00:00 2001
From: rimu <3310831+rimu@users.noreply.github.com>
Date: Tue, 12 Mar 2024 20:58:47 +1300
Subject: [PATCH 5/6] opt out of search
---
app/activitypub/util.py | 15 +++++++++++++--
app/community/util.py | 1 +
app/models.py | 2 +-
app/post/routes.py | 1 +
app/search/routes.py | 25 +++++++++++++++++--------
app/templates/base.html | 3 +++
app/templates/post/post.html | 4 ++--
app/user/forms.py | 2 +-
app/user/routes.py | 6 ++++++
9 files changed, 45 insertions(+), 14 deletions(-)
diff --git a/app/activitypub/util.py b/app/activitypub/util.py
index 683c35f7..425f5125 100644
--- a/app/activitypub/util.py
+++ b/app/activitypub/util.py
@@ -339,10 +339,19 @@ def refresh_user_profile_task(user_id):
if actor_data.status_code == 200:
activity_json = actor_data.json()
actor_data.close()
+
+ # update indexible state on their posts, if necessary
+ new_indexable = activity_json['indexable'] if 'indexable' in activity_json else True
+ if new_indexable != user.indexable:
+ db.session.execute(text('UPDATE "post" set indexable = :indexable WHERE user_id = :user_id'),
+ {'user_id': user.id,
+ 'indexable': new_indexable})
+
user.user_name = activity_json['preferredUsername']
user.about_html = parse_summary(activity_json)
user.ap_fetched_at = utcnow()
- user.public_key=activity_json['publicKey']['publicKeyPem']
+ user.public_key = activity_json['publicKey']['publicKeyPem']
+ user.indexable = new_indexable
avatar_changed = cover_changed = False
if 'icon' in activity_json:
@@ -594,6 +603,7 @@ def post_json_to_model(post_json, user, community) -> Post:
last_active=post_json['published'],
instance_id=user.instance_id
)
+ post.indexable = user.indexable
if 'source' in post_json and \
post_json['source']['mediaType'] == 'text/markdown':
post.body = post_json['source']['content']
@@ -1212,7 +1222,8 @@ def create_post(activity_log: ActivityPubLog, community: Community, request_json
type=constants.POST_TYPE_ARTICLE,
up_votes=1,
score=instance_weight(user.ap_domain),
- instance_id=user.instance_id
+ instance_id=user.instance_id,
+ indexable=user.indexable
)
# Get post content. Lemmy and Kbin put this in different places.
if 'source' in request_json['object'] and isinstance(request_json['object']['source'], dict) and request_json['object']['source']['mediaType'] == 'text/markdown': # Lemmy
diff --git a/app/community/util.py b/app/community/util.py
index 75132ded..f86e5811 100644
--- a/app/community/util.py
+++ b/app/community/util.py
@@ -164,6 +164,7 @@ def url_to_thumbnail_file(filename) -> File:
def save_post(form, post: Post):
+ post.indexable = current_user.indexable
post.nsfw = form.nsfw.data
post.nsfl = form.nsfl.data
post.notify_author = form.notify_author.data
diff --git a/app/models.py b/app/models.py
index c42f8a59..69449bd5 100644
--- a/app/models.py
+++ b/app/models.py
@@ -776,7 +776,7 @@ class Post(db.Model):
nsfl = db.Column(db.Boolean, default=False, index=True)
sticky = db.Column(db.Boolean, default=False)
notify_author = db.Column(db.Boolean, default=True)
- indexable = db.Column(db.Boolean, default=False)
+ indexable = db.Column(db.Boolean, default=True)
from_bot = db.Column(db.Boolean, default=False, index=True)
created_at = db.Column(db.DateTime, index=True, default=utcnow) # this is when the content arrived here
posted_at = db.Column(db.DateTime, index=True, default=utcnow) # this is when the original server created it
diff --git a/app/post/routes.py b/app/post/routes.py
index 0c5ed613..67472b84 100644
--- a/app/post/routes.py
+++ b/app/post/routes.py
@@ -216,6 +216,7 @@ def show_post(post_id: int):
canonical=post.ap_id, form=form, replies=replies, THREAD_CUTOFF_DEPTH=constants.THREAD_CUTOFF_DEPTH,
description=description, og_image=og_image, POST_TYPE_IMAGE=constants.POST_TYPE_IMAGE,
POST_TYPE_LINK=constants.POST_TYPE_LINK, POST_TYPE_ARTICLE=constants.POST_TYPE_ARTICLE,
+ noindex=not post.author.indexable,
etag=f"{post.id}{sort}_{hash(post.last_active)}", markdown_editor=current_user.is_authenticated and current_user.markdown_editor,
low_bandwidth=request.cookies.get('low_bandwidth', '0') == '1', SUBSCRIPTION_MEMBER=SUBSCRIPTION_MEMBER,
moderating_communities=moderating_communities(current_user.get_id()),
diff --git a/app/search/routes.py b/app/search/routes.py
index e4a96cf8..8edbcef7 100644
--- a/app/search/routes.py
+++ b/app/search/routes.py
@@ -5,11 +5,10 @@ from sqlalchemy import or_
from app.models import Post
from app.search import bp
-from app.utils import moderating_communities, joined_communities, render_template, blocked_domains
+from app.utils import moderating_communities, joined_communities, render_template, blocked_domains, blocked_instances
@bp.route('/search', methods=['GET', 'POST'])
-@login_required
def run_search():
if request.args.get('q') is not None:
q = request.args.get('q')
@@ -17,16 +16,26 @@ def run_search():
low_bandwidth = request.cookies.get('low_bandwidth', '0') == '1'
posts = Post.query.search(q)
- if current_user.ignore_bots:
+ if current_user.is_authenticated:
+ if current_user.ignore_bots:
+ posts = posts.filter(Post.from_bot == False)
+ if current_user.show_nsfl is False:
+ posts = posts.filter(Post.nsfl == False)
+ if current_user.show_nsfw is False:
+ posts = posts.filter(Post.nsfw == False)
+ 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))
+ instance_ids = blocked_instances(current_user.id)
+ if instance_ids:
+ posts = posts.filter(or_(Post.instance_id.not_in(instance_ids), Post.instance_id == None))
+ else:
posts = posts.filter(Post.from_bot == False)
- if current_user.show_nsfl is False:
posts = posts.filter(Post.nsfl == False)
- if current_user.show_nsfw is False:
posts = posts.filter(Post.nsfw == False)
- 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))
+ posts = posts.filter(Post.indexable == True)
+
posts = posts.paginate(page=page, per_page=100 if current_user.is_authenticated and not low_bandwidth else 50,
error_out=False)
diff --git a/app/templates/base.html b/app/templates/base.html
index 92c8e266..7e76319b 100644
--- a/app/templates/base.html
+++ b/app/templates/base.html
@@ -70,6 +70,9 @@
{% if rss_feed %}
{% endif %}
+ {% if noindex %}
+
+ {% endif %}