mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
find spammy content more easily
This commit is contained in:
parent
ba3dba8f57
commit
1e256e5d8f
3 changed files with 74 additions and 1 deletions
|
@ -18,7 +18,7 @@ from app.admin.util import unsubscribe_from_everything_then_delete, unsubscribe_
|
|||
from app.community.util import save_icon_file, save_banner_file
|
||||
from app.constants import REPORT_STATE_NEW, REPORT_STATE_ESCALATED
|
||||
from app.models import AllowedInstances, BannedInstances, ActivityPubLog, utcnow, Site, Community, CommunityMember, \
|
||||
User, Instance, File, Report, Topic, UserRegistration, Role, Post
|
||||
User, Instance, File, Report, Topic, UserRegistration, Role, Post, PostReply
|
||||
from app.utils import render_template, permission_required, set_setting, get_setting, gibberish, markdown_to_html, \
|
||||
moderating_communities, joined_communities, finalize_user_setup, theme_list, blocked_phrases, blocked_referrers, \
|
||||
topic_tree
|
||||
|
@ -512,6 +512,41 @@ def admin_content_trash():
|
|||
)
|
||||
|
||||
|
||||
@bp.route('/content/spam', methods=['GET'])
|
||||
@login_required
|
||||
@permission_required('administer all users')
|
||||
def admin_content_spam():
|
||||
# Essentially the same as admin_content_trash() except only shows heavily downvoted posts by new users - who are usually spammers
|
||||
page = request.args.get('page', 1, type=int)
|
||||
replies_page = request.args.get('replies_page', 1, type=int)
|
||||
|
||||
posts = Post.query.join(User, User.id == Post.user_id).\
|
||||
filter(User.created > utcnow() - timedelta(days=3)).\
|
||||
filter(Post.posted_at > utcnow() - timedelta(days=3)).\
|
||||
filter(Post.score <= 0).order_by(Post.score)
|
||||
posts = posts.paginate(page=page, per_page=100, error_out=False)
|
||||
|
||||
post_replies = PostReply.query.join(User, User.id == PostReply.user_id). \
|
||||
filter(User.created > utcnow() - timedelta(days=3)). \
|
||||
filter(PostReply.posted_at > utcnow() - timedelta(days=3)). \
|
||||
filter(PostReply.score <= 0).order_by(PostReply.score)
|
||||
post_replies = post_replies.paginate(page=replies_page, per_page=100, error_out=False)
|
||||
|
||||
next_url = url_for('admin.admin_content_spam', page=posts.next_num) if posts.has_next else None
|
||||
prev_url = url_for('admin.admin_content_spam', page=posts.prev_num) if posts.has_prev and page != 1 else None
|
||||
next_url_replies = url_for('admin.admin_content_spam', replies_page=post_replies.next_num) if post_replies.has_next else None
|
||||
prev_url_replies = url_for('admin.admin_content_spam', replies_page=post_replies.prev_num) if post_replies.has_prev and replies_page != 1 else None
|
||||
|
||||
return render_template('admin/spam_posts.html', title=_('Likely spam'),
|
||||
next_url=next_url, prev_url=prev_url,
|
||||
next_url_replies=next_url_replies, prev_url_replies=prev_url_replies,
|
||||
posts=posts, post_replies=post_replies,
|
||||
moderating_communities=moderating_communities(current_user.get_id()),
|
||||
joined_communities=joined_communities(current_user.get_id()),
|
||||
site=g.site
|
||||
)
|
||||
|
||||
|
||||
@bp.route('/approve_registrations', methods=['GET'])
|
||||
@login_required
|
||||
@permission_required('approve registrations')
|
||||
|
|
37
app/templates/admin/spam_posts.html
Normal file
37
app/templates/admin/spam_posts.html
Normal file
|
@ -0,0 +1,37 @@
|
|||
{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %}
|
||||
{% extends 'themes/' + theme() + '/base.html' %}
|
||||
{% else %}
|
||||
{% extends "base.html" %}
|
||||
{% endif %} %}
|
||||
{% from 'bootstrap/form.html' import render_form %}
|
||||
{% set active_child = 'admin_content_spam' %}
|
||||
|
||||
{% block app_content %}
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h1>{{ _('Most downvoted posts in the last 3 days') }}</h1>
|
||||
<div class="post_list">
|
||||
{% for post in posts.items %}
|
||||
{% include 'post/_post_teaser.html' %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% if post_replies %}
|
||||
<h2 class="mt-4" id="comments">Downvoted comments</h2>
|
||||
<div class="post_list">
|
||||
{% for post_reply in post_replies.items %}
|
||||
{% include 'post/_post_reply_teaser.html' %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p>{{ _('No comments yet.') }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
{% include 'admin/_nav.html' %}
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
{% endblock %}
|
|
@ -195,6 +195,7 @@
|
|||
<li><a class="dropdown-item{{ ' active' if active_child == 'admin_users' }}" href="{{ url_for('admin.admin_users', local_remote='local') }}">{{ _('Users') }}</a></li>
|
||||
<li><a class="dropdown-item{{ ' active' if active_child == 'admin_users_trash' }}" href="{{ url_for('admin.admin_users_trash', local_remote='local') }}">{{ _('Monitoring - users') }}</a></li>
|
||||
<li><a class="dropdown-item{{ ' active' if active_child == 'admin_content_trash' }}" href="{{ url_for('admin.admin_content_trash') }}">{{ _('Monitoring - content') }}</a></li>
|
||||
<li><a class="dropdown-item{{ ' active' if active_child == 'admin_content_spam' }}" href="{{ url_for('admin.admin_content_spam') }}">{{ _('Monitoring - spammy content') }}</a></li>
|
||||
{% if g.site.registration_mode == 'RequireApplication' %}
|
||||
<li><a class="dropdown-item{{ ' active' if active_child == 'admin_approve_registrations' }}" href="{{ url_for('admin.admin_approve_registrations') }}">{{ _('Registration applications') }}</a></li>
|
||||
{% endif %}
|
||||
|
|
Loading…
Add table
Reference in a new issue