merge i think

remotes/1693176582716663532/tmp_refs/heads/watchparty
justcool393 2022-10-30 15:08:20 -05:00
parent 024005cc17
commit d61eda8427
2 changed files with 25 additions and 27 deletions

View File

@ -282,7 +282,7 @@ def execute_longpostbot(c, level, body, body_html, parent_submission, v):
n = Notification(comment_id=c2.id, user_id=v.id)
g.db.add(n)
def execute_basedbot(c, level, body, parent_submission, parent_post, v):
def execute_basedbot(c, level, body, parent_post, v):
pill = based_regex.match(body)
if level == 1: basedguy = get_account(parent_post.author_id)
else: basedguy = get_account(c.parent_comment.author_id)
@ -297,7 +297,7 @@ def execute_basedbot(c, level, body, parent_submission, parent_post, v):
body_based_html = sanitize(body2)
c_based = Comment(author_id=BASEDBOT_ID,
parent_submission=parent_submission,
parent_submission=parent_post.id,
distinguish_level=6,
parent_comment_id=c.id,
level=level+1,

View File

@ -90,10 +90,24 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
def comment(v):
if v.is_suspended: abort(403, "You can't perform this action while banned.")
parent_submission = request.values.get("submission").strip()
parent_fullname = request.values.get("parent_fullname").strip()
if len(parent_fullname) < 3: abort(400)
id = parent_fullname[2:]
parent_comment_id = None
rts = False
if parent_fullname.startswith("p_"):
parent = get_post(id, v=v)
parent_post = parent
if POLL_THREAD and parent.id == POLL_THREAD and v.admin_level < PERMS['POST_TO_POLL_THREAD']: abort(403)
elif parent_fullname.startswith("c_"):
parent = get_comment(id, v=v)
parent_post = get_post(parent.parent_submission, v=v)
parent_comment_id = parent.id
if parent.author_id == v.id: rts = True
else: abort(400)
parent_post = get_post(parent_submission, v=v)
level = 1 if isinstance(parent, Submission) else parent.level + 1
sub = parent_post.sub
if sub and v.exiled_from(sub): abort(403, f"You're exiled from /h/{sub}")
@ -102,20 +116,6 @@ def comment(v):
if parent_post.club and not (v and (v.paid_dues or v.id == parent_post.author_id)): abort(403)
rts = False
if parent_fullname.startswith("p_"):
parent = parent_post
parent_comment_id = None
level = 1
if POLL_THREAD and parent.id == POLL_THREAD and v.admin_level < PERMS['POST_TO_POLL_THREAD']: abort(403)
elif parent_fullname.startswith("c_"):
parent = get_comment(parent_fullname.split("_")[1], v=v)
parent_comment_id = parent.id
level = parent.level + 1
if parent.author_id == v.id: rts = True
else: abort(400)
if not parent.can_see(v): abort(404)
if parent.deleted_utc != 0: abort(404)
@ -201,15 +201,13 @@ def comment(v):
body_for_sanitize = marsify(body_for_sanitize)
torture = (v.agendaposter and not v.marseyawarded and parent_post.sub != 'chudrama' and parent_post.id not in ADMIGGER_THREADS)
body_html = sanitize(body_for_sanitize, limit_pings=5, count_marseys=not v.marsify, torture=torture)
if parent_post.id not in ADMIGGER_THREADS and '!wordle' not in body.lower() and AGENDAPOSTER_PHRASE not in body.lower():
existing = g.db.query(Comment.id).filter(Comment.author_id == v.id,
Comment.deleted_utc == 0,
Comment.parent_comment_id == parent_comment_id,
Comment.parent_submission == parent_submission,
Comment.parent_submission == parent_post.id,
Comment.body_html == body_html
).first()
if existing: abort(409, f"You already made that comment: /comment/{existing.id}")
@ -226,7 +224,7 @@ def comment(v):
if len(body_html) > COMMENT_BODY_HTML_LENGTH_LIMIT: abort(400)
c = Comment(author_id=v.id,
parent_submission=parent_submission,
parent_submission=parent_post.id,
parent_comment_id=parent_comment_id,
level=level,
over_18=parent_post.over_18 or request.values.get("over_18")=="true",
@ -263,7 +261,7 @@ def comment(v):
g.db.add(choice)
if SITE == 'pcmemes.net' and c.body.lower().startswith("based"):
execute_basedbot(c, level, body, parent_submission, parent_post, v)
execute_basedbot(c, level, body, parent_post, v)
if parent_post.id not in ADMIGGER_THREADS and v.agendaposter and not v.marseyawarded and AGENDAPOSTER_PHRASE not in c.body.lower() and parent_post.sub != 'chudrama':
c.is_banned = True
@ -274,7 +272,7 @@ def comment(v):
body_jannied_html = AGENDAPOSTER_MSG_HTML.format(id=v.id, username=v.username, type='comment', AGENDAPOSTER_PHRASE=AGENDAPOSTER_PHRASE)
c_jannied = Comment(author_id=AUTOJANNY_ID,
parent_submission=parent_submission,
parent_submission=parent_post.id,
distinguish_level=6,
parent_comment_id=c.id,
level=level+1,
@ -292,14 +290,14 @@ def comment(v):
g.db.add(n)
if SITE_NAME == 'rDrama':
execute_longpostbot(c, level, body, body_html, parent_submission, v)
execute_zozbot(c, level, parent_submission, v)
execute_longpostbot(c, level, body, body_html, parent_post.id, v)
execute_zozbot(c, level, parent_post.id, v)
if not v.shadowbanned:
notify_users = NOTIFY_USERS(body, v)
if c.level == 1:
subscribers = g.db.query(Subscription.user_id).filter(Subscription.submission_id == c.parent_submission, Subscription.user_id != v.id).all()
subscribers = g.db.query(Subscription.user_id).filter(Subscription.submission_id == c.parent_post.id, Subscription.user_id != v.id).all()
for x in subscribers:
notify_users.add(x[0])