mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-02 16:21:32 -08:00
Adding import, export for bans
This commit is contained in:
parent
a14a41c18e
commit
549abde9b3
3 changed files with 40 additions and 2 deletions
|
@ -57,6 +57,11 @@ class PreLoadCommunitiesForm(FlaskForm):
|
|||
pre_load_submit = SubmitField(_l('Add Communities'))
|
||||
|
||||
|
||||
class ImportExportBannedListsForm(FlaskForm):
|
||||
import_submit = SubmitField(_l('Import'))
|
||||
export_submit = SubmitField(_l('Export'))
|
||||
|
||||
|
||||
class EditCommunityForm(FlaskForm):
|
||||
title = StringField(_l('Title'), validators=[DataRequired()])
|
||||
url = StringField(_l('Url'), validators=[DataRequired()])
|
||||
|
|
|
@ -14,7 +14,11 @@ from app.activitypub.routes import process_inbox_request, process_delete_request
|
|||
from app.activitypub.signature import post_request, default_context
|
||||
from app.activitypub.util import instance_allowed, instance_blocked, extract_domain_and_actor
|
||||
from app.admin.forms import FederationForm, SiteMiscForm, SiteProfileForm, EditCommunityForm, EditUserForm, \
|
||||
<<<<<<< HEAD
|
||||
EditTopicForm, SendNewsletterForm, AddUserForm, PreLoadCommunitiesForm, EditInstanceForm
|
||||
=======
|
||||
EditTopicForm, SendNewsletterForm, AddUserForm, PreLoadCommunitiesForm, ImportExportBannedListsForm
|
||||
>>>>>>> bc26e9f (Adding import, export for bans)
|
||||
from app.admin.util import unsubscribe_from_everything_then_delete, unsubscribe_from_community, send_newsletter, \
|
||||
topics_for_form
|
||||
from app.community.util import save_icon_file, save_banner_file, search_for_community
|
||||
|
@ -191,6 +195,7 @@ def admin_misc():
|
|||
def admin_federation():
|
||||
form = FederationForm()
|
||||
preload_form = PreLoadCommunitiesForm()
|
||||
ban_lists_form = ImportExportBannedListsForm()
|
||||
site = Site.query.get(1)
|
||||
if site is None:
|
||||
site = Site()
|
||||
|
@ -308,6 +313,16 @@ def admin_federation():
|
|||
|
||||
return redirect(url_for('admin.admin_federation'))
|
||||
|
||||
# this is the import bans button
|
||||
elif ban_lists_form.import_submit.data and ban_lists_form.validate():
|
||||
flash(_('import button clicked'))
|
||||
return redirect(url_for('admin.admin_federation'))
|
||||
|
||||
# this is the export bans button
|
||||
elif ban_lists_form.export_submit.data and ban_lists_form.validate():
|
||||
flash(_('export button clicked'))
|
||||
return redirect(url_for('admin.admin_federation'))
|
||||
|
||||
# this is the main settings form
|
||||
elif form.validate_on_submit():
|
||||
if form.use_allowlist.data:
|
||||
|
@ -344,7 +359,8 @@ def admin_federation():
|
|||
form.blocked_actors.data = get_setting('actor_blocked_words', '88')
|
||||
|
||||
return render_template('admin/federation.html', title=_('Federation settings'),
|
||||
form=form, preload_form=preload_form, current_app_debug=current_app.debug,
|
||||
form=form, preload_form=preload_form, ban_lists_form=ban_lists_form,
|
||||
current_app_debug=current_app.debug,
|
||||
moderating_communities=moderating_communities(current_user.get_id()),
|
||||
joined_communities=joined_communities(current_user.get_id()),
|
||||
menu_topics=menu_topics(),
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
{% else %}
|
||||
{% extends "base.html" %}
|
||||
{% endif %} %}
|
||||
{% from 'bootstrap/form.html' import render_form %}
|
||||
{% from 'bootstrap/form.html' import render_form, render_field %}
|
||||
{% set active_child = 'admin_federation' %}
|
||||
|
||||
{% block app_content %}
|
||||
|
@ -15,6 +15,23 @@
|
|||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p>Import / Export Bans</p>
|
||||
<p>JSON format:</p>
|
||||
<pre><code>
|
||||
{
|
||||
"banned_instances": ["banned1.social", "banned2.social"],
|
||||
"banned_domains": ["banned3.social"],
|
||||
"banned_tags": ["badtag"],
|
||||
"banned_users": ["baduser@banned4.social"]
|
||||
}</code>
|
||||
</pre>
|
||||
{{ render_field(ban_lists_form.import_submit) }}
|
||||
{{ render_field(ban_lists_form.export_submit) }}
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="column">
|
||||
<p>Use this to "pre-load" known threadiverse communities, as ranked by posts and activity. The list of communities pulls from the same list as <a href="https://lemmyverse.net/communities">LemmyVerse</a>. NSFW communities and communities from banned instances are excluded.</p>
|
||||
|
|
Loading…
Add table
Reference in a new issue