diff --git a/files/routes/comments.py b/files/routes/comments.py index a871e79b5..0ee88bae6 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -185,14 +185,11 @@ def api_comment(v): if parent_fullname.startswith("t2_"): parent = parent_post parent_comment_id = None - top_comment_id = None level = 1 elif parent_fullname.startswith("t3_"): parent = get_comment(parent_fullname.split("_")[1], v=v) parent_comment_id = parent.id level = parent.level + 1 - if level == 2: top_comment_id = parent.id - else: top_comment_id = parent.top_comment_id if parent.author_id == v.id: rts = True else: abort(400) @@ -397,7 +394,6 @@ def api_comment(v): c = Comment(author_id=v.id, parent_submission=parent_submission, parent_comment_id=parent_comment_id, - top_comment_id=top_comment_id, level=level, over_18=parent_post.over_18 or request.values.get("over_18")=="true", is_bot=is_bot, @@ -411,6 +407,9 @@ def api_comment(v): g.db.add(c) g.db.flush() + 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, diff --git a/files/routes/posts.py b/files/routes/posts.py index ce17adc5f..1cb8236e6 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -543,6 +543,8 @@ def edit_post(pid, v): g.db.add(c_jannied) g.db.flush() + c_jannied.top_comment_id = c_jannied.id + n = Notification(comment_id=c_jannied.id, user_id=v.id) g.db.add(n) @@ -725,6 +727,9 @@ def thumbnail_thread(pid): db.add(new_comment) db.flush() + new_comment.top_comment_id = new_comment.id + + admins = db.query(User).filter(User.admin_level > 0).all() for admin in admins: notif = Notification(comment_id=new_comment.id, user_id=admin.id) @@ -751,6 +756,9 @@ def thumbnail_thread(pid): db.add(new_comment) db.flush() + new_comment.top_comment_id = new_comment.id + + notif = Notification(comment_id=new_comment.id, user_id=val) db.add(notif) @@ -777,6 +785,9 @@ def thumbnail_thread(pid): db.add(new_comment) db.flush() + new_comment.top_comment_id = new_comment.id + + admins = db.query(User).filter(User.admin_level > 2).all() for admin in admins: notif = Notification(comment_id=new_comment.id, user_id=admin.id) @@ -1187,6 +1198,8 @@ def submit_post(v, sub=None): g.db.add(c_jannied) g.db.flush() + c_jannied.top_comment_id = c_jannied.id + n = Notification(comment_id=c_jannied.id, user_id=v.id) g.db.add(n) @@ -1282,6 +1295,9 @@ def submit_post(v, sub=None): check_for_slots_command(body, snappy, c) g.db.flush() + + c.top_comment_id = c.id + post.comment_count += 1 post.replies = [c]