diff --git a/files/helpers/actions.py b/files/helpers/actions.py
index 9453d9a65..6f3dad05e 100644
--- a/files/helpers/actions.py
+++ b/files/helpers/actions.py
@@ -12,8 +12,10 @@ from files.classes.notifications import Notification
from files.helpers.alerts import send_repeatable_notification
from files.helpers.const import *
from files.helpers.const_stateful import *
+from files.helpers.discord import discord_message_send
from files.helpers.get import *
from files.helpers.sanitize import *
+from files.helpers.settings import get_setting
from files.helpers.slots import check_slots_command
@@ -38,7 +40,6 @@ def archive_url(url):
url = url.replace('https://instagram.com/', 'https://imginn.com/')
gevent.spawn(_archiveorg, url)
-
def execute_snappy(post, v):
snappy = get_account(SNAPPY_ID)
@@ -360,18 +361,6 @@ def execute_antispam_submission_check(title, v, url):
return True
def execute_blackjack_custom(v, target, body, type):
- if v.age < (10 * 60):
- v.shadowbanned = 'AutoJanny'
- if not v.is_banned: v.ban_reason = f"Under Siege"
- v.is_muted = True
- g.db.add(v)
- with open(f"/under_siege.log", "a", encoding="utf-8") as f:
- t = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(time.time()))
- f.write(f"[{t}] {v.id} @{v.username} {type} {v.age}s\n")
- from files.helpers.discord import discord_message_send
- discord_message_send("1041917843094110239",
- f"<{SITE_FULL}/id/{v.id}> `@{v.username} {type} {v.age}s`")
- return False
return True
def execute_blackjack(v, target, body, type):
@@ -458,6 +447,21 @@ def execute_antispam_comment_check(body:str, v:User):
g.db.commit()
abort(403, "Too much spam!")
+def execute_under_siege(v:User, target:Optional[Union[Submission, Comment]], body, type:str):
+ if not get_setting("under_siege"): return True
+ if v.age < UNDER_SIEGE_AGE_THRESHOLD and not v.admin_level >= PERMS['SITE_BYPASS_UNDER_SIEGE_MODE']:
+ v.shadowbanned = 'AutoJanny'
+ if not v.is_banned: v.ban_reason = f"Under Siege"
+ v.is_muted = True
+ g.db.add(v)
+ with open(f"/under_siege.log", "a", encoding="utf-8") as f:
+ t = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(time.time()))
+ f.write(f"[{t}] {v.id} @{v.username} {type} {v.age}s\n")
+ discord_message_send(UNDER_SIEGE_CHANNEL_ID,
+ f"<{SITE_FULL}/id/{v.id}> `@{v.username} {type} {v.age}s`")
+ return False
+ return True
+
def execute_lawlz_actions(v:User, p:Submission):
if v.id != LAWLZ_ID: return
if SITE_NAME != 'rDrama': return
diff --git a/files/helpers/const.py b/files/helpers/const.py
index 98d97dad4..242bdb3e1 100644
--- a/files/helpers/const.py
+++ b/files/helpers/const.py
@@ -199,6 +199,7 @@ AGENDAPOSTER_MSG_HTML = """
Hi ")
@admin_level_required(PERMS['SITE_SETTINGS'])
def change_settings(v, setting):
+ if setting not in get_settings().keys():
+ abort(404, f"Setting '{setting}' not found")
val = toggle_setting(setting)
if val: word = 'enable'
else: word = 'disable'
@@ -463,7 +465,7 @@ def change_settings(v, setting):
user_id=v.id,
)
g.db.add(ma)
- return {'message': f"{setting} {word}d successfully!"}
+ return {'message': f"{setting.replace('_', ' ').title()} {word}d successfully!"}
@app.post("/admin/clear_cloudflare_cache")
@admin_level_required(PERMS['SITE_CACHE_PURGE_CDN'])
diff --git a/files/routes/comments.py b/files/routes/comments.py
index 108fed507..72faa75fe 100644
--- a/files/routes/comments.py
+++ b/files/routes/comments.py
@@ -239,6 +239,7 @@ def comment(v):
g.db.flush()
execute_blackjack(v, c, c.body, "comment")
+ execute_under_siege(v, c, c.body, "comment")
if c.level == 1: c.top_comment_id = c.id
else: c.top_comment_id = parent.top_comment_id
@@ -444,6 +445,7 @@ def edit_comment(cid, v):
c.body_html = body_html
execute_blackjack(v, c, c.body, "comment")
+ execute_under_siege(v, c, c.body, "comment")
if c.post.id not in ADMIGGER_THREADS and v.agendaposter and not v.marseyawarded and AGENDAPOSTER_PHRASE not in c.body.lower() and c.post.sub != 'chudrama':
abort(403, f'You have to include "{AGENDAPOSTER_PHRASE}" in your comment!')
diff --git a/files/routes/posts.py b/files/routes/posts.py
index ded73cdff..661f6a284 100644
--- a/files/routes/posts.py
+++ b/files/routes/posts.py
@@ -392,7 +392,9 @@ def edit_post(pid, v):
p.body = body
- for text in {p.body, p.title, p.url}:
+ execute_under_siege(v, p, p.body, 'submission')
+
+ for text in [p.body, p.title, p.url]:
if not execute_blackjack(v, p, text, 'submission'): break
if len(body_html) > POST_BODY_HTML_LENGTH_LIMIT:
diff --git a/files/routes/reporting.py b/files/routes/reporting.py
index 865bd2476..d27aeb7d6 100644
--- a/files/routes/reporting.py
+++ b/files/routes/reporting.py
@@ -18,6 +18,7 @@ from files.__main__ import app, limiter, cache
def flag_post(pid, v):
post = get_post(pid)
reason = request.values.get("reason", "").strip()
+ execute_under_siege(v, post, reason, 'flag')
execute_blackjack(v, post, reason, 'flag')
if v.is_muted: abort(403, "You are forbidden from making reports.")
reason = reason[:100]
@@ -76,6 +77,7 @@ def flag_comment(cid, v):
if existing: abort(409, "You already reported this comment!")
reason = request.values.get("reason", "").strip()
+ execute_under_siege(v, comment, reason, 'flag')
execute_blackjack(v, comment, reason, 'flag')
reason = reason[:100]
reason = filter_emojis_only(reason)
diff --git a/files/routes/static.py b/files/routes/static.py
index fe8aa57d5..c15624676 100644
--- a/files/routes/static.py
+++ b/files/routes/static.py
@@ -231,6 +231,7 @@ def submit_contact(v):
g.db.add(new_comment)
g.db.flush()
execute_blackjack(v, new_comment, new_comment.body_html, 'modmail')
+ execute_under_siege(v, new_comment, new_comment.body_html, 'modmail')
new_comment.top_comment_id = new_comment.id
admins = g.db.query(User).filter(User.admin_level >= PERMS['NOTIFICATIONS_MODMAIL'], User.id != AEVANN_ID)
diff --git a/files/routes/users.py b/files/routes/users.py
index 0f26bde2d..f20f83dd6 100644
--- a/files/routes/users.py
+++ b/files/routes/users.py
@@ -13,7 +13,7 @@ from files.classes import *
from files.classes.leaderboard import Leaderboard
from files.classes.transactions import *
from files.classes.views import *
-from files.helpers.actions import execute_blackjack
+from files.helpers.actions import execute_blackjack, execute_under_siege
from files.helpers.alerts import *
from files.helpers.const import *
from files.helpers.mail import *
@@ -461,6 +461,7 @@ def message2(v, username):
g.db.add(c)
g.db.flush()
execute_blackjack(v, c, c.body_html, 'message')
+ execute_under_siege(v, c, c.body_html, 'message')
c.top_comment_id = c.id
if user.id not in bots:
@@ -536,6 +537,7 @@ def messagereply(v):
g.db.add(c)
g.db.flush()
execute_blackjack(v, c, c.body_html, 'message')
+ execute_under_siege(v, c, c.body_html, 'message')
if user_id and user_id not in (v.id, 2, bots):
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=user_id).one_or_none()
diff --git a/ubuntu_setup.sh b/ubuntu_setup.sh
index 25ddaea3a..3595d685c 100644
--- a/ubuntu_setup.sh
+++ b/ubuntu_setup.sh
@@ -80,7 +80,6 @@ echo "psql -U postgres" > /p
echo "tmux -S /tmp/s a -t 0" > /c
echo "tmux -S /tmp/s a -t 1" > /c2
echo "cd /rDrama && git pull" > /g
-echo '{"Bots": true, "Fart mode": false, "Read-only mode": false, "Signups": true, "login_required": false}' > /site_settings.json
cd ./chat
yarn install