make non-jannies unable to ping more than 3 ppl

master
Aevann1 2022-07-29 15:23:34 +02:00
parent 3b6f3b5bfb
commit 347604c433
5 changed files with 32 additions and 4 deletions

View File

@ -242,11 +242,13 @@ def sanitize(sanitized, edit=False):
sanitized = reddit_regex.sub(r'\1<a href="https://old.reddit.com/\2" rel="nofollow noopener noreferrer" target="_blank">/\2</a>', sanitized) sanitized = reddit_regex.sub(r'\1<a href="https://old.reddit.com/\2" rel="nofollow noopener noreferrer" target="_blank">/\2</a>', sanitized)
sanitized = sub_regex.sub(r'\1<a href="/\2">/\2</a>', sanitized) sanitized = sub_regex.sub(r'\1<a href="/\2">/\2</a>', sanitized)
v = getattr(g, 'v', None)
matches = [ m for m in mention_regex.finditer(sanitized) if m ] matches = [ m for m in mention_regex.finditer(sanitized) if m ]
names = set( m.group(2) for m in matches ) names = set( m.group(2) for m in matches )
if len(names) > 3 and not v.admin_level: abort(406)
users = get_users(names, graceful=True) users = get_users(names, graceful=True)
v = getattr(g, 'v', None)
for u in users: for u in users:
if not u: continue if not u: continue
m = [ m for m in matches if u.username.lower() == m.group(2).lower() or u.original_username.lower() == m.group(2).lower() ] m = [ m for m in matches if u.username.lower() == m.group(2).lower() or u.original_username.lower() == m.group(2).lower() ]

View File

@ -21,6 +21,11 @@ def error_401(e):
argval = quote(f"{path}?{qs}", safe='') argval = quote(f"{path}?{qs}", safe='')
return redirect(f"/login?redirect={argval}") return redirect(f"/login?redirect={argval}")
@app.errorhandler(406)
def error_406(e):
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "You can't ping more than 3 people!"}, 406
else: return render_template('errors/406.html', err=True), 406
@app.errorhandler(403) @app.errorhandler(403)
def error_403(e): def error_403(e):

View File

@ -0,0 +1,21 @@
{% extends "default.html" %}
{% block title %}
<title>Too many pings</title>
{% endblock %}
{% block pagetype %}Too many pings{% endblock %}
{% block content %}
<div class="row justify-content-center">
<div class="col-10 col-md-5">
<div class="text-center px-3 my-8">
<img alt=":#marseyrage" loading="lazy" src="/e/marseyrage.webp">
<pre></pre>
<h1 class="h5">Too many pings</h1>
<p class="text-muted mb-5">You can't ping more than 3 people!</p>
<div><a href="/" class="btn btn-primary">Go to frontpage</a></div>
</div>
</div>
</div>
{% endblock %}

View File

@ -10,7 +10,7 @@
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col-10 col-md-5"> <div class="col-10 col-md-5">
<div class="text-center px-3 my-8"> <div class="text-center px-3 my-8">
<img alt=":#marseyretard:" loading="lazy" src="/e/marseyretard.webp"> <img alt=":#marseyretard:" loading="lazy" src="/e/marseychonker2.webp">
<pre></pre> <pre></pre>
<h1 class="h5">Max file size is 8 MB (16 MB for paypigs)</h1> <h1 class="h5">Max file size is 8 MB (16 MB for paypigs)</h1>
<div><a href="/" class="btn btn-primary">Go to frontpage</a></div> <div><a href="/" class="btn btn-primary">Go to frontpage</a></div>

View File

@ -10,7 +10,7 @@
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col-10 col-md-5"> <div class="col-10 col-md-5">
<div class="text-center px-3 my-8"> <div class="text-center px-3 my-8">
<img alt=":#marseydead:" loading="lazy" src="/e/marseydead.webp"> <img alt=":#marseydead:" loading="lazy" src="/e/marseycarp3.webp">
<pre></pre> <pre></pre>
<h1 class="h5">500 Internal Server Error</h1> <h1 class="h5">500 Internal Server Error</h1>
<p class="text-muted mb-5">Hiiiii it's carp! I think this error means that there's a timeout error. And I think that means something took too long to load so it decided not to work at all. If you keep seeing this on the same page <I>but not other pages</I>, then something is probably wrong with that specific function. It may not be called a function, but that sounds right to me. Anyway, ping me and I'll whine to someone smarter to fix it. Don't bother them. Thanks ily <3</p> <p class="text-muted mb-5">Hiiiii it's carp! I think this error means that there's a timeout error. And I think that means something took too long to load so it decided not to work at all. If you keep seeing this on the same page <I>but not other pages</I>, then something is probably wrong with that specific function. It may not be called a function, but that sounds right to me. Anyway, ping me and I'll whine to someone smarter to fix it. Don't bother them. Thanks ily <3</p>