forked from rDrama/rDrama
restore banning domains
parent
5c13700080
commit
af59e82528
|
@ -1529,55 +1529,53 @@ 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)
|
if len(reason) > 100:
|
||||||
|
abort(400, 'Reason is too long!')
|
||||||
|
|
||||||
# if len(reason) > 100:
|
existing = g.db.get(BannedDomain, domain)
|
||||||
# abort(400, 'Reason is too long!')
|
if not existing:
|
||||||
|
d = BannedDomain(domain=domain, reason=reason)
|
||||||
|
g.db.add(d)
|
||||||
|
ma = ModAction(
|
||||||
|
kind="ban_domain",
|
||||||
|
user_id=v.id,
|
||||||
|
_note=filter_emojis_only(f'{domain}, reason: {reason}')
|
||||||
|
)
|
||||||
|
g.db.add(ma)
|
||||||
|
|
||||||
# existing = g.db.get(BannedDomain, domain)
|
return redirect("/admin/banned_domains/")
|
||||||
# if not existing:
|
|
||||||
# d = BannedDomain(domain=domain, reason=reason)
|
|
||||||
# g.db.add(d)
|
|
||||||
# ma = ModAction(
|
|
||||||
# kind="ban_domain",
|
|
||||||
# user_id=v.id,
|
|
||||||
# _note=f'{domain}, reason: {reason}'
|
|
||||||
# )
|
|
||||||
# g.db.add(ma)
|
|
||||||
|
|
||||||
# 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=filter_emojis_only(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