disallow jannoids from undoing chud awards

pull/83/head
Aevann 2022-12-26 04:38:32 +02:00
parent e3529d0495
commit f37e1dc702
4 changed files with 11 additions and 1 deletions

View File

@ -77,7 +77,8 @@ class User(Base):
lootboxes_bought = Column(Integer, default=0)
agendaposter = Column(Integer, default=0)
is_activated = Column(Boolean, default=False)
shadowbanned = Column(Integer)
shadowbanned = Column(Integer, ForeignKey("users.id"))
chudded_by = Column(Integer, ForeignKey("users.id"))
over_18 = Column(Boolean, default=False)
hidevotedon = Column(Boolean, default=False)
highlightcomments = Column(Boolean, default=True)

View File

@ -24,6 +24,7 @@ def award_timers(v, bot=False):
notify_if_not_bot("You have been unbanned!")
if v.agendaposter and v.agendaposter != 1 and v.agendaposter < now:
v.agendaposter = 0
v.chudded_by = None
notify_if_not_bot("Your chud status has expired!")
badge = v.has_badge(28)
if badge: g.db.delete(badge)

View File

@ -873,6 +873,9 @@ def admin_removed_comments(v):
def unagendaposter(user_id, v):
user = get_account(user_id)
if not user.chudded_by:
abort(403, "Jannies can't undo chud awards anymore!")
user.agendaposter = 0
g.db.add(user)
@ -1080,6 +1083,7 @@ def agendaposter(user_id, v):
if reason: text = f"@{v.username} (a site admin) has chudded you permanently for the following reason:\n\n> {reason}"
else: text = f"@{v.username} (a site admin) has chudded you permanently."
user.chudded_by = v.id
g.db.add(user)
send_repeatable_notification(user.id, text)

View File

@ -0,0 +1,4 @@
alter table users add column chudded_by int;
alter table users add constraint user_chudded_by_fkey foreign key (chudded_by) references users(id);
create index fki_user_chudded_by_fkey on users using btree (chudded_by);
update users set chudded_by=1 where agendaposter > 0;