diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index ad9845f0e..37f11cb2c 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -86,4 +86,20 @@ def NOTIFY_USERS2(text, v): user = get_user(i.group(2), graceful=True) if user and not v.any_block_exists(user): notify_users.add(user.id) - return notify_users \ No newline at end of file + return notify_users + +def send_admin(id, body_html): + + new_comment = Comment(author_id=id, + parent_submission=None, + level=1, + sentto=0, + body_html=body_html, + ) + g.db.add(new_comment) + g.db.flush() + + admins = g.db.query(User).filter(User.admin_level > 2).all() + for admin in admins: + notif = Notification(comment_id=new_comment.id, user_id=admin.id) + g.db.add(notif) \ No newline at end of file diff --git a/files/routes/admin.py b/files/routes/admin.py index a19fd204c..40326a552 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -175,7 +175,7 @@ def club_ban(v, username): @app.post("/@/make_meme_admin") @limiter.limit("1/second;30/minute;200/hour;1000/day") -@admin_level_required(2) +@admin_level_required(3) def make_meme_admin(v, username): if request.host == 'pcmemes.net' or (SITE_NAME == 'Drama' and v.admin_level > 2) or (request.host != 'rdrama.net' and request.host != 'pcmemes.net'): user = get_user(username) @@ -188,7 +188,7 @@ def make_meme_admin(v, username): @app.post("/@/remove_meme_admin") @limiter.limit("1/second;30/minute;200/hour;1000/day") -@admin_level_required(2) +@admin_level_required(3) def remove_meme_admin(v, username): if request.host == 'pcmemes.net' or (SITE_NAME == 'Drama' and v.admin_level > 2) or (request.host != 'rdrama.net' and request.host != 'pcmemes.net'): user = get_user(username) @@ -387,7 +387,7 @@ def purge_cache(v): @app.post("/admin/under_attack") -@admin_level_required(2) +@admin_level_required(3) def under_attack(v): if environ.get('under_attack'): environ["under_attack"] = "" @@ -1217,7 +1217,7 @@ def admin_dump_cache(v): @app.get("/admin/banned_domains/") -@admin_level_required(2) +@admin_level_required(3) def admin_banned_domains(v): banned_domains = g.db.query(BannedDomain).all() @@ -1225,7 +1225,7 @@ def admin_banned_domains(v): @app.post("/admin/banned_domains") @limiter.limit("1/second;30/minute;200/hour;1000/day") -@admin_level_required(2) +@admin_level_required(3) def admin_toggle_ban_domain(v): domain=request.values.get("domain", "").strip() diff --git a/files/routes/static.py b/files/routes/static.py index 9fa5b234c..646bcbd87 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -295,19 +295,7 @@ def submit_contact(v): body_html += f"

{url}

" else: return {"error": "Image/Video files only"}, 400 - new_comment = Comment(author_id=v.id, - parent_submission=None, - level=1, - sentto=0, - body_html=body_html, - ) - g.db.add(new_comment) - g.db.flush() - - admins = g.db.query(User).filter(User.admin_level > 2).all() - for admin in admins: - notif = Notification(comment_id=new_comment.id, user_id=admin.id) - g.db.add(notif) + send_admin(v.id, body_html) g.db.commit() return render_template("contact.html", v=v, msg="Your message has been sent.") diff --git a/files/routes/users.py b/files/routes/users.py index 3f3b3ddb6..fb05d81f3 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -457,7 +457,7 @@ def message2(v, username): if v.admin_level <= 1 and hasattr(user, 'is_blocked') and user.is_blocked: return {"error": "This user is blocking you."}, 403 - if v.shadowbanned: return {"message": "Message sent!"} + if v.shadowbanned and user.admin_level < 2: return {"message": "Message sent!"} message = request.values.get("message", "").strip()[:10000].strip() diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index 3085c20dd..887a9b50a 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -12,16 +12,6 @@ {% endif %} - -