user ban and also fix global hole mod a bit i hope i didn't screw up the templates
parent
591e6342bb
commit
d5a48871f8
|
@ -285,7 +285,7 @@ class User(Base):
|
||||||
@lazy
|
@lazy
|
||||||
def mods(self, sub):
|
def mods(self, sub):
|
||||||
if self.is_suspended_permanently or self.shadowbanned: return False
|
if self.is_suspended_permanently or self.shadowbanned: return False
|
||||||
return self.admin_level > 2 or bool(g.db.query(Mod.user_id).filter_by(user_id=self.id, sub=sub).one_or_none())
|
return self.admin_level >= PERMS['GLOBAL_MODERATION'] or bool(g.db.query(Mod.user_id).filter_by(user_id=self.id, sub=sub).one_or_none())
|
||||||
|
|
||||||
@lazy
|
@lazy
|
||||||
def exiled_from(self, sub):
|
def exiled_from(self, sub):
|
||||||
|
|
|
@ -130,6 +130,7 @@ PERMS = { # Minimum admin_level to perform action.
|
||||||
'POST_COMMENT_MODERATION': 2,
|
'POST_COMMENT_MODERATION': 2,
|
||||||
'GLOBAL_HOLE_MODERATION': 3,
|
'GLOBAL_HOLE_MODERATION': 3,
|
||||||
'POST_EDITING': 3,
|
'POST_EDITING': 3,
|
||||||
|
'USER_BAN': 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
FEATURES = {
|
FEATURES = {
|
||||||
|
|
|
@ -988,7 +988,7 @@ def admin_title_change(user_id, v):
|
||||||
|
|
||||||
@app.post("/ban_user/<user_id>")
|
@app.post("/ban_user/<user_id>")
|
||||||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||||
@admin_level_required(2)
|
@admin_level_required(PERMS['USER_BAN'])
|
||||||
def ban_user(user_id, v):
|
def ban_user(user_id, v):
|
||||||
user = get_account(user_id)
|
user = get_account(user_id)
|
||||||
|
|
||||||
|
@ -1051,7 +1051,7 @@ def ban_user(user_id, v):
|
||||||
|
|
||||||
@app.post("/unban_user/<user_id>")
|
@app.post("/unban_user/<user_id>")
|
||||||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||||
@admin_level_required(2)
|
@admin_level_required(PERMS['USER_BAN'])
|
||||||
def unban_user(user_id, v):
|
def unban_user(user_id, v):
|
||||||
user = get_account(user_id)
|
user = get_account(user_id)
|
||||||
if not user.is_banned:
|
if not user.is_banned:
|
||||||
|
@ -1082,7 +1082,7 @@ def unban_user(user_id, v):
|
||||||
|
|
||||||
@app.post("/mute_user/<int:user_id>/<int:mute_status>")
|
@app.post("/mute_user/<int:user_id>/<int:mute_status>")
|
||||||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||||
@admin_level_required(2)
|
@admin_level_required(PERMS['USER_BAN'])
|
||||||
def mute_user(v, user_id, mute_status):
|
def mute_user(v, user_id, mute_status):
|
||||||
user = get_account(user_id)
|
user = get_account(user_id)
|
||||||
|
|
||||||
|
@ -1442,7 +1442,7 @@ def admin_toggle_ban_domain(v):
|
||||||
|
|
||||||
@app.post("/admin/nuke_user")
|
@app.post("/admin/nuke_user")
|
||||||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||||
@admin_level_required(2)
|
@admin_level_required(PERMS['POST_COMMENT_MODERATION'])
|
||||||
def admin_nuke_user(v):
|
def admin_nuke_user(v):
|
||||||
|
|
||||||
user=get_user(request.values.get("user"))
|
user=get_user(request.values.get("user"))
|
||||||
|
@ -1475,7 +1475,7 @@ def admin_nuke_user(v):
|
||||||
|
|
||||||
@app.post("/admin/unnuke_user")
|
@app.post("/admin/unnuke_user")
|
||||||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||||
@admin_level_required(2)
|
@admin_level_required(PERMS['POST_COMMENT_MODERATION'])
|
||||||
def admin_nunuke_user(v):
|
def admin_nunuke_user(v):
|
||||||
|
|
||||||
user=get_user(request.values.get("user"))
|
user=get_user(request.values.get("user"))
|
||||||
|
|
|
@ -212,7 +212,7 @@ def award_thing(v, thing_type, id):
|
||||||
author.unban_utc += 86400
|
author.unban_utc += 86400
|
||||||
send_repeatable_notification(author.id, f"Your account has been banned for **yet another day** for {link}. Seriously man?")
|
send_repeatable_notification(author.id, f"Your account has been banned for **yet another day** for {link}. Seriously man?")
|
||||||
|
|
||||||
if v.admin_level > 2:
|
if v.admin_level >= PERMS['USER_BAN']:
|
||||||
log_link = f'/{thing_type}/{thing.id}'
|
log_link = f'/{thing_type}/{thing.id}'
|
||||||
reason = f'<a href="{log_link}">{log_link}</a>'
|
reason = f'<a href="{log_link}">{log_link}</a>'
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ def award_thing(v, thing_type, id):
|
||||||
author.ban_reason = None
|
author.ban_reason = None
|
||||||
send_repeatable_notification(author.id, "You have been unbanned!")
|
send_repeatable_notification(author.id, "You have been unbanned!")
|
||||||
|
|
||||||
if v.admin_level > 2:
|
if v.admin_level >= PERMS['USER_BAN']:
|
||||||
ma=ModAction(
|
ma=ModAction(
|
||||||
kind="unban_user",
|
kind="unban_user",
|
||||||
user_id=v.id,
|
user_id=v.id,
|
||||||
|
|
|
@ -127,7 +127,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
|
||||||
|
|
||||||
if request.headers.get("Authorization"): return top_comment.json
|
if request.headers.get("Authorization"): return top_comment.json
|
||||||
else:
|
else:
|
||||||
if post.is_banned and not (v and (v.admin_level > 1 or post.author_id == v.id)): template = "submission_banned.html"
|
if post.is_banned and not (v and (v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or post.author_id == v.id)): template = "submission_banned.html"
|
||||||
else: template = "submission.html"
|
else: template = "submission.html"
|
||||||
return render_template(template, v=v, p=post, sort=sort, comment_info=comment_info, render_replies=True, sub=post.subr)
|
return render_template(template, v=v, p=post, sort=sort, comment_info=comment_info, render_replies=True, sub=post.subr)
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ def comment(v):
|
||||||
).first()
|
).first()
|
||||||
if existing: return {"error": f"You already made that comment: /comment/{existing.id}"}, 409
|
if existing: return {"error": f"You already made that comment: /comment/{existing.id}"}, 409
|
||||||
|
|
||||||
if parent.author.any_block_exists(v) and v.admin_level < 2:
|
if parent.author.any_block_exists(v) and v.admin_level < PERMS['POST_COMMENT_MODERATION']:
|
||||||
return {"error": "You can't reply to users who have blocked you, or users you have blocked."}, 403
|
return {"error": "You can't reply to users who have blocked you, or users you have blocked."}, 403
|
||||||
|
|
||||||
is_bot = v.id != 12125 and (bool(request.headers.get("Authorization")) or (SITE == 'pcmemes.net' and v.id == SNAPPY_ID))
|
is_bot = v.id != 12125 and (bool(request.headers.get("Authorization")) or (SITE == 'pcmemes.net' and v.id == SNAPPY_ID))
|
||||||
|
|
|
@ -33,7 +33,7 @@ def flag_post(pid, v):
|
||||||
if reason.startswith('!') and (v.admin_level > PERMS['POST_COMMENT_MODERATION'] or post.sub and v.mods(post.sub)):
|
if reason.startswith('!') and (v.admin_level > PERMS['POST_COMMENT_MODERATION'] or post.sub and v.mods(post.sub)):
|
||||||
post.flair = reason[1:]
|
post.flair = reason[1:]
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
if v.admin_level > 1:
|
if v.admin_level >= PERMS['POST_COMMENT_MODERATION']:
|
||||||
ma=ModAction(
|
ma=ModAction(
|
||||||
kind="flair_post",
|
kind="flair_post",
|
||||||
user_id=v.id,
|
user_id=v.id,
|
||||||
|
|
|
@ -366,7 +366,7 @@ def kick(v, pid):
|
||||||
old = post.sub
|
old = post.sub
|
||||||
post.sub = None
|
post.sub = None
|
||||||
|
|
||||||
if v.admin_level >= 3 and v.id != post.author_id:
|
if v.admin_level >= PERMS['GLOBAL_MODERATION'] and v.id != post.author_id:
|
||||||
old_str = f'<a href="/h/{old}">/h/{old}</a>'
|
old_str = f'<a href="/h/{old}">/h/{old}</a>'
|
||||||
ma = ModAction(
|
ma = ModAction(
|
||||||
kind='move_hole',
|
kind='move_hole',
|
||||||
|
@ -385,7 +385,7 @@ def kick(v, pid):
|
||||||
g.db.add(ma)
|
g.db.add(ma)
|
||||||
|
|
||||||
if v.id != post.author_id:
|
if v.id != post.author_id:
|
||||||
if v.admin_level >= 3: position = 'Admin'
|
if v.admin_level >= PERMS['GLOBAL_MODERATION']: position = 'Admin'
|
||||||
else: position = 'Mod'
|
else: position = 'Mod'
|
||||||
message = f"@{v.username} ({position}) has moved [{post.title}]({post.shortlink}) from /h/{old} to the main feed!"
|
message = f"@{v.username} ({position}) has moved [{post.title}]({post.shortlink}) from /h/{old} to the main feed!"
|
||||||
send_repeatable_notification(post.author_id, message)
|
send_repeatable_notification(post.author_id, message)
|
||||||
|
|
|
@ -755,7 +755,7 @@
|
||||||
{% if v %}
|
{% if v %}
|
||||||
{% include "gif_modal.html" %}
|
{% include "gif_modal.html" %}
|
||||||
{% include "emoji_modal.html" %}
|
{% include "emoji_modal.html" %}
|
||||||
{% if v.admin_level > 1 %}
|
{% if v.admin_level >= PERMS['USER_BAN'] %}
|
||||||
{% include "ban_modal.html" %}
|
{% include "ban_modal.html" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
|
@ -418,7 +418,7 @@
|
||||||
{% if v %}
|
{% if v %}
|
||||||
{% include "delete_post_modal.html" %}
|
{% include "delete_post_modal.html" %}
|
||||||
{% include "report_post_modal.html" %}
|
{% include "report_post_modal.html" %}
|
||||||
{% if v.admin_level > 1 %}
|
{% if v.admin_level >= PERMS['USER_BAN'] %}
|
||||||
{% include "ban_modal.html" %}
|
{% include "ban_modal.html" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -296,6 +296,7 @@
|
||||||
</div>
|
</div>
|
||||||
<pre></pre>
|
<pre></pre>
|
||||||
<pre></pre>
|
<pre></pre>
|
||||||
|
{% if v.admin_level >= PERMS['USER_BAN'] %}
|
||||||
{% if u.is_suspended %}
|
{% if u.is_suspended %}
|
||||||
<form action="/unban_user/{{u.id}}" method="post" action="">
|
<form action="/unban_user/{{u.id}}" method="post" action="">
|
||||||
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||||
|
@ -315,6 +316,7 @@
|
||||||
<input autocomplete="off" id="user-ban-submit" type="submit" onclick="disable(this)" class="btn btn-danger" value="Ban user" disabled>
|
<input autocomplete="off" id="user-ban-submit" type="submit" onclick="disable(this)" class="btn btn-danger" value="Ban user" disabled>
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
<pre></pre>
|
<pre></pre>
|
||||||
<pre></pre>
|
<pre></pre>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue