Merge branch 'frost' into new-user-filtering

This commit is contained in:
Julian Rota 2022-05-22 17:01:45 -04:00
commit 0002f66f36
82 changed files with 1036 additions and 1528 deletions

View file

@ -950,77 +950,6 @@ def admin_removed_comments(v):
)
@app.post("/agendaposter/<user_id>")
@admin_level_required(2)
def agendaposter(user_id, v):
user = g.db.query(User).filter_by(id=user_id).one_or_none()
days = request.values.get("days") or 30
expiry = float(days)
expiry = int(time.time() + expiry*60*60*24)
user.agendaposter = expiry
g.db.add(user)
for alt in user.alts:
if alt.admin_level: return {"error": "User is an admin!"}
alt.agendaposter = expiry
g.db.add(alt)
note = f"for {days} days"
ma = ModAction(
kind="agendaposter",
user_id=v.id,
target_user_id=user.id,
note = note
)
g.db.add(ma)
if not user.has_badge(28):
badge = Badge(user_id=user.id, badge_id=28)
g.db.add(badge)
g.db.flush()
send_notification(user.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}")
send_repeatable_notification(user.id, f"@{v.username} has marked you as a chud ({note}).")
g.db.commit()
return redirect(user.url)
@app.post("/unagendaposter/<user_id>")
@admin_level_required(2)
def unagendaposter(user_id, v):
user = g.db.query(User).filter_by(id=user_id).one_or_none()
user.agendaposter = 0
g.db.add(user)
for alt in user.alts:
alt.agendaposter = 0
g.db.add(alt)
ma = ModAction(
kind="unagendaposter",
user_id=v.id,
target_user_id=user.id
)
g.db.add(ma)
badge = user.has_badge(28)
if badge: g.db.delete(badge)
send_repeatable_notification(user.id, f"@{v.username} has unmarked you as a chud.")
g.db.commit()
return {"message": "Chud theme disabled!"}
@app.post("/shadowban/<user_id>")
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@admin_level_required(2)
@ -1538,9 +1467,6 @@ def api_unban_comment(c_id, v):
comment = g.db.query(Comment).filter_by(id=c_id).one_or_none()
if not comment: abort(404)
if comment.author.agendaposter and AGENDAPOSTER_PHRASE not in comment.body.lower():
return {"error": "You can't bypass the chud award!"}
if comment.is_banned:
ma=ModAction(
kind="unban_comment",