forked from rDrama/rDrama
dedup chud-checking logic
parent
0c3600e9a0
commit
4f788cb909
|
@ -620,6 +620,16 @@ def validate_css(css):
|
|||
|
||||
|
||||
def complies_with_chud(obj):
|
||||
if not obj.author.agendaposter: return True
|
||||
if obj.author.marseyawarded: return True
|
||||
|
||||
if isinstance(obj, Submission):
|
||||
if obj.id in ADMIGGER_THREADS: return True
|
||||
if obj.sub == "chudrama": return True
|
||||
elif obj.parent_submission:
|
||||
if obj.parent_submission in ADMIGGER_THREADS: return True
|
||||
if obj.post.sub == "chudrama": return True
|
||||
|
||||
soup=BeautifulSoup(obj.body_html.lower(), 'lxml')
|
||||
|
||||
tags = soup.html.body.find_all('p', recursive=False)
|
||||
|
|
|
@ -1306,7 +1306,7 @@ def remove_post(post_id, v):
|
|||
def approve_post(post_id, v):
|
||||
post = get_post(post_id)
|
||||
|
||||
if post.author.id == v.id and post.author.agendaposter and post.sub != 'chudrama' and not complies_with_chud(post):
|
||||
if not complies_with_chud(post):
|
||||
abort(400, "You can't bypass the chud award!")
|
||||
|
||||
if post.is_banned:
|
||||
|
@ -1540,7 +1540,7 @@ def remove_comment(c_id, v):
|
|||
def approve_comment(c_id, v):
|
||||
comment = get_comment(c_id)
|
||||
|
||||
if comment.author.id == v.id and comment.author.agendaposter and not (comment.parent_submission and comment.post.sub == 'chudrama') and not complies_with_chud(comment):
|
||||
if not complies_with_chud(comment):
|
||||
abort(400, "You can't bypass the chud award!")
|
||||
|
||||
if comment.is_banned:
|
||||
|
|
|
@ -279,7 +279,7 @@ def comment(v:User):
|
|||
if c.level == 1: c.top_comment_id = c.id
|
||||
else: c.top_comment_id = parent.top_comment_id
|
||||
|
||||
if post_target.id not in ADMIGGER_THREADS and v.agendaposter and not v.marseyawarded and not (posting_to_submission and post_target.sub == 'chudrama') and not complies_with_chud(c):
|
||||
if not complies_with_chud(c):
|
||||
c.is_banned = True
|
||||
c.ban_reason = "AutoJanny"
|
||||
g.db.add(c)
|
||||
|
@ -674,7 +674,7 @@ def edit_comment(cid, v):
|
|||
execute_blackjack(v, c, c.body, "comment")
|
||||
execute_under_siege(v, c, c.body, "comment")
|
||||
|
||||
if not (c.parent_submission and c.post.id in ADMIGGER_THREADS) and v.agendaposter and not v.marseyawarded and not (c.parent_submission and c.post.sub == 'chudrama') and not complies_with_chud(c):
|
||||
if not complies_with_chud(c):
|
||||
abort(403, f'You have to include "{v.agendaposter_phrase}" in your comment!')
|
||||
|
||||
|
||||
|
|
|
@ -656,7 +656,7 @@ def submit_post(v:User, sub=None):
|
|||
for x in notify_users:
|
||||
add_notif(cid, x, text, pushnotif_url=p.permalink)
|
||||
|
||||
if v.agendaposter and not v.marseyawarded and sub != 'chudrama' and not complies_with_chud(p):
|
||||
if not complies_with_chud(p):
|
||||
p.is_banned = True
|
||||
p.ban_reason = "AutoJanny"
|
||||
|
||||
|
@ -1041,7 +1041,7 @@ def edit_post(pid, v):
|
|||
|
||||
p.body_html = body_html
|
||||
|
||||
if v.id == p.author_id and v.agendaposter and not v.marseyawarded and p.sub != 'chudrama' and not complies_with_chud(p):
|
||||
if not complies_with_chud(p):
|
||||
abort(403, f'You have to include "{v.agendaposter_phrase}" in your post!')
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue