1. tell jannies the location of the report that caused someone to get under-sieged

2. allow jannies to see reports by shadowbanned users
3. destroy the shadowbanned underworld for reports
4. dedup reports HTML code
5. show JL5 the message that caused someone to get under-sieged
pull/150/head
Aevann 2023-05-15 01:01:10 +03:00
parent beeb3dba94
commit bbaa6cd6b0
7 changed files with 65 additions and 53 deletions

View File

@ -398,7 +398,7 @@ class Comment(Base):
@lazy
def filtered_flags(self, v):
return [f for f in self.flags if (v and v.shadowbanned) or not f.user.shadowbanned]
return [f for f in self.flags if not f.user.shadowbanned or (v and v.id == f.user_id) or (v and v.admin_level)]
@lazy
def active_flags(self, v):

View File

@ -365,7 +365,7 @@ class Submission(Base):
@lazy
def filtered_flags(self, v):
return [f for f in self.flags if (v and v.shadowbanned) or not f.user.shadowbanned]
return [f for f in self.flags if not f.user.shadowbanned or (v and v.id == f.user_id) or (v and v.admin_level)]
@lazy
def active_flags(self, v):

View File

@ -467,33 +467,47 @@ def execute_antispam_comment_check(body:str, v:User):
g.db.commit()
abort(403, "Too much spam!")
def execute_under_siege(v:User, target:Optional[Union[Submission, Comment]], body, type:str) -> bool:
if not get_setting("under_siege"): return True
def execute_under_siege(v:User, target:Optional[Union[Submission, Comment]], body, kind:str) -> bool:
if not get_setting("under_siege"): return
if v.shadowbanned: return
if v.admin_level >= PERMS['SITE_BYPASS_UNDER_SIEGE_MODE']: return
unshadowbannedcels = [x[0] for x in g.db.query(ModAction.target_user_id).filter_by(kind='unshadowban').all()]
if v.id in unshadowbannedcels: return True
if type in ('report', 'message'):
if kind in {'message', 'report'}:
threshold = 86400
else:
threshold = UNDER_SIEGE_AGE_THRESHOLD
if not v.shadowbanned and v.age < threshold and not v.admin_level >= PERMS['SITE_BYPASS_UNDER_SIEGE_MODE']:
v.shadowbanned = AUTOJANNY_ID
if v.age > threshold: return
ma = ModAction(
kind="shadowban",
user_id=AUTOJANNY_ID,
target_user_id=v.id,
_note=f'reason: "Under Siege ({type}, {v.age} seconds)"'
)
g.db.add(ma)
unshadowbannedcels = [x[0] for x in g.db.query(ModAction.target_user_id).filter_by(kind='unshadowban').all()]
if v.id in unshadowbannedcels: return
v.shadowbanned = AUTOJANNY_ID
v.ban_reason = "Under Siege"
g.db.add(v)
if kind == "report":
if isinstance(target, Submission):
reason = f'report on <a href="{target.permalink}">post</a>'
else:
reason = f'report on <a href="{target.permalink}">comment</a>'
else:
reason = kind
ma = ModAction(
kind="shadowban",
user_id=AUTOJANNY_ID,
target_user_id=v.id,
_note=f'reason: "Under Siege ({reason}, {v.age} seconds)"'
)
g.db.add(ma)
if kind == 'message':
notified_ids = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['BLACKJACK_NOTIFICATIONS'])]
for uid in notified_ids:
n = Notification(comment_id=target.id, user_id=uid)
g.db.add(n)
v.ban_reason = "Under Siege"
g.db.add(v)
t = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(time.time()))
return False
return True
def execute_lawlz_actions(v:User, p:Submission):
if v.id != LAWLZ_ID: return

View File

@ -234,16 +234,8 @@
{{c.blackjack_html | safe}}
{% endif %}
</div>
{% if c.active_flags(v) %}
<div id="flaggers-{{c.id}}" class="flaggers d-none">
<strong><i class="far fa-fw fa-flag"></i> Reported by:</strong>
<ul class="mt-1 mb-0" style="padding-left:20px;word-wrap:break-word">
{% for f in c.filtered_flags(v) %}
<li><a style="font-weight:bold" href="{{f.user.url}}">{{f.user.username}}</a>{% if f.reason %}: {{f.realreason(v) | safe}}{% endif %} {% if v and v.admin_level >= PERMS['FLAGS_REMOVE'] %}<button type="button" data-nonce="{{g.nonce}}" data-onclick="delReportComment(this,'/del_report/comment/{{f.comment_id}}/{{f.user_id}}')">[remove]</button>{% endif %}</li>
{% endfor %}
</ul>
</div>
{% endif %}
{{macros.flags(c)}}
{% if c.is_banned and c.ban_reason %}
<div id="comment-banned-warning" class="comment-text text-removed mb-0">removed by @{{c.ban_reason}} (Admin)</div>

View File

@ -74,18 +74,11 @@
<div id="post-content" class="card-block w-100 my-md-auto">
<div class="post-meta text-left mb-2">
{{ macros.post_meta(p) }}
{{macros.post_meta(p)}}
</div>
{% if p.active_flags(v) %}
<div id="flaggers-{{p.id}}" class="flaggers d-none">
<strong><i class="far fa-fw fa-flag"></i> Reported by:</strong>
<ul class="mt-1 mb-0" style="padding-left:20px; word-wrap:break-word">
{% for f in p.filtered_flags(v) %}
<li><a style="font-weight:bold" href="{{f.user.url}}">{{f.user.username}}</a>{% if f.reason %}: {{f.realreason(v) | safe}}{% endif %} {% if v and v.admin_level >= PERMS['FLAGS_REMOVE'] %}<button type="button" data-nonce="{{g.nonce}}" data-onclick="delReportPost(this,'/del_report/post/{{f.post_id}}/{{f.user_id}}')">[remove]</button>{% endif %}</li>
{% endfor %}
</ul>
</div>
{% endif %}
{{macros.flags(p)}}
{% if p.realurl(v) and not v_forbid_deleted %}
<h1 id="post-title" class="card-title post-title text-left mb-md-3 {% if p.author.agendaposter and p.sub != 'chudrama' %}text-uppercase{% endif %}">
<a {% if p.author.rainbow %}class="rainbow-text"{% endif %} {% if not v or v.newtabexternal %}target="_blank"{% endif %} rel="nofollow noopener" href="{{p.realurl(v)}}">

View File

@ -26,16 +26,7 @@
{% set v_forbid_deleted = (p.deleted_utc != 0 or p.is_banned) and not (v and v.admin_level >= PERMS['POST_COMMENT_MODERATION']) and not (v and v.id == p.author_id) %}
{% if p.active_flags(v) %}
<div id="flaggers-{{p.id}}" class="flaggers d-none">
<strong><i class="far fa-fw fa-flag"></i> Reported by:</strong>
<ul class="mt-1 mb-0" style="padding-left:20px; word-wrap:break-word">
{% for f in p.filtered_flags(v) %}
<li><a style="font-weight:bold" href="{{f.user.url}}">{{f.user.username}}</a>{% if f.reason %}: {{f.realreason(v) | safe}}{% endif %} {% if v and v.admin_level >= PERMS['FLAGS_REMOVE'] %}<button type="button" data-nonce="{{g.nonce}}" data-onclick="delReportPost(this,'/del_report/post/{{f.post_id}}/{{f.user_id}}')">[remove]</button>{% endif %}</li>
{% endfor %}
</ul>
</div>
{% endif %}
{{macros.flags(p)}}
<div id="post-{{p.id}}" class="actual-post {% if p.ghost %}ghost-post{% endif %} {% if p.unread %}unread{% else %}card{% endif %} {% if p.is_banned %} banned{% endif %}{% if p.deleted_utc %} deleted{% endif %}{% if p.stickied %} stickied{% endif %}{% if voted==1 %} upvoted{% elif voted==-1 %} downvoted{% endif %}{% if p.over_18 %} nsfw{% endif %}">

View File

@ -196,3 +196,25 @@
</div>
{% endif %}
{% endmacro %}
{% macro flags(i) %}
{% if i.active_flags(v) %}
<div id="flaggers-{{i.id}}" class="flaggers d-none">
<strong><i class="far fa-fw fa-flag"></i> Reported by:</strong>
<ul class="mt-1 mb-0" style="padding-left:20px;word-wrap:break-word">
{% for f in i.filtered_flags(v) %}
<li>
{% if v and v.admin_level %}
<i class="fas fa-user-times text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title='Shadowbanned by @{{f.user.shadowbanner}} for "{{f.user.ban_reason}}"'></i>
{% endif %}
<a style="font-weight:bold" href="{{f.user.url}}">{{f.user.username}}</a>
{% if f.reason %}: {{f.realreason(v) | safe}}{% endif %}
{% if v and v.admin_level >= PERMS['FLAGS_REMOVE'] %}
<button type="button" data-nonce="{{g.nonce}}" data-onclick="delReportComment(this,'/del_report/comment/{{f.comment_id}}/{{f.user_id}}')">[remove]</button>
{% endif %}
</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% endmacro %}