mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-03 00:31:25 -08:00
block nsfw community adding if nsfw is disabled
This commit is contained in:
parent
3d11dcf62e
commit
14d0344702
3 changed files with 18 additions and 4 deletions
|
@ -382,6 +382,14 @@ def actor_json_to_model(activity_json, address, server):
|
||||||
mods_url = activity_json['moderators']
|
mods_url = activity_json['moderators']
|
||||||
else:
|
else:
|
||||||
mods_url = None
|
mods_url = None
|
||||||
|
|
||||||
|
# only allow nsfw communities if enabled for this instance
|
||||||
|
site = Site.query.get(1) # can't use g.site because actor_json_to_model can be called from celery
|
||||||
|
if activity_json['sensitive'] and not site.enable_nsfw:
|
||||||
|
return None
|
||||||
|
if 'nsfl' in activity_json and activity_json['nsfl'] and not site.enable_nsfl:
|
||||||
|
return None
|
||||||
|
|
||||||
community = Community(name=activity_json['preferredUsername'],
|
community = Community(name=activity_json['preferredUsername'],
|
||||||
title=activity_json['name'],
|
title=activity_json['name'],
|
||||||
description=activity_json['summary'] if 'summary' in activity_json else '',
|
description=activity_json['summary'] if 'summary' in activity_json else '',
|
||||||
|
|
|
@ -90,6 +90,11 @@ def add_remote():
|
||||||
message = Markup(
|
message = Markup(
|
||||||
'Type address in the format !community@server.name. Search on <a href="https://lemmyverse.net/communities">Lemmyverse.net</a> to find some.')
|
'Type address in the format !community@server.name. Search on <a href="https://lemmyverse.net/communities">Lemmyverse.net</a> to find some.')
|
||||||
flash(message, 'error')
|
flash(message, 'error')
|
||||||
|
if new_community is None:
|
||||||
|
if g.site.enable_nsfw:
|
||||||
|
flash(_('Community not found.'), 'warning')
|
||||||
|
else:
|
||||||
|
flash(_('Community not found. If you are searching for a nsfw community it is blocked by this instance.'), 'warning')
|
||||||
|
|
||||||
return render_template('community/add_remote.html',
|
return render_template('community/add_remote.html',
|
||||||
title=_('Add remote community'), form=form, new_community=new_community,
|
title=_('Add remote community'), form=form, new_community=new_community,
|
||||||
|
|
|
@ -54,10 +54,11 @@ def search_for_community(address: str):
|
||||||
community_data.close()
|
community_data.close()
|
||||||
if community_json['type'] == 'Group':
|
if community_json['type'] == 'Group':
|
||||||
community = actor_json_to_model(community_json, name, server)
|
community = actor_json_to_model(community_json, name, server)
|
||||||
if current_app.debug:
|
if community:
|
||||||
retrieve_mods_and_backfill(community.id)
|
if current_app.debug:
|
||||||
else:
|
retrieve_mods_and_backfill(community.id)
|
||||||
retrieve_mods_and_backfill.delay(community.id)
|
else:
|
||||||
|
retrieve_mods_and_backfill.delay(community.id)
|
||||||
return community
|
return community
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue