minor bugfix

pull/64/head
Aevann1 2022-12-13 20:50:38 +02:00
parent f551c8e018
commit 36fca9caab
9 changed files with 17 additions and 9 deletions

View File

@ -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()

View File

@ -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)

View File

@ -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)

View File

@ -20,7 +20,7 @@
<td data-sort-key="{{user.username.lower() if user else ''}}">{%- include 'user_in_table.html' -%}</td>
<td {% if user.last_active %}data-time="{{user.last_active}}"{% endif %}></td>
<td>{{user.truescore}}</td>
<td>{{user.shadowbanned}}</td>
<td><a href="/@{{user.shadowbanner}}">{{user.shadowbanner}}</a></td>
<td>{% if user.ban_reason %}{{user.ban_reason}}{% endif %}</td>
</tr>
{% endfor %}

View File

@ -1 +1 @@
{% if v and v.admin_level >= PERMS['USER_SHADOWBAN'] and user.shadowbanned %}<i class="fas fa-user-times text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title='Shadowbanned by @{{user.shadowbanned}}{% if user.ban_reason %} for "{{user.ban_reason}}"{% endif %}'></i>{% endif %}
{% if v and v.admin_level >= PERMS['USER_SHADOWBAN'] and user.shadowbanned %}<i class="fas fa-user-times text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title='Shadowbanned by @{{user.shadowbanner}}{% if user.ban_reason %} for "{{user.ban_reason}}"{% endif %}'></i>{% endif %}

View File

@ -149,7 +149,7 @@
{% if c.active_flags(v) %}<button type="button" class="btn btn-primary" style="padding:1px 5px; font-size:10px" onclick="document.getElementById('flaggers-{{c.id}}').classList.toggle('d-none')">{{c.active_flags(v)}} Report{{macros.plural(c.active_flags(v))}}</button>{% endif %}
{% if c.over_18 %}<span class="badge badge-danger text-small-extra mr-1">+18</span>{% endif %}
{% if v and v.admin_level >= PERMS['USER_SHADOWBAN'] and c.author.shadowbanned %}<i class="fas fa-user-times text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title='Shadowbanned by @{{c.author.shadowbanned}} for "{{c.author.ban_reason}}"'></i>{% endif %}
{% if v and v.admin_level >= PERMS['USER_SHADOWBAN'] and c.author.shadowbanned %}<i class="fas fa-user-times text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title='Shadowbanned by @{{c.author.shadowbanner}} for "{{c.author.ban_reason}}"'></i>{% endif %}
{% if c.stickied %}
<i id='pinned-{{c.id}}'class="fas fa-thumbtack fa-rotate--45 text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Pinned by @{{c.stickied}}" {% if c.stickied_utc %}onmouseover="pinned_timestamp('pinned-{{c.id}}')" data-timestamp={{c.stickied_utc}} {% endif %}></i>
{% endif %}

View File

@ -15,7 +15,7 @@
{% if u.ban_reason %}:
{{u.ban_reason | safe}}
{% endif %}
(by <a href="/@{{u.shadowbanned}}">@{{u.shadowbanned}}</a>)
(by <a href="/@{{u.shadowbanner}}">@{{u.shadowbanner}}</a>)
</h5>
{% endif %}
{% endmacro %}

View File

@ -52,7 +52,7 @@
{% endfor %}
{% if v and v.admin_level >= PERMS['USER_SHADOWBAN'] and p.author.shadowbanned %}
<i class="fas fa-user-times text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title='Shadowbanned by @{{p.author.shadowbanned}} for "{{p.author.ban_reason}}"'></i>
<i class="fas fa-user-times text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title='Shadowbanned by @{{p.author.shadowbanner}} for "{{p.author.ban_reason}}"'></i>
{% endif %}
{% if p.stickied %}

View File

@ -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);