From 6c46de47de75e127b8d212841a2cf02b917c9f03 Mon Sep 17 00:00:00 2001 From: Aevann Date: Tue, 26 Sep 2023 23:45:16 +0300 Subject: [PATCH] try smth on devrama to fix chat refreshing --- files/helpers/cron.py | 4 ++-- files/routes/admin.py | 5 +++-- files/routes/allroutes.py | 4 ++-- nginx.conf | 6 ------ 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/files/helpers/cron.py b/files/helpers/cron.py index a0456cfed..e4fe16433 100644 --- a/files/helpers/cron.py +++ b/files/helpers/cron.py @@ -185,7 +185,7 @@ def _create_and_delete_orgy(): del g.db stdout.flush() - requests.post(f'{SITE_FULL}/refresh_chat') + requests.post('http://localhost:5001/refresh_chat') video_info = ffmpeg.probe(f'/orgies/{get_file()}') seconds = int(video_info['streams'][0]['duration']) @@ -195,7 +195,7 @@ def _create_and_delete_orgy(): if orgy: g.db.delete(orgy) g.db.commit() - requests.post(f'{SITE_FULL}/refresh_chat') + requests.post('http://localhost:5001/refresh_chat') def _delete_all_posts(): posts = g.db.query(Post).filter_by(author_id=AUTOJANNY_ID, deleted_utc=0).all() diff --git a/files/routes/admin.py b/files/routes/admin.py index 42760f753..3dce3349c 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -1979,7 +1979,8 @@ def start_orgy(v): g.db.add(orgy) g.db.commit() - requests.post(f'{SITE_FULL}/refresh_chat') + x = requests.post('http://localhost:5001/refresh_chat') + print(x.text, flush=True) return redirect('/chat') @@ -1987,5 +1988,5 @@ def start_orgy(v): @admin_level_required(PERMS['ORGIES']) def stop_orgy(v): g.db.query(Orgy).delete() - requests.post(f'{SITE_FULL}/refresh_chat') + requests.post('http://localhost:5001/refresh_chat') return {"message": "Orgy stopped successfully!"} diff --git a/files/routes/allroutes.py b/files/routes/allroutes.py index af212e6e4..059e66487 100644 --- a/files/routes/allroutes.py +++ b/files/routes/allroutes.py @@ -11,7 +11,7 @@ from files.__main__ import app, limiter, get_CF, redis_instance def before_request(): g.v = None - if request.host != SITE: + if request.host != SITE and request.path != '/refresh_chat': abort(403, "Unauthorized host provided!") if SITE == 'marsey.world' and request.path != '/kofi': @@ -21,7 +21,7 @@ def before_request(): abort(403, "Cloudflare workers are not allowed to access this website!") g.agent = request.headers.get("User-Agent", "") - if not g.agent and request.path != '/kofi': + if not g.agent and request.path not in {'/kofi', '/refresh_chat'}: abort(403, 'Please use a "User-Agent" header!') if not get_setting('bots') and request.headers.get("Authorization"): diff --git a/nginx.conf b/nginx.conf index 659aa46d7..e205bad78 100644 --- a/nginx.conf +++ b/nginx.conf @@ -24,12 +24,6 @@ server { proxy_pass http://localhost:5001/chat; include includes/headers; } - location /refresh_chat { - allow 127.0.0.1; - deny all; - proxy_pass http://localhost:5001/refresh_chat; - include includes/headers; - } location /reply { proxy_pass http://localhost:5001/reply; include includes/headers;