better enforcement for effortposts

master
Aevann 2024-04-29 05:28:46 +03:00
parent 895e2d2adf
commit b020f8a300
1 changed files with 10 additions and 1 deletions

View File

@ -2052,9 +2052,18 @@ def mark_effortpost(pid, v):
min_chars = 3000
min_lines = 20
if len(p.body) < min_chars or p.body_html.count('<p>') < min_lines:
if p.body_html.count('<p>') < min_lines:
abort(403, "Post is too short!")
soup = BeautifulSoup(p.body_html, 'lxml')
tags = soup.html.body.find_all(lambda tag: tag.name == 'p' and tag.text, recursive=False)
post_char_count = 0
for tag in tags:
post_char_count += len(tag.text)
if post_char_count < min_chars:
abort(403, "Post is too short.")
p.effortpost = True
g.db.add(p)