Set filter status badly so commenting works again
This commit is contained in:
parent
6312ebea16
commit
3c2871dd0f
3 changed files with 4 additions and 118 deletions
|
@ -69,6 +69,8 @@ class Comment(Base):
|
|||
def __init__(self, *args, **kwargs):
|
||||
if "created_utc" not in kwargs:
|
||||
kwargs["created_utc"] = int(time.time())
|
||||
if 'filter_state' not in kwargs:
|
||||
kwargs['filter_state'] = 'normal'
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def __repr__(self):
|
||||
|
|
|
@ -196,16 +196,6 @@ def api_comment(v):
|
|||
|
||||
if not body and not request.files.get('file'): return {"error":"You need to actually write something!"}, 400
|
||||
|
||||
options = []
|
||||
for i in poll_regex.finditer(body):
|
||||
options.append(i.group(1))
|
||||
body = body.replace(i.group(0), "")
|
||||
|
||||
choices = []
|
||||
for i in choice_regex.finditer(body):
|
||||
choices.append(i.group(1))
|
||||
body = body.replace(i.group(0), "")
|
||||
|
||||
if request.files.get("file") and request.headers.get("cf-ipcountry") != "T1":
|
||||
files = request.files.getlist('file')[:4]
|
||||
for file in files:
|
||||
|
@ -322,7 +312,8 @@ def api_comment(v):
|
|||
app_id=v.client.application.id if v.client else None,
|
||||
body_html=body_html,
|
||||
body=body[:10000],
|
||||
ghost=parent_post.ghost
|
||||
ghost=parent_post.ghost,
|
||||
filter_state='normal' #todo this needs the real filter state calculator
|
||||
)
|
||||
|
||||
c.upvotes = 1
|
||||
|
@ -337,30 +328,6 @@ def api_comment(v):
|
|||
if c.level == 1: c.top_comment_id = c.id
|
||||
else: c.top_comment_id = parent.top_comment_id
|
||||
|
||||
for option in options:
|
||||
c_option = Comment(author_id=AUTOPOLLER_ID,
|
||||
parent_submission=parent_submission,
|
||||
parent_comment_id=c.id,
|
||||
level=level+1,
|
||||
body_html=filter_emojis_only(option),
|
||||
upvotes=0,
|
||||
is_bot=True
|
||||
)
|
||||
|
||||
g.db.add(c_option)
|
||||
|
||||
for choice in choices:
|
||||
c_choice = Comment(author_id=AUTOCHOICE_ID,
|
||||
parent_submission=parent_submission,
|
||||
parent_comment_id=c.id,
|
||||
level=level+1,
|
||||
body_html=filter_emojis_only(choice),
|
||||
upvotes=0,
|
||||
is_bot=True
|
||||
)
|
||||
|
||||
g.db.add(c_choice)
|
||||
|
||||
if parent_post.id not in ADMINISTRATORS:
|
||||
if not v.shadowbanned:
|
||||
notify_users = NOTIFY_USERS(body, v)
|
||||
|
@ -450,32 +417,6 @@ def edit_comment(cid, v):
|
|||
elif v.bird and len(body) > 140:
|
||||
return {"error":"You have to type less than 140 characters!"}, 403
|
||||
|
||||
if not c.options:
|
||||
for i in poll_regex.finditer(body):
|
||||
body = body.replace(i.group(0), "")
|
||||
c_option = Comment(author_id=AUTOPOLLER_ID,
|
||||
parent_submission=c.parent_submission,
|
||||
parent_comment_id=c.id,
|
||||
level=c.level+1,
|
||||
body_html=filter_emojis_only(i.group(1)),
|
||||
upvotes=0,
|
||||
is_bot=True
|
||||
)
|
||||
g.db.add(c_option)
|
||||
|
||||
if not c.choices:
|
||||
for i in choice_regex.finditer(body):
|
||||
body = body.replace(i.group(0), "")
|
||||
c_choice = Comment(author_id=AUTOCHOICE_ID,
|
||||
parent_submission=c.parent_submission,
|
||||
parent_comment_id=c.id,
|
||||
level=c.level+1,
|
||||
body_html=filter_emojis_only(i.group(1)),
|
||||
upvotes=0,
|
||||
is_bot=True
|
||||
)
|
||||
g.db.add(c_choice)
|
||||
|
||||
body_html = sanitize(body, edit=True)
|
||||
|
||||
if '!slots' not in body.lower() and '!blackjack' not in body.lower() and '!wordle' not in body.lower():
|
||||
|
|
|
@ -465,31 +465,6 @@ def edit_post(pid, v):
|
|||
body += f"\n\n{url}"
|
||||
else: return {"error": "Image/Video files only"}, 400
|
||||
|
||||
if body != p.body:
|
||||
if not p.options:
|
||||
for i in poll_regex.finditer(body):
|
||||
body = body.replace(i.group(0), "")
|
||||
c = Comment(author_id=AUTOPOLLER_ID,
|
||||
parent_submission=p.id,
|
||||
level=1,
|
||||
body_html=filter_emojis_only(i.group(1)),
|
||||
upvotes=0,
|
||||
is_bot=True
|
||||
)
|
||||
g.db.add(c)
|
||||
|
||||
if not p.choices:
|
||||
for i in choice_regex.finditer(body):
|
||||
body = body.replace(i.group(0), "")
|
||||
c = Comment(author_id=AUTOCHOICE_ID,
|
||||
parent_submission=p.id,
|
||||
level=1,
|
||||
body_html=filter_emojis_only(i.group(1)),
|
||||
upvotes=0,
|
||||
is_bot=True
|
||||
)
|
||||
g.db.add(c)
|
||||
|
||||
body_html = sanitize(body, edit=True)
|
||||
|
||||
if v.id == p.author_id and v.marseyawarded and marseyaward_body_regex.search(body_html):
|
||||
|
@ -980,38 +955,6 @@ def submit_post(v, sub=None):
|
|||
g.db.add(v)
|
||||
send_repeatable_notification(CARP_ID, post.permalink)
|
||||
|
||||
if v and v.admin_level > 2:
|
||||
for option in bet_options:
|
||||
bet_option = Comment(author_id=AUTOBETTER_ID,
|
||||
parent_submission=post.id,
|
||||
level=1,
|
||||
body_html=filter_emojis_only(option),
|
||||
upvotes=0,
|
||||
is_bot=True
|
||||
)
|
||||
|
||||
g.db.add(bet_option)
|
||||
|
||||
for option in options:
|
||||
c = Comment(author_id=AUTOPOLLER_ID,
|
||||
parent_submission=post.id,
|
||||
level=1,
|
||||
body_html=filter_emojis_only(option),
|
||||
upvotes=0,
|
||||
is_bot=True
|
||||
)
|
||||
g.db.add(c)
|
||||
|
||||
for choice in choices:
|
||||
c = Comment(author_id=AUTOCHOICE_ID,
|
||||
parent_submission=post.id,
|
||||
level=1,
|
||||
body_html=filter_emojis_only(choice),
|
||||
upvotes=0,
|
||||
is_bot=True
|
||||
)
|
||||
g.db.add(c)
|
||||
|
||||
vote = Vote(user_id=v.id,
|
||||
vote_type=1,
|
||||
submission_id=post.id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue