mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
checking for use_allowlist in exports
This commit is contained in:
parent
49a9e3e692
commit
1cbb15a32b
1 changed files with 23 additions and 18 deletions
|
@ -332,23 +332,35 @@ def admin_federation():
|
||||||
import_file.save(final_place)
|
import_file.save(final_place)
|
||||||
|
|
||||||
# import bans in background task
|
# import bans in background task
|
||||||
import_bans(final_place)
|
if current_app.debug:
|
||||||
|
import_bans_task(final_place)
|
||||||
|
return redirect(url_for('admin.admin_federation'))
|
||||||
|
else:
|
||||||
|
import_bans_task.delay(final_place)
|
||||||
|
flash(_(f'Ban imports started in a background process.'))
|
||||||
|
return redirect(url_for('admin.admin_federation'))
|
||||||
|
|
||||||
flash(_(f'import file: {import_file}'))
|
|
||||||
return redirect(url_for('admin.admin_federation'))
|
|
||||||
|
|
||||||
# this is the export bans button
|
# this is the export bans button
|
||||||
elif ban_lists_form.export_submit.data and ban_lists_form.validate():
|
elif ban_lists_form.export_submit.data and ban_lists_form.validate():
|
||||||
# create the empty dict
|
# create the empty dict
|
||||||
ban_lists_dict = {}
|
ban_lists_dict = {}
|
||||||
|
|
||||||
# get banned_instances info
|
if get_setting('use_allowlist'):
|
||||||
banned_instances = []
|
# get the allowed_instances info
|
||||||
instance_bans = BannedInstances.query.all()
|
allowed_instances = []
|
||||||
if len(instance_bans) > 0:
|
already_allowed = AllowedInstances.query.all()
|
||||||
for bi in instance_bans:
|
if len(already_allowed) > 0:
|
||||||
banned_instances.append(bi.domain)
|
for aa in already_allowed:
|
||||||
ban_lists_dict['banned_instances'] = banned_instances
|
allowed_instances.append(aa.domain)
|
||||||
|
ban_lists_dict['allowed_instances'] = banned_instances
|
||||||
|
else:
|
||||||
|
# get banned_instances info
|
||||||
|
banned_instances = []
|
||||||
|
instance_bans = BannedInstances.query.all()
|
||||||
|
if len(instance_bans) > 0:
|
||||||
|
for bi in instance_bans:
|
||||||
|
banned_instances.append(bi.domain)
|
||||||
|
ban_lists_dict['banned_instances'] = banned_instances
|
||||||
|
|
||||||
# get banned_domains info
|
# get banned_domains info
|
||||||
banned_domains = []
|
banned_domains = []
|
||||||
|
@ -434,13 +446,6 @@ def admin_federation():
|
||||||
site=g.site
|
site=g.site
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def import_bans(filename):
|
|
||||||
if current_app.debug:
|
|
||||||
import_bans_task(filename)
|
|
||||||
else:
|
|
||||||
import_bans_task.delay(filename)
|
|
||||||
|
|
||||||
@celery.task
|
@celery.task
|
||||||
def import_bans_task(filename):
|
def import_bans_task(filename):
|
||||||
contents = file_get_contents(filename)
|
contents = file_get_contents(filename)
|
||||||
|
|
Loading…
Add table
Reference in a new issue