mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
peertube blocklist
This commit is contained in:
parent
0e4e4ef00e
commit
f2f9510dd4
2 changed files with 20 additions and 1 deletions
|
@ -19,7 +19,7 @@ from app.auth.util import random_token
|
||||||
from app.email import send_verification_email, send_email
|
from app.email import send_verification_email, send_email
|
||||||
from app.models import Settings, BannedInstances, Interest, Role, User, RolePermission, Domain, ActivityPubLog, \
|
from app.models import Settings, BannedInstances, Interest, Role, User, RolePermission, Domain, ActivityPubLog, \
|
||||||
utcnow, Site, Instance, File, Notification, Post, CommunityMember
|
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):
|
def register(app):
|
||||||
|
@ -115,6 +115,12 @@ def register(app):
|
||||||
for domain in block_list.split('\n'):
|
for domain in block_list.split('\n'):
|
||||||
db.session.add(Domain(name=domain.strip(), banned=True))
|
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
|
# Initial roles
|
||||||
anon_role = Role(name='Anonymous user', weight=0)
|
anon_role = Role(name='Anonymous user', weight=0)
|
||||||
anon_role.permissions.append(RolePermission(permission='register'))
|
anon_role.permissions.append(RolePermission(permission='register'))
|
||||||
|
|
13
app/utils.py
13
app/utils.py
|
@ -319,6 +319,19 @@ def retrieve_block_list():
|
||||||
return response.text
|
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):
|
def ensure_directory_exists(directory):
|
||||||
parts = directory.split('/')
|
parts = directory.split('/')
|
||||||
rebuild_directory = ''
|
rebuild_directory = ''
|
||||||
|
|
Loading…
Add table
Reference in a new issue