master
Aevann 2023-06-23 16:46:42 +03:00
parent e607c39d67
commit d9bed378a9
20 changed files with 120 additions and 104 deletions

View File

@ -72,7 +72,7 @@ def add_options(self, body, v):
if v:
if kind == 'post':
sub = self.sub
elif self.parent_submission:
elif self.parent_post:
sub = self.post.sub
else:
sub = None
@ -105,7 +105,7 @@ class Comment(Base):
id = Column(Integer, primary_key=True)
author_id = Column(Integer, ForeignKey("users.id"))
parent_submission = Column(Integer, ForeignKey("posts.id"))
parent_post = Column(Integer, ForeignKey("posts.id"))
wall_user_id = Column(Integer, ForeignKey("users.id"))
created_utc = Column(Integer)
edited_utc = Column(Integer, default=0)
@ -203,7 +203,7 @@ class Comment(Base):
@lazy
def parent_fullname(self):
if self.parent_comment_id: return f"c_{self.parent_comment_id}"
elif self.parent_submission: return f"p_{self.parent_submission}"
elif self.parent_post: return f"p_{self.parent_post}"
@lazy
def replies(self, sort, v):
@ -211,7 +211,7 @@ class Comment(Base):
return self.replies2
replies = g.db.query(Comment).filter_by(parent_comment_id=self.id).order_by(Comment.stickied, Comment.stickied_child_id)
if not self.parent_submission: sort='old'
if not self.parent_post: sort='old'
return sort_objects(sort, replies, Comment).all()
@ -337,7 +337,7 @@ class Comment(Base):
body = add_options(self, body, v)
if body:
if not (self.parent_submission and self.post.sub == 'chudrama'):
if not (self.parent_post and self.post.sub == 'chudrama'):
body = censor_slurs(body, v)
body = normalize_urls_runtime(body, v)
@ -371,7 +371,7 @@ class Comment(Base):
if not body: return ""
if not (self.parent_submission and self.post.sub == 'chudrama'):
if not (self.parent_post and self.post.sub == 'chudrama'):
body = censor_slurs(body, v).replace('<img loading="lazy" data-bs-toggle="tooltip" alt=":marseytrain:" title=":marseytrain:" src="/e/marseytrain.webp">', ':marseytrain:')
return body

View File

@ -66,7 +66,7 @@ class Post(Base):
approved_by = relationship("User", uselist=False, primaryjoin="Post.is_approved==User.id")
awards = relationship("AwardRelationship", order_by="AwardRelationship.awarded_utc.desc()", back_populates="post")
flags = relationship("Flag", order_by="Flag.created_utc")
comments = relationship("Comment", primaryjoin="Comment.parent_submission==Post.id", back_populates="post")
comments = relationship("Comment", primaryjoin="Comment.parent_post==Post.id", back_populates="post")
subr = relationship("Sub", primaryjoin="foreign(Post.sub)==remote(Sub.name)")
options = relationship("PostOption", order_by="PostOption.id")

View File

@ -698,7 +698,7 @@ class User(Base):
Notification.read == False,
Comment.sentto != None,
or_(Comment.author_id==self.id, Comment.sentto==self.id),
Comment.parent_submission == None,
Comment.parent_post == None,
)
if not self.can_see_shadowbanned:
@ -762,7 +762,7 @@ class User(Base):
Comment.created_utc > self.last_viewed_reddit_notifs,
Comment.is_banned == False, Comment.deleted_utc == 0,
Comment.body_html.like('%<p>New site mention%<a href="https://old.reddit.com/r/%'),
Comment.parent_submission == None, Comment.author_id == AUTOJANNY_ID).count()
Comment.parent_post == None, Comment.author_id == AUTOJANNY_ID).count()
@property
@lazy
@ -1040,7 +1040,7 @@ class User(Base):
if other.deleted_utc: return False
if other.author.shadowbanned and not (user and user.can_see_shadowbanned): return False
if isinstance(other, Comment):
if other.parent_submission and not cls.can_see(user, other.post): return False
if other.parent_post and not cls.can_see(user, other.post): return False
return True
@classmethod
@ -1063,7 +1063,7 @@ class User(Base):
if SITE == 'watchpeopledie.tv' and other.id == 5:
return False
else:
if other.parent_submission:
if other.parent_post:
return cls.can_see(user, other.post)
else:
if not user and not other.wall_user_id: return False

View File

@ -204,7 +204,7 @@ def execute_snappy(post:Post, v:User):
if len(body_html) < COMMENT_BODY_HTML_LENGTH_LIMIT:
c = Comment(author_id=SNAPPY_ID,
distinguish_level=6,
parent_submission=post.id,
parent_post=post.id,
level=1,
over_18=False,
is_bot=True,
@ -256,11 +256,11 @@ def execute_snappy(post:Post, v:User):
def execute_zozbot(c:Comment, level:int, post_target:post_target_type, v):
if SITE_NAME != 'rDrama': return
posting_to_submission = isinstance(post_target, Post)
posting_to_post = isinstance(post_target, Post)
if random.random() >= 0.001: return
c2 = Comment(author_id=ZOZBOT_ID,
parent_submission=post_target.id if posting_to_submission else None,
wall_user_id=post_target.id if not posting_to_submission else None,
parent_post=post_target.id if posting_to_post else None,
wall_user_id=post_target.id if not posting_to_post else None,
parent_comment_id=c.id,
level=level+1,
is_bot=True,
@ -277,8 +277,8 @@ def execute_zozbot(c:Comment, level:int, post_target:post_target_type, v):
g.db.add(n)
c3 = Comment(author_id=ZOZBOT_ID,
parent_submission=post_target.id if posting_to_submission else None,
wall_user_id=post_target.id if not posting_to_submission else None,
parent_post=post_target.id if posting_to_post else None,
wall_user_id=post_target.id if not posting_to_post else None,
parent_comment_id=c2.id,
level=level+2,
is_bot=True,
@ -294,8 +294,8 @@ def execute_zozbot(c:Comment, level:int, post_target:post_target_type, v):
c4 = Comment(author_id=ZOZBOT_ID,
parent_submission=post_target.id if posting_to_submission else None,
wall_user_id=post_target.id if not posting_to_submission else None,
parent_post=post_target.id if posting_to_post else None,
wall_user_id=post_target.id if not posting_to_post else None,
parent_comment_id=c3.id,
level=level+3,
is_bot=True,
@ -313,7 +313,7 @@ def execute_zozbot(c:Comment, level:int, post_target:post_target_type, v):
zozbot.pay_account('coins', 1)
g.db.add(zozbot)
if posting_to_submission:
if posting_to_post:
post_target.comment_count += 3
g.db.add(post_target)
@ -321,7 +321,7 @@ def execute_zozbot(c:Comment, level:int, post_target:post_target_type, v):
def execute_longpostbot(c:Comment, level:int, body, body_html, post_target:post_target_type, v:User):
if SITE_NAME != 'rDrama': return
posting_to_submission = isinstance(post_target, Post)
posting_to_post = isinstance(post_target, Post)
if not len(c.body.split()) >= 200: return
if "</blockquote>" in body_html: return
body = random.choice(LONGPOST_REPLIES)
@ -338,8 +338,8 @@ def execute_longpostbot(c:Comment, level:int, body, body_html, post_target:post_
body_html = sanitize(body)
c2 = Comment(author_id=LONGPOSTBOT_ID,
parent_submission=post_target.id if posting_to_submission else None,
wall_user_id=post_target.id if not posting_to_submission else None,
parent_post=post_target.id if posting_to_post else None,
wall_user_id=post_target.id if not posting_to_post else None,
parent_comment_id=c.id,
level=level+1,
is_bot=True,
@ -359,13 +359,13 @@ def execute_longpostbot(c:Comment, level:int, body, body_html, post_target:post_
n = Notification(comment_id=c2.id, user_id=v.id)
g.db.add(n)
if posting_to_submission:
if posting_to_post:
post_target.comment_count += 3
g.db.add(post_target)
push_notif({v.id}, f'New reply by @{c2.author_name}', c2.body, c2)
def execute_antispam_submission_check(title, v, url):
def execute_antispam_post_check(title, v, url):
now = int(time.time())
cutoff = now - 60 * 60 * 24

View File

@ -15,7 +15,7 @@ from .sanitize import *
def create_comment(text_html):
new_comment = Comment(author_id=AUTOJANNY_ID,
parent_submission=None,
parent_post=None,
body_html=text_html,
distinguish_level=6,
is_bot=True)
@ -32,7 +32,7 @@ def send_repeatable_notification(uid, text):
text_html = sanitize(text, blackjack="notification")
existing_comments = g.db.query(Comment.id).filter_by(author_id=AUTOJANNY_ID, parent_submission=None, body_html=text_html, is_bot=True).order_by(Comment.id).all()
existing_comments = g.db.query(Comment.id).filter_by(author_id=AUTOJANNY_ID, parent_post=None, body_html=text_html, is_bot=True).order_by(Comment.id).all()
for c in existing_comments:
existing_notif = g.db.query(Notification.user_id).filter_by(user_id=uid, comment_id=c.id).one_or_none()
@ -65,7 +65,7 @@ def notif_comment(text):
existing = g.db.query(Comment.id).filter(
Comment.author_id == AUTOJANNY_ID,
Comment.parent_submission == None,
Comment.parent_post == None,
Comment.body_html == text_html,
Comment.is_bot == True,
).order_by(Comment.id).all()
@ -96,7 +96,7 @@ def notif_comment2(p):
search_html = f'%</a> has mentioned you: <a href="/post/{p.id}"%'
existing = g.db.query(Comment.id).filter(Comment.author_id == AUTOJANNY_ID, Comment.parent_submission == None, Comment.body_html.like(search_html)).first()
existing = g.db.query(Comment.id).filter(Comment.author_id == AUTOJANNY_ID, Comment.parent_post == None, Comment.body_html.like(search_html)).first()
if existing: return existing[0], text
else:

View File

@ -107,13 +107,13 @@ def notify_mentions(mentions, send_to=None, mention_str='site mention'):
existing_comment = g.db.query(Comment.id).filter_by(
author_id=const.AUTOJANNY_ID,
parent_submission=None,
parent_post=None,
body_html=notif_text).one_or_none()
if existing_comment: break
new_comment = Comment(
author_id=const.AUTOJANNY_ID,
parent_submission=None,
parent_post=None,
body_html=notif_text,
distinguish_level=6)
g.db.add(new_comment)

View File

@ -138,7 +138,7 @@ url_re = build_url_re(tlds=TLDS, protocols=['http', 'https'])
def create_comment_duplicated(text_html):
new_comment = Comment(author_id=AUTOJANNY_ID,
parent_submission=None,
parent_post=None,
body_html=text_html,
distinguish_level=6,
is_bot=True)
@ -155,7 +155,7 @@ def send_repeatable_notification_duplicated(uid, text):
text_html = sanitize(text)
existing_comments = g.db.query(Comment.id).filter_by(author_id=AUTOJANNY_ID, parent_submission=None, body_html=text_html, is_bot=True).order_by(Comment.id).all()
existing_comments = g.db.query(Comment.id).filter_by(author_id=AUTOJANNY_ID, parent_post=None, body_html=text_html, is_bot=True).order_by(Comment.id).all()
for c in existing_comments:
existing_notif = g.db.query(Notification.user_id).filter_by(user_id=uid, comment_id=c.id).one_or_none()
@ -735,8 +735,8 @@ def complies_with_chud(obj):
if isinstance(obj, Post):
if obj.id in ADMIGGER_THREADS: return True
if obj.sub == "chudrama": return True
elif obj.parent_submission:
if obj.parent_submission in ADMIGGER_THREADS: return True
elif obj.parent_post:
if obj.parent_post in ADMIGGER_THREADS: return True
if obj.post.sub == "chudrama": return True
if obj.author.chud:

View File

@ -145,7 +145,7 @@ def award_thing(v, thing_type, id):
thing = get_post(id)
else:
thing = get_comment(id)
if not thing.parent_submission and not thing.wall_user_id: abort(404) # don't let users award messages
if not thing.parent_post and not thing.wall_user_id: abort(404) # don't let users award messages
if v.shadowbanned: abort(500)
author = thing.author

View File

@ -40,8 +40,8 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
g.db.add(notif)
g.db.flush()
if comment.parent_submission:
post = comment.parent_submission
if comment.parent_post:
post = comment.parent_post
else:
post = NOTIFICATION_THREAD
@ -125,7 +125,7 @@ def comment(v:User):
ghost = parent.ghost
elif parent_fullname.startswith("c_"):
parent = get_comment(id, v=v)
post_target = get_post(parent.parent_submission, v=v, graceful=True) or get_account(parent.wall_user_id, v=v, include_blocks=True)
post_target = get_post(parent.parent_post, v=v, graceful=True) or get_account(parent.wall_user_id, v=v, include_blocks=True)
parent_comment_id = parent.id
if parent.author_id == v.id: rts = True
if not v.can_post_in_ghost_threads and isinstance(post_target, Post) and post_target.ghost:
@ -135,7 +135,7 @@ def comment(v:User):
level = 1 if isinstance(parent, (Post, User)) else int(parent.level) + 1
parent_user = parent if isinstance(parent, User) else parent.author
posting_to_submission = isinstance(post_target, Post)
posting_to_post = isinstance(post_target, Post)
@ -146,7 +146,7 @@ def comment(v:User):
else:
abort(403, "You can't reply to deleted comments!")
if posting_to_submission:
if posting_to_post:
sub = post_target.sub
if sub and v.exiled_from(sub): abort(403, f"You're exiled from /h/{sub}")
if sub in {'furry','vampire','racist','femboy'} and not v.client and not v.house.lower().startswith(sub):
@ -156,7 +156,7 @@ def comment(v:User):
body = sanitize_raw_body(request.values.get("body", ""), False)
if not posting_to_submission or post_target.id not in ADMIGGER_THREADS:
if not posting_to_post or post_target.id not in ADMIGGER_THREADS:
if v.longpost and (len(body) < 280 or ' [](' in body or body.startswith('[](')):
abort(403, "You have to type more than 280 characters!")
elif v.bird and len(body) > 140:
@ -183,7 +183,7 @@ def comment(v:User):
file.save(oldname)
image = process_image(oldname, v)
if image == "": abort(400, "Image upload failed")
if posting_to_submission and v.admin_level >= PERMS['USE_ADMIGGER_THREADS']:
if posting_to_post and v.admin_level >= PERMS['USE_ADMIGGER_THREADS']:
def process_sidebar_or_banner(type, resize=0):
li = sorted(os.listdir(f'files/assets/images/{SITE_NAME}/{type}'),
key=lambda e: int(e.split('.webp')[0]))[-1]
@ -232,7 +232,7 @@ def comment(v:User):
body = body.replace('\n ', '\n')
body = body.strip()[:COMMENT_BODY_LENGTH_LIMIT]
if v.admin_level >= PERMS['USE_ADMIGGER_THREADS'] and posting_to_submission and post_target.id == SNAPPY_THREAD and level == 1 and body not in SNAPPY_QUOTES:
if v.admin_level >= PERMS['USE_ADMIGGER_THREADS'] and posting_to_post and post_target.id == SNAPPY_THREAD and level == 1 and body not in SNAPPY_QUOTES:
with open(f"snappy_{SITE_NAME}.txt", "a", encoding="utf-8") as f:
f.write('\n{[para]}\n' + body)
@ -247,8 +247,8 @@ def comment(v:User):
Comment.author_id == v.id,
Comment.deleted_utc == 0,
Comment.parent_comment_id == parent_comment_id,
Comment.parent_submission == post_target.id if posting_to_submission else None,
Comment.wall_user_id == post_target.id if not posting_to_submission else None,
Comment.parent_post == post_target.id if posting_to_post else None,
Comment.wall_user_id == post_target.id if not posting_to_post else None,
Comment.body_html == body_html
).first()
if existing: abort(409, f"You already made that comment: /comment/{existing.id}#context")
@ -256,7 +256,7 @@ def comment(v:User):
execute_antispam_comment_check(body, v)
execute_antispam_duplicate_comment_check(v, body_html)
if v.marseyawarded and posting_to_submission and post_target.id not in ADMIGGER_THREADS and marseyaward_body_regex.search(body_html):
if v.marseyawarded and posting_to_post and post_target.id not in ADMIGGER_THREADS and marseyaward_body_regex.search(body_html):
abort(403, "You can only type marseys!")
if len(body_html) > COMMENT_BODY_HTML_LENGTH_LIMIT:
@ -264,14 +264,14 @@ def comment(v:User):
is_bot = v.client is not None and v.id not in PRIVILEGED_USER_BOTS
chudded = v.chud and not (posting_to_submission and post_target.sub == 'chudrama')
chudded = v.chud and not (posting_to_post and post_target.sub == 'chudrama')
c = Comment(author_id=v.id,
parent_submission=post_target.id if posting_to_submission else None,
wall_user_id=post_target.id if not posting_to_submission else None,
parent_post=post_target.id if posting_to_post else None,
wall_user_id=post_target.id if not posting_to_post else None,
parent_comment_id=parent_comment_id,
level=level,
over_18=post_target.over_18 if posting_to_submission else False,
over_18=post_target.over_18 if posting_to_post else False,
is_bot=is_bot,
app_id=v.client.application.id if v.client else None,
body_html=body_html,
@ -301,8 +301,8 @@ def comment(v:User):
body_jannied_html = sanitize(body)
c_jannied = Comment(author_id=AUTOJANNY_ID,
parent_submission=post_target.id if posting_to_submission else None,
wall_user_id=post_target.id if not posting_to_submission else None,
parent_post=post_target.id if posting_to_post else None,
wall_user_id=post_target.id if not posting_to_post else None,
distinguish_level=6,
parent_comment_id=c.id,
level=level+1,
@ -316,7 +316,7 @@ def comment(v:User):
g.db.add(c_jannied)
g.db.flush()
if posting_to_submission:
if posting_to_post:
post_target.comment_count += 1
g.db.add(post_target)
@ -335,7 +335,7 @@ def comment(v:User):
else:
push_notif(notify_users, f'New mention of you by @{c.author_name}', c.body, c)
if c.level == 1 and posting_to_submission:
if c.level == 1 and posting_to_post:
subscriber_ids = [x[0] for x in g.db.query(Subscription.user_id).filter(Subscription.post_id == post_target.id, Subscription.user_id != v.id).all()]
notify_users.update(subscriber_ids)
@ -370,7 +370,7 @@ def comment(v:User):
v.comment_count = g.db.query(Comment).filter(
Comment.author_id == v.id,
or_(Comment.parent_submission != None, Comment.wall_user_id != None),
or_(Comment.parent_post != None, Comment.wall_user_id != None),
Comment.deleted_utc == 0
).count()
g.db.add(v)
@ -382,7 +382,7 @@ def comment(v:User):
# Increment post count iff not self-reply and not a spammy comment game
# Essentially a measure to make comment counts reflect "real" content
if (posting_to_submission and not rts and not c.slots_result):
if (posting_to_post and not rts and not c.slots_result):
post_target.comment_count += 1
g.db.add(post_target)
@ -395,8 +395,8 @@ def comment(v:User):
g.db.flush()
if SITE == 'watchpeopledie.tv' and c.parent_submission:
cache.delete(f'post_{c.parent_submission}')
if SITE == 'watchpeopledie.tv' and c.parent_post:
cache.delete(f'post_{c.parent_post}')
if v.client: return c.json
return {"comment": render_template("comments.html", v=v, comments=[c])}
@ -418,7 +418,7 @@ def delete_comment(cid, v):
v.comment_count = g.db.query(Comment).filter(
Comment.author_id == v.id,
or_(Comment.parent_submission != None, Comment.wall_user_id != None),
or_(Comment.parent_post != None, Comment.wall_user_id != None),
Comment.deleted_utc == 0
).count()
g.db.add(v)
@ -439,7 +439,7 @@ def undelete_comment(cid, v):
cache.delete_memoized(comment_idlist)
v.comment_count = g.db.query(Comment).filter(
Comment.author_id == v.id,
or_(Comment.parent_submission != None, Comment.wall_user_id != None),
or_(Comment.parent_post != None, Comment.wall_user_id != None),
Comment.deleted_utc == 0
).count()
g.db.add(v)
@ -607,7 +607,7 @@ def edit_comment(cid, v):
abort(403, "You can't edit comments older than 1 week!")
if c.author_id != v.id: abort(403)
if not c.parent_submission and not c.wall_user_id:
if not c.parent_post and not c.wall_user_id:
abort(403)
body = sanitize_raw_body(request.values.get("body", ""), False)

View File

@ -189,7 +189,7 @@ def comment_idlist(v=None, page=1, sort="new", t="day", gt=0, lt=0):
.outerjoin(Comment.post) \
.options(load_only(Comment.id)) \
.filter(
or_(Comment.parent_submission != None, Comment.wall_user_id != None),
or_(Comment.parent_post != None, Comment.wall_user_id != None),
)
if v.admin_level < PERMS['POST_COMMENT_MODERATION']:
@ -197,7 +197,7 @@ def comment_idlist(v=None, page=1, sort="new", t="day", gt=0, lt=0):
Comment.is_banned == False,
Comment.deleted_utc == 0,
Comment.author_id.notin_(v.userblocks),
or_(Comment.parent_submission == None, Post.private == False),
or_(Comment.parent_post == None, Post.private == False),
)
if gt: comments = comments.filter(Comment.created_utc > gt)

View File

@ -96,7 +96,7 @@ def notifications_messages(v:User):
message_threads = g.db.query(Comment).filter(
Comment.sentto != None,
or_(Comment.author_id == v.id, Comment.sentto == v.id),
Comment.parent_submission == None,
Comment.parent_post == None,
Comment.level == 1,
)
@ -258,7 +258,7 @@ def notifications_reddit(v:User):
listing = g.db.query(Comment).filter(
Comment.body_html.like('%<p>New site mention%<a href="https://old.reddit.com/r/%'),
Comment.parent_submission == None,
Comment.parent_post == None,
Comment.author_id == AUTOJANNY_ID
)
@ -342,7 +342,7 @@ def notifications(v:User):
if not n.read: c.unread = True
if c.parent_submission or c.wall_user_id:
if c.parent_post or c.wall_user_id:
all_items.append(c)
if c.replies2 == None:

View File

@ -73,7 +73,7 @@ def request_api_keys(v):
body_html = sanitize(body, blackjack="app description")
new_comment = Comment(author_id=AUTOJANNY_ID,
parent_submission=None,
parent_post=None,
level=1,
body_html=body_html,
sentto=MODMAIL_ID,

View File

@ -70,7 +70,7 @@ def vote_option_comment(option_id, v):
option = g.db.get(CommentOption, option_id)
if not option: abort(404)
if option.parent.parent_submission:
if option.parent.parent_post:
sub = option.parent.post.sub
else:
sub = None

View File

@ -109,7 +109,7 @@ def post_id(pid, anything=None, v=None, sub=None):
execute_shadowban_viewers_and_voters(v, p)
# shadowban check is done in sort_objects
# output is needed: see comments.py
comments, output = get_comments_v_properties(v, None, Comment.parent_submission == p.id, Comment.level < 10)
comments, output = get_comments_v_properties(v, None, Comment.parent_post == p.id, Comment.level < 10)
if sort == "hot":
pinned = [c[0] for c in comments.filter(Comment.stickied != None).order_by(Comment.created_utc.desc()).all()]
@ -119,7 +119,7 @@ def post_id(pid, anything=None, v=None, sub=None):
comments = sort_objects(sort, comments, Comment)
comments = [c[0] for c in comments.all()]
else:
comments = g.db.query(Comment).filter(Comment.parent_submission == p.id)
comments = g.db.query(Comment).filter(Comment.parent_post == p.id)
if sort == "hot":
pinned = comments.filter(Comment.stickied != None).order_by(Comment.created_utc.desc()).all()
@ -141,13 +141,13 @@ def post_id(pid, anything=None, v=None, sub=None):
for comment in comments:
comments2.append(comment)
ids.add(comment.id)
count += g.db.query(Comment).filter_by(parent_submission=p.id, top_comment_id=comment.id).count() + 1
count += g.db.query(Comment).filter_by(parent_post=p.id, top_comment_id=comment.id).count() + 1
if count > threshold: break
else:
for comment in comments:
comments2.append(comment)
ids.add(comment.id)
count += g.db.query(Comment).filter_by(parent_submission=p.id, parent_comment_id=comment.id).count() + 1
count += g.db.query(Comment).filter_by(parent_post=p.id, parent_comment_id=comment.id).count() + 1
if count > 20: break
if len(comments) == len(comments2): offset = 0
@ -203,14 +203,14 @@ def view_more(v, pid, sort, offset):
if v:
# shadowban check is done in sort_objects
# output is needed: see comments.py
comments, output = get_comments_v_properties(v, None, Comment.parent_submission == pid, Comment.stickied == None, Comment.id.notin_(ids), Comment.level < 10)
comments, output = get_comments_v_properties(v, None, Comment.parent_post == pid, Comment.stickied == None, Comment.id.notin_(ids), Comment.level < 10)
comments = comments.filter(Comment.level == 1)
comments = sort_objects(sort, comments, Comment)
comments = [c[0] for c in comments.all()]
else:
comments = g.db.query(Comment).filter(
Comment.parent_submission == pid,
Comment.parent_post == pid,
Comment.level == 1,
Comment.stickied == None,
Comment.id.notin_(ids)
@ -226,13 +226,13 @@ def view_more(v, pid, sort, offset):
for comment in comments:
comments2.append(comment)
ids.add(comment.id)
count += g.db.query(Comment).filter_by(parent_submission=p.id, top_comment_id=comment.id).count() + 1
count += g.db.query(Comment).filter_by(parent_post=p.id, top_comment_id=comment.id).count() + 1
if count > 100: break
else:
for comment in comments:
comments2.append(comment)
ids.add(comment.id)
count += g.db.query(Comment).filter_by(parent_submission=p.id, parent_comment_id=comment.id).count() + 1
count += g.db.query(Comment).filter_by(parent_post=p.id, parent_comment_id=comment.id).count() + 1
if count > 20: break
if len(comments) == len(comments2): offset = 0
@ -565,7 +565,7 @@ def submit_post(v:User, sub=None):
if dup:
return {"post_id": dup.id, "success": False}
if not execute_antispam_submission_check(title, v, url):
if not execute_antispam_post_check(title, v, url):
return redirect("/notifications")
if len(url) > 2048:
@ -684,7 +684,7 @@ def submit_post(v:User, sub=None):
c_jannied = Comment(author_id=AUTOJANNY_ID,
parent_submission=p.id,
parent_post=p.id,
level=1,
over_18=False,
is_bot=True,

View File

@ -199,7 +199,7 @@ def searchcomments(v:User):
comments = g.db.query(Comment).options(load_only(Comment.id)).outerjoin(Comment.post) \
.filter(
or_(Comment.parent_submission != None, Comment.wall_user_id != None),
or_(Comment.parent_post != None, Comment.wall_user_id != None),
Comment.author_id.notin_(v.userblocks),
)
@ -207,7 +207,7 @@ def searchcomments(v:User):
if 'post' in criteria:
try: post = int(criteria['post'])
except: abort(404)
comments = comments.filter(Comment.parent_submission == post)
comments = comments.filter(Comment.parent_post == post)
if 'author' in criteria:
@ -245,7 +245,7 @@ def searchcomments(v:User):
Comment.is_banned==False,
Comment.deleted_utc == 0,
or_(
Comment.parent_submission.notin_(private),
Comment.parent_post.notin_(private),
Comment.wall_user_id != None
)
)
@ -307,7 +307,7 @@ def searchmessages(v:User):
comments = g.db.query(Comment).options(load_only(Comment.id)) \
.filter(
Comment.sentto != None,
Comment.parent_submission == None,
Comment.parent_post == None,
or_(*dm_conditions),
)

View File

@ -269,7 +269,7 @@ def submit_contact(v):
execute_antispam_duplicate_comment_check(v, body_html)
new_comment = Comment(author_id=v.id,
parent_submission=None,
parent_post=None,
level=1,
body=body,
body_html=body_html,
@ -386,7 +386,7 @@ def transfers_id(id, v):
@auth_required
def transfers(v:User):
comments = g.db.query(Comment).filter(Comment.author_id == AUTOJANNY_ID, Comment.parent_submission == None, Comment.body_html.like("%</a> has transferred %"))
comments = g.db.query(Comment).filter(Comment.author_id == AUTOJANNY_ID, Comment.parent_post == None, Comment.body_html.like("%</a> has transferred %"))
page = get_page()

View File

@ -561,7 +561,7 @@ def message2(v:User, username:str):
if existing: abort(403, "Message already exists!")
c = Comment(author_id=v.id,
parent_submission=None,
parent_post=None,
level=1,
sentto=user.id,
body=body,
@ -638,7 +638,7 @@ def messagereply(v:User):
sentto = user_id
c = Comment(author_id=v.id,
parent_submission=None,
parent_post=None,
parent_comment_id=id,
top_comment_id=parent.top_comment_id,
level=parent.level + 1,
@ -1036,7 +1036,7 @@ def u_username_comments(username, v=None):
.outerjoin(comment_post_author, Post.author) \
.filter(
Comment.author_id == u.id,
or_(Comment.parent_submission != None, Comment.wall_user_id != None),
or_(Comment.parent_post != None, Comment.wall_user_id != None),
)
if not v or (v.id != u.id and v.admin_level < PERMS['POST_COMMENT_MODERATION']):

View File

@ -60,7 +60,7 @@ def vote_post_comment(target_id, new, v, cls, vote_cls):
target = get_post(target_id)
elif cls == Comment:
target = get_comment(target_id)
if not target.parent_submission and not target.wall_user_id: abort(404)
if not target.parent_post and not target.wall_user_id: abort(404)
else:
abort(404)

View File

@ -68,16 +68,16 @@
{% if standalone and level==1 %}
<div id="post-info-{{c.id}}" class="post-info mb-1 mr-2 {% if request.path.startswith('/notifications') %}mt-5{% elif request.path == '/search/messages' %}mt-6{% else %}mt-3{% endif %}">
{% if c.parent_submission and c.post.over_18 %}
{% if c.parent_post and c.post.over_18 %}
<span class="badge badge-danger text-small-extra mr-1">+18</span>
{% endif %}
<span class="align-top">
{% if c.parent_submission %}
{% if c.parent_post %}
{% if c.author_id==v.id and replies and is_notification_page %}
<span class="font-weight-bold">Comment {{'Replies' if (replies | length)>1 else 'Reply'}}: <a href="{{c.post.permalink}}">{{c.post.realtitle(v) | safe}}</a></span>
{% elif c.post.author_id==v.id and c.level == 1 and is_notification_page%}
<span class="font-weight-bold">Post Reply: <a href="{{c.post.permalink}}">{{c.post.realtitle(v) | safe}}</a></span>
{% elif is_notification_page and c.parent_submission in v.subscribed_idlist %}
{% elif is_notification_page and c.parent_post in v.subscribed_idlist %}
<span class="font-weight-bold">Subscribed Thread: <a href="{{c.post.permalink}}">{{c.post.realtitle(v) | safe}}</a></span>
{% elif is_notification_page %}
<span class="font-weight-bold">Username Mention: <a href="{{c.post.permalink}}">{{c.post.realtitle(v) | safe}}</a></span>
@ -128,7 +128,7 @@
<i class="{{a.class_list}} px-1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{a.title}} Award given by @{{a.user.username}}"></i>
{% endfor %}
{% if c.parent_submission %}
{% if c.parent_post %}
{% set sub = c.post.sub %}
{% if sub and c.author.exiled_from(sub) %}
<a><i class="fas fa-campfire text-danger" data-bs-toggle="tooltip" data-bs-placement="bottom" title="User has been exiled from /h/{{sub}}"></i></a>
@ -245,7 +245,7 @@
<div id="comment-text-{{c.id}}" class="comment-text mb-0 {% if c.chudded %}text-uppercase chud-img chud-{{c.id_last_num}}{% endif %} {% if c.author.rainbow %}rainbow-text{% endif %} {%if c.author.queen%}queen{%endif%}">
{{realbody | safe}}
</div>
{% if c.parent_submission or c.wall_user_id %}
{% if c.parent_post or c.wall_user_id %}
{% if v and v.id==c.author_id %}
@ -394,7 +394,7 @@
<button type="button" id="save-{{c.id}}" class="btn caction py-0 nobackground px-1 {% if c.id not in v.saved_comment_idlist %}d-md-inline-block{% endif %} text-muted d-none" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/save_comment/{{c.id}}','save-{{c.id}}','unsave-{{c.id}}','d-md-inline-block')"><i class="fas fa-save"></i>Save {% if c.num_savers %}<span data-bs-toggle="tooltip" data-bs-placement="bottom" title="Number of users who saved this comment">[{{c.num_savers}}]</span>{% endif %}</button>
{% endif %}
{% if c.parent_submission or c.wall_user_id %}
{% if c.parent_post or c.wall_user_id %}
{% if v and c.author_id == v.id %}
<button type="button" class="btn caction py-0 nobackground px-1 text-muted" data-nonce="{{g.nonce}}" data-onclick="toggleEdit('{{c.id}}')"><i class="fas fa-edit fa-fw"></i>Edit</button>
@ -425,7 +425,7 @@
<button type="button" id="block-{{c.id}}" class="dropdown-item list-inline-item text-danger {% if c.is_blocking %}d-none{% endif %}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/settings/block?username={{c.author_name}}','block-{{c.id}}','unblock-{{c.id}}','d-none')"><i class="fas fa-eye-slash text-danger"></i>Block user</button>
{% endif %}
{% if c.parent_submission %}
{% if c.parent_post %}
{% set url = "" %}
{% if v.admin_level >= PERMS['POST_COMMENT_MODERATION'] %}
@ -449,7 +449,7 @@
<button type="button" id="remove-{{c.id}}" class="dropdown-item list-inline-item d-none {% if not c.is_banned %}d-md-block{% endif %} text-danger" data-nonce="{{g.nonce}}" data-onclick="removeComment(this,'{{c.id}}','approve-{{c.id}}','remove-{{c.id}}','d-md-block')"><i class="fas fa-ban text-danger fa-fw"></i>Remove</button>
{% endif %}
{% if c.parent_submission %}
{% if c.parent_post %}
{% set sub = c.post.sub %}
{% if sub and v.mods(sub) and not c.author.mods(sub) %}
<button type="button" id="exile-{{c.id}}" class="d-none {% if not c.author.exiled_from(sub) %}d-md-block{% endif %} dropdown-item list-inline-item text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/exile/comment/{{c.id}}','exile-{{c.id}}','unexile-{{c.id}}','d-none')"><i class="fas fa-campfire text-danger fa-fw"></i>Exile user</button>
@ -462,7 +462,7 @@
<button type="button" id="unprogstack-{{c.id}}" class="dropdown-item list-inline-item d-none {% if c.is_approved == PROGSTACK_ID %}d-md-block{% endif %} text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/admin/unprogstack/comment/{{c.id}}','progstack-{{c.id}}','unprogstack-{{c.id}}','d-md-block')"><i class="fas fa-bullhorn text-danger fa-fw"></i>Remove Progressive Stack</button>
{% endif %}
{% if FEATURES['NSFW_MARKING'] and (c.parent_submission or c.wall_user_id) and (c.author_id==v.id or v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or (c.post.sub and v.mods(c.post.sub))) %}
{% if FEATURES['NSFW_MARKING'] and (c.parent_post or c.wall_user_id) and (c.author_id==v.id or v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or (c.post.sub and v.mods(c.post.sub))) %}
<button type="button" id="unmark-{{c.id}}" class="dropdown-item list-inline-item d-none {% if c.over_18 %}d-md-block{% endif %} text-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/toggle_comment_nsfw/{{c.id}}','mark-{{c.id}}','unmark-{{c.id}}','d-md-block')"><i class="fas fa-eye-evil text-success fa-fw"></i>Unmark +18</button>
<button type="button" id="mark-{{c.id}}" class="dropdown-item list-inline-item d-none {% if not c.over_18 %}d-md-block{% endif %} text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/toggle_comment_nsfw/{{c.id}}','mark-{{c.id}}','unmark-{{c.id}}','d-md-block')"><i class="fas fa-eye-evil text-danger fa-fw"></i>Mark +18</button>
{% endif %}
@ -491,7 +491,7 @@
<div autocomplete="off" class="markdown d-none border my-2 p-3 rounded" id="markdown-{{c.fullname}}" readonly>{{c.body.strip()}}</div>
{% endif %}
{% if c.parent_submission or c.wall_user_id %}
{% if c.parent_post or c.wall_user_id %}
{{macros.comment_reply_box(c.fullname, "reply-to-" + c.fullname, "d-none", "collapsed child", 'reply-to-' + c.fullname, true)}}
{% endif %}
@ -504,7 +504,7 @@
<div id="replies-of-{{c.fullname}}">
{% if request.path.startswith('/notifications') and replies|length > 8 %}
{% for reply in replies %}
{% if reply.parent_submission %}
{% if reply.parent_post %}
{% set collapse = reply.collapse %}
{% else %}
{% set collapse = not reply.unread and loop.index != replies|length %}
@ -521,7 +521,7 @@
{% endif %}
</div>
{% if request.path.startswith('/notifications') and c.level == 1 and c.sentto and not c.parent_submission and c.author_id != AUTOJANNY_ID %}
{% if request.path.startswith('/notifications') and c.level == 1 and c.sentto and not c.parent_post and c.author_id != AUTOJANNY_ID %}
{% if (v and v.admin_level >= PERMS['USER_BAN']) and (c.sentto == MODMAIL_ID) %}
<button type="button" class="btn btn-danger mt-2 mr-3 {% if c.author.is_muted %}d-none{% endif %}" id="mute-user-{{c.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/mute_user/{{c.author.id}}','mute-user-{{c.id}}','unmute-user-{{c.id}}','d-none')">Mute</button>
<button type="button" class="btn btn-primary mt-2 mr-3 {% if not c.author.is_muted %}d-none{% endif %}" id="unmute-user-{{c.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unmute_user/{{c.author.id}}','mute-user-{{c.id}}','unmute-user-{{c.id}}','d-none')">Unmute</button>
@ -616,7 +616,7 @@
{% endif %}
{% if v.admin_level < PERMS['POST_COMMENT_MODERATION'] %}
{% if c.parent_submission and v.id == c.post.author_id %}
{% if c.parent_post and v.id == c.post.author_id %}
<button type="button" id="pin2-{{c.id}}" class="list-group-item {% if c.stickied %}d-none{% endif %} text-info" data-bs-target="#actionsModal-{{c.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/pin_comment/{{c.id}}','pin2-{{c.id}}','unpin2-{{c.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-info mr-2"></i>Pin</button>
<button type="button" id="unpin2-{{c.id}}" class="list-group-item {% if not c.stickied %}d-none{% endif %} text-info" data-bs-target="#actionsModal-{{c.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unpin_comment/{{c.id}}','pin2-{{c.id}}','unpin2-{{c.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-info mr-2"></i>Unpin</button>
{% elif c.post.sub and v.mods(c.post.sub) %}
@ -625,7 +625,7 @@
{% endif %}
{% endif %}
{% if c.parent_submission %}
{% if c.parent_post %}
{% set sub = c.post.sub %}
{% if sub and v.mods(sub) and not c.author.mods(sub) %}
<button type="button" data-bs-dismiss="modal" id="exile2-{{c.id}}" class="{% if c.author.exiled_from(sub) %}d-none{% endif %} list-group-item text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/exile/comment/{{c.id}}','exile2-{{c.id}}','unexile2-{{c.id}}','d-none')"><i class="fas fa-campfire text-danger mr-2"></i>Exile user</button>
@ -656,7 +656,7 @@
</div>
<div class="modal-body">
<ul class="list-group comment-actions">
{% if c.parent_submission or c.wall_user_id %}
{% if c.parent_post or c.wall_user_id %}
{% if v.admin_level >= PERMS['APPS_MODERATION'] and c.oauth_app %}
<a href="{{c.oauth_app.permalink}}/comments" class="list-group-item text-info"><i class="fas fa-code text-info mr-2"></i>API App</a>
{% endif %}

View File

@ -0,0 +1,16 @@
alter table comments rename column parent_submission to parent_post;
alter index fki_save_relationship_submission_fkey rename to fki_save_relationship_post_fkey;
alter index fki_submission_sub_fkey rename to fki_post_sub_fkey;
alter index fki_submissions_approver_fkey rename to fki_post_approver_fkey;
alter index option_submission rename to option_post;
alter table award_relationships rename constraint award_submission_fkey to award_post_fkey;
alter table comments rename constraint comment_parent_submission_fkey to comment_parent_post_fkey;
alter table modactions rename constraint modactions_submission_fkey to modactions_post_fkey;
alter table post_options rename constraint option_submission_fkey to option_post_fkey;
alter table save_relationship rename constraint save_relationship_submission_fkey to save_relationship_post_fkey;
alter table subactions rename constraint subactions_submission_fkey to subactions_post_fkey;
alter table subscriptions rename constraint subscription_submission_fkey to subscription_post_fkey;
alter table post_option_votes rename constraint vote_submission_fkey to vote_post_fkey;
alter table votes rename constraint vote_submission_key to vote_post_key;