peertube blocklist

This commit is contained in:
rimu 2024-03-05 09:07:26 +13:00
parent 0e4e4ef00e
commit f2f9510dd4
2 changed files with 20 additions and 1 deletions

View file

@ -19,7 +19,7 @@ from app.auth.util import random_token
from app.email import send_verification_email, send_email
from app.models import Settings, BannedInstances, Interest, Role, User, RolePermission, Domain, ActivityPubLog, \
utcnow, Site, Instance, File, Notification, Post, CommunityMember
from app.utils import file_get_contents, retrieve_block_list, blocked_domains
from app.utils import file_get_contents, retrieve_block_list, blocked_domains, retrieve_peertube_block_list
def register(app):
@ -115,6 +115,12 @@ def register(app):
for domain in block_list.split('\n'):
db.session.add(Domain(name=domain.strip(), banned=True))
# Load peertube domain block list
block_list = retrieve_peertube_block_list()
if block_list:
for domain in block_list.split('\n'):
db.session.add(Domain(name=domain.strip(), banned=True))
# Initial roles
anon_role = Role(name='Anonymous user', weight=0)
anon_role.permissions.append(RolePermission(permission='register'))

View file

@ -319,6 +319,19 @@ def retrieve_block_list():
return response.text
def retrieve_peertube_block_list():
try:
response = requests.get('https://peertube_isolation.frama.io/list/peertube_isolation.json', timeout=1)
except:
return None
list = ''
if response and response.status_code == 200:
response_data = response.json()
for row in response_data['data']:
list += row['value'] + "\n"
return list.strip()
def ensure_directory_exists(directory):
parts = directory.split('/')
rebuild_directory = ''