forked from rDrama/rDrama
comment domains for now
parent
bf00867fe8
commit
181a660760
|
@ -1510,55 +1510,55 @@ def admin_banned_domains(v):
|
||||||
return render_template("admin/banned_domains.html", v=v,
|
return render_template("admin/banned_domains.html", v=v,
|
||||||
banned_domains=banned_domains)
|
banned_domains=banned_domains)
|
||||||
|
|
||||||
@app.post("/admin/ban_domain")
|
# @app.post("/admin/ban_domain")
|
||||||
@limiter.limit(DEFAULT_RATELIMIT_SLOWER)
|
# @limiter.limit(DEFAULT_RATELIMIT_SLOWER)
|
||||||
@admin_level_required(PERMS['DOMAINS_BAN'])
|
# @admin_level_required(PERMS['DOMAINS_BAN'])
|
||||||
def ban_domain(v):
|
# def ban_domain(v):
|
||||||
|
|
||||||
domain=request.values.get("domain", "").strip().lower()
|
# domain=request.values.get("domain", "").strip().lower()
|
||||||
if not domain: abort(400)
|
# if not domain: abort(400)
|
||||||
|
|
||||||
reason=request.values.get("reason", "").strip()
|
# reason=request.values.get("reason", "").strip()
|
||||||
if not reason: abort(400, 'Reason is required!')
|
# if not reason: abort(400, 'Reason is required!')
|
||||||
|
|
||||||
if len(reason) > 100:
|
# if len(reason) > 100:
|
||||||
abort(400, 'Reason is too long (max 100 characters)!')
|
# abort(400, 'Reason is too long (max 100 characters)!')
|
||||||
|
|
||||||
reason = filter_emojis_only(reason)
|
# reason = filter_emojis_only(reason)
|
||||||
|
|
||||||
if len(reason) > 100:
|
# if len(reason) > 100:
|
||||||
abort(400, 'Reason is too long (max 100 characters)!')
|
# abort(400, 'Reason is too long (max 100 characters)!')
|
||||||
|
|
||||||
existing = g.db.get(BannedDomain, domain)
|
# existing = g.db.get(BannedDomain, domain)
|
||||||
if not existing:
|
# if not existing:
|
||||||
d = BannedDomain(domain=domain, reason=reason)
|
# d = BannedDomain(domain=domain, reason=reason)
|
||||||
g.db.add(d)
|
# g.db.add(d)
|
||||||
ma = ModAction(
|
# ma = ModAction(
|
||||||
kind="ban_domain",
|
# kind="ban_domain",
|
||||||
user_id=v.id,
|
# user_id=v.id,
|
||||||
_note=f'{domain}, reason: {reason}'
|
# _note=f'{domain}, reason: {reason}'
|
||||||
)
|
# )
|
||||||
g.db.add(ma)
|
# g.db.add(ma)
|
||||||
|
|
||||||
return redirect("/admin/banned_domains/")
|
# return redirect("/admin/banned_domains/")
|
||||||
|
|
||||||
|
|
||||||
@app.post("/admin/unban_domain/<path:domain>")
|
# @app.post("/admin/unban_domain/<path:domain>")
|
||||||
@limiter.limit(DEFAULT_RATELIMIT_SLOWER)
|
# @limiter.limit(DEFAULT_RATELIMIT_SLOWER)
|
||||||
@admin_level_required(PERMS['DOMAINS_BAN'])
|
# @admin_level_required(PERMS['DOMAINS_BAN'])
|
||||||
def unban_domain(v:User, domain):
|
# def unban_domain(v:User, domain):
|
||||||
existing = g.db.get(BannedDomain, domain)
|
# existing = g.db.get(BannedDomain, domain)
|
||||||
if not existing: abort(400, 'Domain is not banned!')
|
# if not existing: abort(400, 'Domain is not banned!')
|
||||||
|
|
||||||
g.db.delete(existing)
|
# g.db.delete(existing)
|
||||||
ma = ModAction(
|
# ma = ModAction(
|
||||||
kind="unban_domain",
|
# kind="unban_domain",
|
||||||
user_id=v.id,
|
# user_id=v.id,
|
||||||
_note=domain
|
# _note=domain
|
||||||
)
|
# )
|
||||||
g.db.add(ma)
|
# g.db.add(ma)
|
||||||
|
|
||||||
return {"message": f"{domain} has been unbanned!"}
|
# return {"message": f"{domain} has been unbanned!"}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue