diff --git a/files/classes/user.py b/files/classes/user.py
index 78074d1a6..a98db16b4 100644
--- a/files/classes/user.py
+++ b/files/classes/user.py
@@ -81,7 +81,7 @@ class User(Base):
lootboxes_bought = Column(Integer, default=0)
agendaposter = Column(Integer, default=0)
is_activated = Column(Boolean, default=False)
- shadowbanned = Column(String)
+ shadowbanned = Column(Integer)
over_18 = Column(Boolean, default=False)
hidevotedon = Column(Boolean, default=False)
highlightcomments = Column(Boolean, default=True)
@@ -1117,3 +1117,8 @@ class User(Base):
@lazy
def offsitementions(self):
return self.has_badge(140)
+
+ @property
+ @lazy
+ def shadowbanner(self):
+ return g.db.query(User.username).filter_by(id=self.shadowbanned).one()
diff --git a/files/helpers/actions.py b/files/helpers/actions.py
index de501f808..eefecc79f 100644
--- a/files/helpers/actions.py
+++ b/files/helpers/actions.py
@@ -385,7 +385,7 @@ def execute_blackjack(v, target, body, type):
if not execute_blackjack_custom(v, target, body, type): return False
if not blackjack or not body: return True
if any(i in body.lower() for i in blackjack.split()):
- v.shadowbanned = 'AutoJanny'
+ v.shadowbanned = AUTOJANNY_ID
if not v.is_banned: v.ban_reason = f"Blackjack"
g.db.add(v)
notif = None
@@ -468,7 +468,7 @@ def execute_antispam_comment_check(body:str, v:User):
def execute_under_siege(v:User, target:Optional[Union[Submission, Comment]], body, type:str):
if not get_setting("under_siege"): return True
if v.age < UNDER_SIEGE_AGE_THRESHOLD and not v.admin_level >= PERMS['SITE_BYPASS_UNDER_SIEGE_MODE']:
- v.shadowbanned = 'AutoJanny'
+ v.shadowbanned = AUTOJANNY_ID
if not v.is_banned: v.ban_reason = f"Under Siege"
v.is_muted = True
g.db.add(v)
diff --git a/files/routes/admin.py b/files/routes/admin.py
index 43213a5c1..85edd790d 100644
--- a/files/routes/admin.py
+++ b/files/routes/admin.py
@@ -889,7 +889,7 @@ def shadowban(user_id, v):
user = get_account(user_id)
if user.admin_level > v.admin_level:
abort(403)
- user.shadowbanned = v.username
+ user.shadowbanned = v.id
reason = request.values.get("reason").strip()[:256]
user.ban_reason = reason
g.db.add(user)
diff --git a/files/templates/admin/shadowbanned.html b/files/templates/admin/shadowbanned.html
index 3a7652c7c..8c2fb66bb 100644
--- a/files/templates/admin/shadowbanned.html
+++ b/files/templates/admin/shadowbanned.html
@@ -20,7 +20,7 @@
{%- include 'user_in_table.html' -%} |
|
{{user.truescore}} |
- {{user.shadowbanned}} |
+ {{user.shadowbanner}} |
{% if user.ban_reason %}{{user.ban_reason}}{% endif %} |
{% endfor %}
diff --git a/files/templates/admin/shadowbanned_tooltip.html b/files/templates/admin/shadowbanned_tooltip.html
index 5b21b5bac..2c795543c 100644
--- a/files/templates/admin/shadowbanned_tooltip.html
+++ b/files/templates/admin/shadowbanned_tooltip.html
@@ -1 +1 @@
-{% if v and v.admin_level >= PERMS['USER_SHADOWBAN'] and user.shadowbanned %}{% endif %}
+{% if v and v.admin_level >= PERMS['USER_SHADOWBAN'] and user.shadowbanned %}{% endif %}
diff --git a/files/templates/comments.html b/files/templates/comments.html
index e52bdb6cf..8945f12ad 100644
--- a/files/templates/comments.html
+++ b/files/templates/comments.html
@@ -149,7 +149,7 @@
{% if c.active_flags(v) %}{% endif %}
{% if c.over_18 %}{% endif %}
- {% if v and v.admin_level >= PERMS['USER_SHADOWBAN'] and c.author.shadowbanned %}{% endif %}
+ {% if v and v.admin_level >= PERMS['USER_SHADOWBAN'] and c.author.shadowbanned %}{% endif %}
{% if c.stickied %}
{% endif %}
diff --git a/files/templates/userpage/admintools.html b/files/templates/userpage/admintools.html
index ebd758c9b..f647c53d1 100644
--- a/files/templates/userpage/admintools.html
+++ b/files/templates/userpage/admintools.html
@@ -15,7 +15,7 @@
{% if u.ban_reason %}:
{{u.ban_reason | safe}}
{% endif %}
- (by @{{u.shadowbanned}})
+ (by @{{u.shadowbanner}})
{% endif %}
{% endmacro %}
diff --git a/files/templates/util/macros.html b/files/templates/util/macros.html
index a30506ac4..2e4c04f87 100644
--- a/files/templates/util/macros.html
+++ b/files/templates/util/macros.html
@@ -52,7 +52,7 @@
{% endfor %}
{% if v and v.admin_level >= PERMS['USER_SHADOWBAN'] and p.author.shadowbanned %}
-
+
{% endif %}
{% if p.stickied %}
diff --git a/migrations/20221213-convert-shadowbanned-attribute-to-fkey.sql b/migrations/20221213-convert-shadowbanned-attribute-to-fkey.sql
new file mode 100644
index 000000000..0c7877e55
--- /dev/null
+++ b/migrations/20221213-convert-shadowbanned-attribute-to-fkey.sql
@@ -0,0 +1,3 @@
+alter table users alter column shadowbanned type int using shadowbanned::integer;
+create index fki_user_shadowbanned_fkey on public.users using btree (shadowbanned);
+alter table only public.users add constraint user_shadowbanned_fkey foreign key (shadowbanned) references public.users(id);