forked from rDrama/rDrama
merge i think
parent
024005cc17
commit
d61eda8427
|
@ -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)
|
n = Notification(comment_id=c2.id, user_id=v.id)
|
||||||
g.db.add(n)
|
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)
|
pill = based_regex.match(body)
|
||||||
if level == 1: basedguy = get_account(parent_post.author_id)
|
if level == 1: basedguy = get_account(parent_post.author_id)
|
||||||
else: basedguy = get_account(c.parent_comment.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)
|
body_based_html = sanitize(body2)
|
||||||
c_based = Comment(author_id=BASEDBOT_ID,
|
c_based = Comment(author_id=BASEDBOT_ID,
|
||||||
parent_submission=parent_submission,
|
parent_submission=parent_post.id,
|
||||||
distinguish_level=6,
|
distinguish_level=6,
|
||||||
parent_comment_id=c.id,
|
parent_comment_id=c.id,
|
||||||
level=level+1,
|
level=level+1,
|
||||||
|
|
|
@ -90,10 +90,24 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
|
||||||
def comment(v):
|
def comment(v):
|
||||||
if v.is_suspended: abort(403, "You can't perform this action while banned.")
|
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()
|
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
|
||||||
|
|
||||||
parent_post = get_post(parent_submission, v=v)
|
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)
|
||||||
|
|
||||||
|
level = 1 if isinstance(parent, Submission) else parent.level + 1
|
||||||
sub = parent_post.sub
|
sub = parent_post.sub
|
||||||
if sub and v.exiled_from(sub): abort(403, f"You're exiled from /h/{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)
|
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 not parent.can_see(v): abort(404)
|
||||||
if parent.deleted_utc != 0: abort(404)
|
if parent.deleted_utc != 0: abort(404)
|
||||||
|
|
||||||
|
@ -201,15 +201,13 @@ def comment(v):
|
||||||
body_for_sanitize = marsify(body_for_sanitize)
|
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)
|
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)
|
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():
|
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,
|
existing = g.db.query(Comment.id).filter(Comment.author_id == v.id,
|
||||||
Comment.deleted_utc == 0,
|
Comment.deleted_utc == 0,
|
||||||
Comment.parent_comment_id == parent_comment_id,
|
Comment.parent_comment_id == parent_comment_id,
|
||||||
Comment.parent_submission == parent_submission,
|
Comment.parent_submission == parent_post.id,
|
||||||
Comment.body_html == body_html
|
Comment.body_html == body_html
|
||||||
).first()
|
).first()
|
||||||
if existing: abort(409, f"You already made that comment: /comment/{existing.id}")
|
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)
|
if len(body_html) > COMMENT_BODY_HTML_LENGTH_LIMIT: abort(400)
|
||||||
|
|
||||||
c = Comment(author_id=v.id,
|
c = Comment(author_id=v.id,
|
||||||
parent_submission=parent_submission,
|
parent_submission=parent_post.id,
|
||||||
parent_comment_id=parent_comment_id,
|
parent_comment_id=parent_comment_id,
|
||||||
level=level,
|
level=level,
|
||||||
over_18=parent_post.over_18 or request.values.get("over_18")=="true",
|
over_18=parent_post.over_18 or request.values.get("over_18")=="true",
|
||||||
|
@ -263,7 +261,7 @@ def comment(v):
|
||||||
g.db.add(choice)
|
g.db.add(choice)
|
||||||
|
|
||||||
if SITE == 'pcmemes.net' and c.body.lower().startswith("based"):
|
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':
|
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
|
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)
|
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,
|
c_jannied = Comment(author_id=AUTOJANNY_ID,
|
||||||
parent_submission=parent_submission,
|
parent_submission=parent_post.id,
|
||||||
distinguish_level=6,
|
distinguish_level=6,
|
||||||
parent_comment_id=c.id,
|
parent_comment_id=c.id,
|
||||||
level=level+1,
|
level=level+1,
|
||||||
|
@ -292,14 +290,14 @@ def comment(v):
|
||||||
g.db.add(n)
|
g.db.add(n)
|
||||||
|
|
||||||
if SITE_NAME == 'rDrama':
|
if SITE_NAME == 'rDrama':
|
||||||
execute_longpostbot(c, level, body, body_html, parent_submission, v)
|
execute_longpostbot(c, level, body, body_html, parent_post.id, v)
|
||||||
execute_zozbot(c, level, parent_submission, v)
|
execute_zozbot(c, level, parent_post.id, v)
|
||||||
|
|
||||||
if not v.shadowbanned:
|
if not v.shadowbanned:
|
||||||
notify_users = NOTIFY_USERS(body, v)
|
notify_users = NOTIFY_USERS(body, v)
|
||||||
|
|
||||||
if c.level == 1:
|
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:
|
for x in subscribers:
|
||||||
notify_users.add(x[0])
|
notify_users.add(x[0])
|
||||||
|
|
Loading…
Reference in New Issue