allow under siege customization

pull/222/head
Aevann 2024-02-01 01:28:39 +02:00
parent 925e2ac4c3
commit 76866e2b07
9 changed files with 68 additions and 24 deletions

View File

@ -2331,6 +2331,12 @@ a.bg-light:hover, a.bg-light:focus, button.bg-light:hover, button.bg-light:focus
z-index: 1020;
}
}
.w-50 {
width: 50% !important;
}
.w-75 {
width: 75% !important;
}
.w-100 {
width: 100% !important;
}
@ -4712,6 +4718,12 @@ ul.comment-section {
.rounded-md {
border-radius: 0.35rem;
}
.w-md-25 {
width: 25% !important;
}
.w-md-100 {
width: 100% !important;
}
}
@media (min-width: 992px) {
.rounded-lg {

View File

@ -516,21 +516,16 @@ def execute_antispam_comment_check(body, v):
def execute_under_siege(v, target, body, kind):
if v.shadowbanned: return
if not get_setting("under_siege"): return
if v.admin_level >= PERMS['BYPASS_UNDER_SIEGE_MODE']: return
if SITE == 'watchpeopledie.tv' and kind == 'normal_comment':
thresholds = cache.get("under_siege_thresholds")
if not thresholds:
thresholds = DEFAULT_UNDER_SIEGE_THRESHOLDS
cache.set("under_siege_thresholds", thresholds)
if v.age > thresholds[kind] * 60:
return
if kind in {'message', 'report'} and SITE == 'rdrama.net':
threshold = 86400
elif kind != 'message' and SITE == 'watchpeopledie.tv':
threshold = 86400
else:
threshold = UNDER_SIEGE_AGE_THRESHOLD
if v.age > threshold: return
unshadowbannedcels = [x[0] for x in g.db.query(ModAction.target_user_id).filter_by(kind='unshadowban')]
if v.id in unshadowbannedcels: return

View File

@ -203,6 +203,7 @@ PERMS = { # Minimum admin_level to perform action.
'MODERATE_PENDING_SUBMITTED_ASSETS': 3,
'UPDATE_ASSETS': 3,
'DELETE_MEDIA': 3,
'CHANGE_UNDER_SIEGE': 3,
'PROGSTACK': 4,
'UNDO_AWARD_PINS': 4,
@ -533,7 +534,16 @@ PFP_DEFAULT_MARSEY = True
NEW_USER_AGE = 7 * 86400
NOTIFICATION_SPAM_AGE_THRESHOLD = 0
COMMENT_SPAM_LENGTH_THRESHOLD = 0
UNDER_SIEGE_AGE_THRESHOLD = 10 * 60
DEFAULT_UNDER_SIEGE_THRESHOLDS = {
"chat": 0,
"normal comment": 0,
"wall comment": 0,
"post": 0,
"report": 0,
"modmail": 0,
"message": 0,
}
HOLE_REQUIRED = False
HOLE_COST = 0

View File

@ -46,6 +46,11 @@ MODACTION_TYPES = {
"icon": 'fa-lock',
"color": 'bg-danger'
},
'change_under_siege': {
"str": 'changed under siege thresholds',
"icon": 'fa-shield',
"color": 'bg-muted'
},
'delete_media': {
"str": 'deleted media',
"icon": 'fa-trash-alt',
@ -91,11 +96,6 @@ MODACTION_TYPES = {
"icon": 'fa-shield',
"color": 'bg-muted'
},
'disable_under_siege': {
"str": 'disabled under siege mode',
"icon": 'fa-shield',
"color": 'bg-muted'
},
'disable_dm_media': {
"str": 'disabled DM media',
"icon": 'fa-images',
@ -166,11 +166,6 @@ MODACTION_TYPES = {
"icon": 'fa-shield',
"color": 'bg-success'
},
'enable_under_siege': {
"str": 'enabled under siege mode',
"icon": 'fa-shield',
"color": 'bg-success',
},
'enable_dm_media': {
"str": 'enabled DM media',
"icon": 'fa-images',
@ -442,6 +437,7 @@ MODACTION_PRIVILEGED_TYPES = {
'reset_password',
'schedule_orgy', 'remove_orgy',
'insert_transaction',
'change_under_siege_thresholds',
}
MODACTION_PRIVILEGED__TYPES = {'progstack_post', 'progstack_comment',
'unprogstack_post', 'unprogstack_comment'}

View File

@ -14,7 +14,6 @@ _SETTINGS = {
"fart_mode": False,
"read_only_mode": False,
"offline_mode": False,
"under_siege": False,
"dm_media": True,
}

View File

@ -306,7 +306,7 @@ def comment(v):
execute_blackjack(v, c, c.body, "comment")
kind = "normal_comment" if posting_to_post else "wall_comment"
kind = "normal comment" if posting_to_post else "wall comment"
execute_under_siege(v, c, c.body, kind)
if c.level == 1: c.top_comment_id = c.id

View File

@ -98,6 +98,9 @@
{% if v.admin_level >= PERMS['VIEW_ALT_VOTES'] %}
<li><a href="/admin/alt_votes">Alt Vote Analysis</a></li>
{% endif %}
{% if v.admin_level >= PERMS['CHANGE_UNDER_SIEGE'] %}
<li><a href="/admin/under_siege">Change Under Siege Thresholds</a></li>
{% endif %}
</ul>
{% if FEATURES['BADGES'] and v.admin_level >= PERMS['USER_BADGES'] -%}

View File

@ -0,0 +1,26 @@
{% extends "settings2.html" %}
{% block pagetitle %}Under Siege Thresholds{% endblock %}
{% block content %}
<section class="settings-section-section">
<h5>Thresholds in Minutes</h5>
<div class="settings-section rounded mt-4">
<form action="/admin/under_siege" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHR(this)">
<div class="body">
{% for name, value in thresholds.items() %}
<div class="d-flex">
<label for="{{name}}" class="mb-0 w-50 w-md-25">{{name.title()}}</label>
<input autocomplete="off" class="form-control mb-2 w-75 w-md-100" type="number" min="0" step="1" id="{{name}}" name="{{name}}" value="{{value}}" required>
</div>
{% endfor %}
</div>
<div class="footer">
<input hidden="" name="formkey" value="cc3a07ff710ab8f23f180ec47a877f6c">
<input hidden="" name="now" value="1706742172">
<div class="d-flex">
<input autocomplete="off" class="btn btn-primary ml-auto" type="submit" value="Submit">
</div>
</div>
</form>
</div>
</section>
{% endblock %}

View File

@ -0,0 +1,3 @@
delete from modactions where kind='enable_under_siege' or kind='disable_under_siege';
delete settings in file