Merge branch 'master' into mistletoe

remotes/1693045480750635534/spooky-22
kek7198 2021-12-04 21:14:23 -06:00
commit 571aa045ac
5 changed files with 62 additions and 24 deletions

View File

@ -33,6 +33,7 @@ class Comment(Base):
is_approved = Column(Integer, default=0)
level = Column(Integer, default=0)
parent_comment_id = Column(Integer, ForeignKey("comments.id"))
top_comment_id = Column(Integer)
over_18 = Column(Boolean, default=False)
is_bot = Column(Boolean, default=False)
is_pinned = Column(String)

View File

@ -147,11 +147,14 @@ 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
else: abort(400)
body = request.values.get("body", "").strip()[:10000]
@ -276,6 +279,7 @@ 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=request.host == 'pcmemes.net' and v.id == 1578 or parent_post.over_18 or request.values.get("over_18","")=="true",
is_bot=is_bot,

View File

@ -116,6 +116,7 @@ def post_id(pid, anything=None, v=None):
if post.club and not (v and (v.paid_dues or v.id == post.author_id)) or post.private and not (v and v.id == post.author_id): abort(403)
pinned = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.is_pinned != None).all()
if v:
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
@ -134,10 +135,7 @@ def post_id(pid, anything=None, v=None):
if not (v and v.shadowbanned) and not (v and v.admin_level > 1):
comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None)
comments=comments.filter(
Comment.parent_submission == post.id,
Comment.author_id != AUTOPOLLER_ID,
).join(
comments=comments.filter(Comment.parent_submission == post.id, Comment.author_id != AUTOPOLLER_ID, Comment.is_pinned == None).join(
votes,
votes.c.comment_id == Comment.id,
isouter=True
@ -151,17 +149,6 @@ def post_id(pid, anything=None, v=None):
isouter=True
)
if sort == "new":
comments = comments.order_by(Comment.created_utc.desc())
elif sort == "old":
comments = comments.order_by(Comment.created_utc.asc())
elif sort == "controversial":
comments = comments.order_by(-1 * Comment.upvotes * Comment.downvotes * Comment.downvotes)
elif sort == "top":
comments = comments.order_by(-Comment.upvotes - Comment.downvotes)
elif sort == "bottom":
comments = comments.order_by(Comment.upvotes - Comment.downvotes)
output = []
for c in comments.all():
comment = c[0]
@ -169,11 +156,8 @@ def post_id(pid, anything=None, v=None):
comment.is_blocking = c[2] or 0
comment.is_blocked = c[3] or 0
output.append(comment)
post.replies = [x for x in output if x.is_pinned] + [x for x in output if x.level == 1 and not x.is_pinned]
else:
comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == post.id, Comment.author_id != AUTOPOLLER_ID)
comments = comments.filter(Comment.level == 1)
if sort == "new":
comments = comments.order_by(Comment.created_utc.desc())
@ -186,7 +170,42 @@ def post_id(pid, anything=None, v=None):
elif sort == "bottom":
comments = comments.order_by(Comment.upvotes - Comment.downvotes)
post.replies = comments.filter(Comment.is_pinned != None).all() + comments.filter(Comment.level == 1, Comment.is_pinned == None).all()
offset = int(request.values.get("offset", 0))
if offset: comments = comments.offset(offset)
comments = [c[0] for c in comments.all()]
else:
comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == post.id, Comment.author_id != AUTOPOLLER_ID, Comment.level == 1, Comment.is_pinned == None)
if sort == "new":
comments = comments.order_by(Comment.created_utc.desc())
elif sort == "old":
comments = comments.order_by(Comment.created_utc.asc())
elif sort == "controversial":
comments = comments.order_by(-1 * Comment.upvotes * Comment.downvotes * Comment.downvotes)
elif sort == "top":
comments = comments.order_by(-Comment.upvotes - Comment.downvotes)
elif sort == "bottom":
comments = comments.order_by(Comment.upvotes - Comment.downvotes)
offset = int(request.values.get("offset", 0))
if offset: comments = comments.offset(offset)
comments = comments.all()
if post.created_utc > 1638672040:
comments2 = []
count = 0
for comment in comments:
comments2.append(comment)
count += g.db.query(Comment.id).filter_by(parent_submission=post.id, top_comment_id=comment.id).count() + 1
offset += 1
if count > 50: break
if len(comments) == len(comments2): offset = None
comments = comments2
post.replies = pinned + comments
if request.host == 'rdrama.net' and pid in [BUG_THREAD, EMOJI_THREAD] and not request.values.get("sort"): post.replies = post.replies[:10]
@ -202,7 +221,7 @@ def post_id(pid, anything=None, v=None):
else:
if post.is_banned and not (v and (v.admin_level > 1 or post.author_id == v.id)): template = "submission_banned.html"
else: template = "submission.html"
return render_template(template, v=v, p=post, sort=sort, render_replies=True)
return render_template(template, v=v, p=post, sort=sort, render_replies=True, offset=offset)
@app.post("/edit_post/<pid>")

View File

@ -1 +1,13 @@
fdssdf
Hi Ill pretty this up eventually, but here are the rules: <br><br>
<h3>RULE 1</h3>No sexualizing minors even as a “joke.” There is zero tolerance for pedo shit here. Go to Reddit if you want that.<br><br>
<h3>RULE 2 </h3>No doxxing ANYONE. <br><br>
<h3>RULE 3 </h3>Using alts to game dramacoin will get you banned. <br><br>
<h3>RULE 4 </h3>Were all doing this for fun. Dont make this “not fun.” <br><br>
<h3>RULE 5 </h3>All rules can and likely will be ignored at admin discretion. Be funny, or at least compelling, and pretty much anything legal is fine.<br><br>
Okay I think thats all, thanks for reading! No one cares about your dumb <I>free speech</I> or whatever, go to Gab or something if you want to screech about amendments and stuff. Rules are not hard and fast, and janitorial abuse is inherent to the platform. So is ban evasion. Have fun or log out, both are easy!

View File

@ -266,7 +266,8 @@ CREATE TABLE public.comments (
body_html character varying(40000),
ban_reason character varying(25),
notifiedto integer,
realupvotes integer
realupvotes integer,
top_comment_id integer
);
@ -1710,6 +1711,7 @@ ALTER TABLE ONLY public.flags
ALTER TABLE ONLY public.notifications
ADD CONSTRAINT notifications_comment_id_fkey FOREIGN KEY (comment_id) REFERENCES public.comments(id);
--
-- PostgreSQL database dump complete
--