fdsfsd
This commit is contained in:
parent
1e9913d642
commit
da2af7f8fa
14 changed files with 80 additions and 78 deletions
|
@ -73,7 +73,7 @@ r=redis.Redis(host=environ.get("REDIS_URL", "redis://127.0.0.1"), decode_respon
|
||||||
limiter = Limiter(
|
limiter = Limiter(
|
||||||
app,
|
app,
|
||||||
key_func=get_ipaddr,
|
key_func=get_ipaddr,
|
||||||
default_limits=["50/minute"],
|
default_limits=["3/second;30/minute;100/hour"],
|
||||||
headers_enabled=True,
|
headers_enabled=True,
|
||||||
strategy="fixed-window"
|
strategy="fixed-window"
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,7 +7,7 @@ from sqlalchemy import *
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from files.__main__ import Base
|
from files.__main__ import Base
|
||||||
from files.classes.votes import CommentVote
|
from files.classes.votes import CommentVote
|
||||||
from files.helpers.const import AUTOPOLLER_ACCOUNT, censor_slurs
|
from files.helpers.const import AUTOPOLLER_ID, censor_slurs
|
||||||
from files.helpers.lazy import lazy
|
from files.helpers.lazy import lazy
|
||||||
from .flags import CommentFlag
|
from .flags import CommentFlag
|
||||||
from random import randint
|
from random import randint
|
||||||
|
@ -80,7 +80,7 @@ class Comment(Base):
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def options(self):
|
def options(self):
|
||||||
return [x for x in self.child_comments if x.author_id == AUTOPOLLER_ACCOUNT]
|
return [x for x in self.child_comments if x.author_id == AUTOPOLLER_ID]
|
||||||
|
|
||||||
def total_poll_voted(self, v):
|
def total_poll_voted(self, v):
|
||||||
if v:
|
if v:
|
||||||
|
@ -185,7 +185,7 @@ class Comment(Base):
|
||||||
def replies(self):
|
def replies(self):
|
||||||
r = self.__dict__.get("replies", None)
|
r = self.__dict__.get("replies", None)
|
||||||
if r: r = [x for x in r if not x.author.shadowbanned]
|
if r: r = [x for x in r if not x.author.shadowbanned]
|
||||||
if not r and r != []: r = sorted([x for x in self.child_comments if not x.author.shadowbanned and x.author_id != AUTOPOLLER_ACCOUNT], key=lambda x: x.score, reverse=True)
|
if not r and r != []: r = sorted([x for x in self.child_comments if not x.author.shadowbanned and x.author_id != AUTOPOLLER_ID], key=lambda x: x.score, reverse=True)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
@replies.setter
|
@replies.setter
|
||||||
|
@ -203,7 +203,7 @@ class Comment(Base):
|
||||||
@property
|
@property
|
||||||
def replies3(self):
|
def replies3(self):
|
||||||
r = self.__dict__.get("replies", None)
|
r = self.__dict__.get("replies", None)
|
||||||
if not r and r != []: r = sorted([x for x in self.child_comments if x.author_id != AUTOPOLLER_ACCOUNT], key=lambda x: x.score, reverse=True)
|
if not r and r != []: r = sorted([x for x in self.child_comments if x.author_id != AUTOPOLLER_ID], key=lambda x: x.score, reverse=True)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -7,7 +7,7 @@ from flask import render_template
|
||||||
from sqlalchemy import *
|
from sqlalchemy import *
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from files.__main__ import Base
|
from files.__main__ import Base
|
||||||
from files.helpers.const import AUTOPOLLER_ACCOUNT, censor_slurs, TROLLTITLES
|
from files.helpers.const import AUTOPOLLER_ID, censor_slurs, TROLLTITLES
|
||||||
from files.helpers.lazy import lazy
|
from files.helpers.lazy import lazy
|
||||||
from .flags import Flag
|
from .flags import Flag
|
||||||
from .comment import Comment
|
from .comment import Comment
|
||||||
|
@ -80,7 +80,7 @@ class Submission(Base):
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def options(self):
|
def options(self):
|
||||||
return g.db.query(Comment).filter_by(parent_submission = self.id, author_id = AUTOPOLLER_ACCOUNT, level=1)
|
return g.db.query(Comment).filter_by(parent_submission = self.id, author_id = AUTOPOLLER_ID, level=1)
|
||||||
|
|
||||||
def total_poll_voted(self, v):
|
def total_poll_voted(self, v):
|
||||||
if v:
|
if v:
|
||||||
|
|
|
@ -355,7 +355,7 @@ class User(Base):
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def post_notifications_count(self):
|
def post_notifications_count(self):
|
||||||
return g.db.query(Notification.id).join(Comment).filter(Notification.user_id == self.id, Notification.read == False, Comment.author_id == AUTOJANNY_ACCOUNT).count()
|
return g.db.query(Notification.id).join(Comment).filter(Notification.user_id == self.id, Notification.read == False, Comment.author_id == AUTOJANNY_ID).count()
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -463,7 +463,7 @@ class User(Base):
|
||||||
self.profileurl = None
|
self.profileurl = None
|
||||||
if self.discord_id: remove_user(self)
|
if self.discord_id: remove_user(self)
|
||||||
|
|
||||||
self.is_banned = admin.id if admin else AUTOJANNY_ACCOUNT
|
self.is_banned = admin.id if admin else AUTOJANNY_ID
|
||||||
if reason: self.ban_reason = reason
|
if reason: self.ban_reason = reason
|
||||||
|
|
||||||
g.db.add(self)
|
g.db.add(self)
|
||||||
|
|
|
@ -14,8 +14,8 @@ def send_notification(uid, text, autojanny=False):
|
||||||
|
|
||||||
text_html = sanitize(text_html)
|
text_html = sanitize(text_html)
|
||||||
|
|
||||||
if autojanny: author_id = AUTOJANNY_ACCOUNT
|
if autojanny: author_id = AUTOJANNY_ID
|
||||||
else: author_id = NOTIFICATIONS_ACCOUNT
|
else: author_id = NOTIFICATIONS_ID
|
||||||
|
|
||||||
new_comment = Comment(author_id=author_id,
|
new_comment = Comment(author_id=author_id,
|
||||||
parent_submission=None,
|
parent_submission=None,
|
||||||
|
@ -38,7 +38,7 @@ def send_follow_notif(vid, user, text):
|
||||||
text_html = CustomRenderer().render(mistletoe.Document(text))
|
text_html = CustomRenderer().render(mistletoe.Document(text))
|
||||||
text_html = sanitize(text_html)
|
text_html = sanitize(text_html)
|
||||||
|
|
||||||
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
|
new_comment = Comment(author_id=NOTIFICATIONS_ID,
|
||||||
parent_submission=None,
|
parent_submission=None,
|
||||||
distinguish_level=6,
|
distinguish_level=6,
|
||||||
body=text,
|
body=text,
|
||||||
|
@ -57,7 +57,7 @@ def send_unfollow_notif(vid, user, text):
|
||||||
text_html = CustomRenderer().render(mistletoe.Document(text))
|
text_html = CustomRenderer().render(mistletoe.Document(text))
|
||||||
text_html = sanitize(text_html)
|
text_html = sanitize(text_html)
|
||||||
|
|
||||||
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
|
new_comment = Comment(author_id=NOTIFICATIONS_ID,
|
||||||
parent_submission=None,
|
parent_submission=None,
|
||||||
distinguish_level=6,
|
distinguish_level=6,
|
||||||
body=text,
|
body=text,
|
||||||
|
@ -76,7 +76,7 @@ def send_block_notif(vid, user, text):
|
||||||
text_html = CustomRenderer().render(mistletoe.Document(text))
|
text_html = CustomRenderer().render(mistletoe.Document(text))
|
||||||
text_html = sanitize(text_html)
|
text_html = sanitize(text_html)
|
||||||
|
|
||||||
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
|
new_comment = Comment(author_id=NOTIFICATIONS_ID,
|
||||||
parent_submission=None,
|
parent_submission=None,
|
||||||
distinguish_level=6,
|
distinguish_level=6,
|
||||||
body=text,
|
body=text,
|
||||||
|
@ -95,7 +95,7 @@ def send_unblock_notif(vid, user, text):
|
||||||
text_html = CustomRenderer().render(mistletoe.Document(text))
|
text_html = CustomRenderer().render(mistletoe.Document(text))
|
||||||
text_html = sanitize(text_html)
|
text_html = sanitize(text_html)
|
||||||
|
|
||||||
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
|
new_comment = Comment(author_id=NOTIFICATIONS_ID,
|
||||||
parent_submission=None,
|
parent_submission=None,
|
||||||
distinguish_level=6,
|
distinguish_level=6,
|
||||||
body=text,
|
body=text,
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -997,14 +997,14 @@ def api_sticky_post(post_id, v):
|
||||||
if post.stickied:
|
if post.stickied:
|
||||||
if v.id != post.author_id:
|
if v.id != post.author_id:
|
||||||
message = f"@{v.username} has pinned your [post](/post/{post_id})!"
|
message = f"@{v.username} has pinned your [post](/post/{post_id})!"
|
||||||
existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first()
|
existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ID, Comment.body == message).first()
|
||||||
if not existing: send_notification(post.author_id, message)
|
if not existing: send_notification(post.author_id, message)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return {"message": "Post pinned!"}
|
return {"message": "Post pinned!"}
|
||||||
else:
|
else:
|
||||||
if v.id != post.author_id:
|
if v.id != post.author_id:
|
||||||
message = f"@{v.username} has unpinned your [post](/post/{post_id})!"
|
message = f"@{v.username} has unpinned your [post](/post/{post_id})!"
|
||||||
existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first()
|
existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ID, Comment.body == message).first()
|
||||||
if not existing: send_notification(post.author_id, message)
|
if not existing: send_notification(post.author_id, message)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return {"message": "Post unpinned!"}
|
return {"message": "Post unpinned!"}
|
||||||
|
|
|
@ -426,7 +426,7 @@ def award_post(pid, v):
|
||||||
author.ban_evade = 0
|
author.ban_evade = 0
|
||||||
send_notification(author.id, f"You have been unbanned!")
|
send_notification(author.id, f"You have been unbanned!")
|
||||||
elif kind == "grass":
|
elif kind == "grass":
|
||||||
author.is_banned = AUTOJANNY_ACCOUNT
|
author.is_banned = AUTOJANNY_ID
|
||||||
author.ban_reason = f"grass award used by @{v.username} on /post/{post.id}"
|
author.ban_reason = f"grass award used by @{v.username} on /post/{post.id}"
|
||||||
link = f"[this post]({post.permalink})"
|
link = f"[this post]({post.permalink})"
|
||||||
send_notification(author.id, f"Your account has been suspended permanently for {link}. You must [provide the admins](/contact) a timestamped picture of you touching grass to get unbanned!")
|
send_notification(author.id, f"Your account has been suspended permanently for {link}. You must [provide the admins](/contact) a timestamped picture of you touching grass to get unbanned!")
|
||||||
|
@ -548,7 +548,7 @@ def award_comment(cid, v):
|
||||||
author.ban_evade = 0
|
author.ban_evade = 0
|
||||||
send_notification(author.id, f"You have been unbanned!")
|
send_notification(author.id, f"You have been unbanned!")
|
||||||
elif kind == "grass":
|
elif kind == "grass":
|
||||||
author.is_banned = AUTOJANNY_ACCOUNT
|
author.is_banned = AUTOJANNY_ID
|
||||||
author.ban_reason = f"grass award used by @{v.username} on /comment/{c.id}"
|
author.ban_reason = f"grass award used by @{v.username} on /comment/{c.id}"
|
||||||
link = f"[this comment]({c.permalink})"
|
link = f"[this comment]({c.permalink})"
|
||||||
send_notification(author.id, f"Your account has been suspended permanently for {link}. You must [provide the admins](/contact) a timestamped picture of you touching grass to get unbanned!")
|
send_notification(author.id, f"Your account has been suspended permanently for {link}. You must [provide the admins](/contact) a timestamped picture of you touching grass to get unbanned!")
|
||||||
|
|
|
@ -96,7 +96,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None):
|
||||||
|
|
||||||
comments=comments.filter(
|
comments=comments.filter(
|
||||||
Comment.parent_submission == post.id,
|
Comment.parent_submission == post.id,
|
||||||
Comment.author_id != AUTOPOLLER_ACCOUNT
|
Comment.author_id != AUTOPOLLER_ID
|
||||||
).join(
|
).join(
|
||||||
votes,
|
votes,
|
||||||
votes.c.comment_id == Comment.id,
|
votes.c.comment_id == Comment.id,
|
||||||
|
@ -241,7 +241,7 @@ def api_comment(v):
|
||||||
comment.ban_reason = "AutoJanny"
|
comment.ban_reason = "AutoJanny"
|
||||||
g.db.add(comment)
|
g.db.add(comment)
|
||||||
ma=ModAction(
|
ma=ModAction(
|
||||||
user_id=AUTOJANNY_ACCOUNT,
|
user_id=AUTOJANNY_ID,
|
||||||
target_comment_id=comment.id,
|
target_comment_id=comment.id,
|
||||||
kind="ban_comment",
|
kind="ban_comment",
|
||||||
_note="spam"
|
_note="spam"
|
||||||
|
@ -268,7 +268,7 @@ def api_comment(v):
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
for option in options:
|
for option in options:
|
||||||
c_option = Comment(author_id=AUTOPOLLER_ACCOUNT,
|
c_option = Comment(author_id=AUTOPOLLER_ID,
|
||||||
parent_submission=parent_submission,
|
parent_submission=parent_submission,
|
||||||
parent_comment_id=c.id,
|
parent_comment_id=c.id,
|
||||||
level=level+1,
|
level=level+1,
|
||||||
|
@ -297,7 +297,7 @@ def api_comment(v):
|
||||||
|
|
||||||
body_based_html = sanitize(body_md)
|
body_based_html = sanitize(body_md)
|
||||||
|
|
||||||
c_based = Comment(author_id=BASEDBOT_ACCOUNT,
|
c_based = Comment(author_id=BASEDBOT_ID,
|
||||||
parent_submission=parent_submission,
|
parent_submission=parent_submission,
|
||||||
distinguish_level=6,
|
distinguish_level=6,
|
||||||
parent_comment_id=c.id,
|
parent_comment_id=c.id,
|
||||||
|
@ -328,7 +328,7 @@ def api_comment(v):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
c_jannied = Comment(author_id=AUTOJANNY_ID,
|
||||||
parent_submission=parent_submission,
|
parent_submission=parent_submission,
|
||||||
distinguish_level=6,
|
distinguish_level=6,
|
||||||
parent_comment_id=c.id,
|
parent_comment_id=c.id,
|
||||||
|
@ -361,7 +361,7 @@ def api_comment(v):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
c_jannied = Comment(author_id=AUTOJANNY_ID,
|
||||||
parent_submission=parent_submission,
|
parent_submission=parent_submission,
|
||||||
distinguish_level=6,
|
distinguish_level=6,
|
||||||
parent_comment_id=c.id,
|
parent_comment_id=c.id,
|
||||||
|
@ -396,7 +396,7 @@ def api_comment(v):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
c2 = Comment(author_id=LONGPOSTBOT_ACCOUNT,
|
c2 = Comment(author_id=LONGPOSTBOT_ID,
|
||||||
parent_submission=parent_submission,
|
parent_submission=parent_submission,
|
||||||
parent_comment_id=c.id,
|
parent_comment_id=c.id,
|
||||||
level=level+1,
|
level=level+1,
|
||||||
|
@ -406,7 +406,7 @@ def api_comment(v):
|
||||||
|
|
||||||
g.db.add(c2)
|
g.db.add(c2)
|
||||||
|
|
||||||
longpostbot = g.db.query(User).filter_by(id = LONGPOSTBOT_ACCOUNT).first()
|
longpostbot = g.db.query(User).filter_by(id = LONGPOSTBOT_ID).first()
|
||||||
longpostbot.comment_count += 1
|
longpostbot.comment_count += 1
|
||||||
longpostbot.coins += 1
|
longpostbot.coins += 1
|
||||||
g.db.add(longpostbot)
|
g.db.add(longpostbot)
|
||||||
|
@ -433,7 +433,7 @@ def api_comment(v):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
c2 = Comment(author_id=ZOZBOT_ACCOUNT,
|
c2 = Comment(author_id=ZOZBOT_ID,
|
||||||
parent_submission=parent_submission,
|
parent_submission=parent_submission,
|
||||||
parent_comment_id=c.id,
|
parent_comment_id=c.id,
|
||||||
level=level+1,
|
level=level+1,
|
||||||
|
@ -459,7 +459,7 @@ def api_comment(v):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
c3 = Comment(author_id=ZOZBOT_ACCOUNT,
|
c3 = Comment(author_id=ZOZBOT_ID,
|
||||||
parent_submission=parent_submission,
|
parent_submission=parent_submission,
|
||||||
parent_comment_id=c2.id,
|
parent_comment_id=c2.id,
|
||||||
level=level+2,
|
level=level+2,
|
||||||
|
@ -481,7 +481,7 @@ def api_comment(v):
|
||||||
body_html2 = sanitize(body_md)
|
body_html2 = sanitize(body_md)
|
||||||
|
|
||||||
|
|
||||||
c4 = Comment(author_id=ZOZBOT_ACCOUNT,
|
c4 = Comment(author_id=ZOZBOT_ID,
|
||||||
parent_submission=parent_submission,
|
parent_submission=parent_submission,
|
||||||
parent_comment_id=c3.id,
|
parent_comment_id=c3.id,
|
||||||
level=level+3,
|
level=level+3,
|
||||||
|
@ -491,7 +491,7 @@ def api_comment(v):
|
||||||
|
|
||||||
g.db.add(c4)
|
g.db.add(c4)
|
||||||
|
|
||||||
zozbot = g.db.query(User).filter_by(id = ZOZBOT_ACCOUNT).first()
|
zozbot = g.db.query(User).filter_by(id = ZOZBOT_ID).first()
|
||||||
zozbot.comment_count += 3
|
zozbot.comment_count += 3
|
||||||
zozbot.coins += 3
|
zozbot.coins += 3
|
||||||
g.db.add(zozbot)
|
g.db.add(zozbot)
|
||||||
|
@ -512,7 +512,7 @@ def api_comment(v):
|
||||||
|
|
||||||
for x in g.db.query(Subscription.user_id).filter_by(submission_id=c.parent_submission).all(): notify_users.add(x[0])
|
for x in g.db.query(Subscription.user_id).filter_by(submission_id=c.parent_submission).all(): notify_users.add(x[0])
|
||||||
|
|
||||||
if parent.author.id != v.id: notify_users.add(parent.author.id)
|
if parent.author.id not in [v.id, BASEDBOT_ID, AUTOJANNY_ID, SNAPPY_ID, LONGPOSTBOT_ID, ZOZBOT_ID, AUTOPOLLER_ID]: notify_users.add(parent.author.id)
|
||||||
|
|
||||||
soup = BeautifulSoup(body_html, features="html.parser")
|
soup = BeautifulSoup(body_html, features="html.parser")
|
||||||
mentions = soup.find_all("a", href=re.compile("^/@(\w+)"))
|
mentions = soup.find_all("a", href=re.compile("^/@(\w+)"))
|
||||||
|
@ -546,7 +546,7 @@ def api_comment(v):
|
||||||
'notification': {
|
'notification': {
|
||||||
'title': f'New reply by @{v.username}',
|
'title': f'New reply by @{v.username}',
|
||||||
'body': c.body,
|
'body': c.body,
|
||||||
'deep_link': f'http://{site}{c.permalink}?context=9&read=true#context',
|
'deep_link': f'http://{site}/comment/{c.id}?context=9&read=true#context',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -696,7 +696,7 @@ def edit_comment(cid, v):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
c_jannied = Comment(author_id=AUTOJANNY_ID,
|
||||||
parent_submission=c.parent_submission,
|
parent_submission=c.parent_submission,
|
||||||
distinguish_level=6,
|
distinguish_level=6,
|
||||||
parent_comment_id=c.id,
|
parent_comment_id=c.id,
|
||||||
|
@ -730,7 +730,7 @@ def edit_comment(cid, v):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
c_jannied = Comment(author_id=AUTOJANNY_ID,
|
||||||
parent_submission=c.parent_submission,
|
parent_submission=c.parent_submission,
|
||||||
distinguish_level=6,
|
distinguish_level=6,
|
||||||
parent_comment_id=c.id,
|
parent_comment_id=c.id,
|
||||||
|
@ -865,14 +865,14 @@ def toggle_pin_comment(cid, v):
|
||||||
if comment.is_pinned:
|
if comment.is_pinned:
|
||||||
if v.id != comment.author_id:
|
if v.id != comment.author_id:
|
||||||
message = f"@{v.username} has pinned your [comment]({comment.permalink})!"
|
message = f"@{v.username} has pinned your [comment]({comment.permalink})!"
|
||||||
existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first()
|
existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ID, Comment.body == message).first()
|
||||||
if not existing: send_notification(comment.author_id, message)
|
if not existing: send_notification(comment.author_id, message)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return {"message": "Comment pinned!"}
|
return {"message": "Comment pinned!"}
|
||||||
else:
|
else:
|
||||||
if v.id != comment.author_id:
|
if v.id != comment.author_id:
|
||||||
message = f"@{v.username} has unpinned your [comment]({comment.permalink})!"
|
message = f"@{v.username} has unpinned your [comment]({comment.permalink})!"
|
||||||
existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first()
|
existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ID, Comment.body == message).first()
|
||||||
if not existing: send_notification(comment.author_id, message)
|
if not existing: send_notification(comment.author_id, message)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return {"message": "Comment unpinned!"}
|
return {"message": "Comment unpinned!"}
|
||||||
|
|
|
@ -37,7 +37,7 @@ def notifications(v):
|
||||||
next_exists = (len(comments) > 25)
|
next_exists = (len(comments) > 25)
|
||||||
comments = comments[:25]
|
comments = comments[:25]
|
||||||
elif posts:
|
elif posts:
|
||||||
notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(101).all()
|
notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ID).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(101).all()
|
||||||
|
|
||||||
listing = []
|
listing = []
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ def notifications(v):
|
||||||
notifications = v.notifications.join(Notification.comment).filter(
|
notifications = v.notifications.join(Notification.comment).filter(
|
||||||
Comment.is_banned == False,
|
Comment.is_banned == False,
|
||||||
Comment.deleted_utc == 0,
|
Comment.deleted_utc == 0,
|
||||||
Comment.author_id != AUTOJANNY_ACCOUNT,
|
Comment.author_id != AUTOJANNY_ID,
|
||||||
).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26).all()
|
).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||||
|
|
||||||
next_exists = (len(notifications) > 25)
|
next_exists = (len(notifications) > 25)
|
||||||
|
|
|
@ -49,7 +49,7 @@ def request_api_keys(v):
|
||||||
|
|
||||||
g.db.add(new_app)
|
g.db.add(new_app)
|
||||||
|
|
||||||
send_admin(NOTIFICATIONS_ACCOUNT, f"{v.username} has requested API keys for `{request.values.get('name')}`. You can approve or deny the request [here](/admin/apps).")
|
send_admin(NOTIFICATIONS_ID, f"{v.username} has requested API keys for `{request.values.get('name')}`. You can approve or deny the request [here](/admin/apps).")
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ def post_id(pid, anything=None, v=None):
|
||||||
|
|
||||||
comments=comments.filter(
|
comments=comments.filter(
|
||||||
Comment.parent_submission == post.id,
|
Comment.parent_submission == post.id,
|
||||||
Comment.author_id != AUTOPOLLER_ACCOUNT,
|
Comment.author_id != AUTOPOLLER_ID,
|
||||||
).join(
|
).join(
|
||||||
votes,
|
votes,
|
||||||
votes.c.comment_id == Comment.id,
|
votes.c.comment_id == Comment.id,
|
||||||
|
@ -176,7 +176,7 @@ def post_id(pid, anything=None, v=None):
|
||||||
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]
|
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:
|
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_ACCOUNT)
|
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)
|
||||||
|
|
||||||
if sort == "new":
|
if sort == "new":
|
||||||
comments = comments.order_by(Comment.created_utc.desc())
|
comments = comments.order_by(Comment.created_utc.desc())
|
||||||
|
@ -271,7 +271,7 @@ def edit_post(pid, v):
|
||||||
body_jannied_html = sanitize(body_md)
|
body_jannied_html = sanitize(body_md)
|
||||||
|
|
||||||
|
|
||||||
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
c_jannied = Comment(author_id=AUTOJANNY_ID,
|
||||||
parent_submission=p.id,
|
parent_submission=p.id,
|
||||||
level=1,
|
level=1,
|
||||||
over_18=False,
|
over_18=False,
|
||||||
|
@ -303,7 +303,7 @@ def edit_post(pid, v):
|
||||||
|
|
||||||
body_jannied_html = sanitize(body_md)
|
body_jannied_html = sanitize(body_md)
|
||||||
|
|
||||||
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
c_jannied = Comment(author_id=AUTOJANNY_ID,
|
||||||
parent_submission=p.id,
|
parent_submission=p.id,
|
||||||
level=1,
|
level=1,
|
||||||
over_18=False,
|
over_18=False,
|
||||||
|
@ -338,7 +338,7 @@ def edit_post(pid, v):
|
||||||
if ('idio3' in f'{body_html}{title}'.lower() or 'idio ' in f'{body_html}{title}'.lower()) and 30 not in notify_users: notify_users.add(30)
|
if ('idio3' in f'{body_html}{title}'.lower() or 'idio ' in f'{body_html}{title}'.lower()) and 30 not in notify_users: notify_users.add(30)
|
||||||
|
|
||||||
for x in notify_users:
|
for x in notify_users:
|
||||||
existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message, Comment.notifiedto == x).first()
|
existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ID, Comment.body == message, Comment.notifiedto == x).first()
|
||||||
if not existing: send_notification(x, message)
|
if not existing: send_notification(x, message)
|
||||||
|
|
||||||
|
|
||||||
|
@ -650,7 +650,7 @@ def submit_post(v):
|
||||||
post.ban_reason = "AutoJanny"
|
post.ban_reason = "AutoJanny"
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
ma=ModAction(
|
ma=ModAction(
|
||||||
user_id=AUTOJANNY_ACCOUNT,
|
user_id=AUTOJANNY_ID,
|
||||||
target_submission_id=post.id,
|
target_submission_id=post.id,
|
||||||
kind="ban_post",
|
kind="ban_post",
|
||||||
_note="spam"
|
_note="spam"
|
||||||
|
@ -713,7 +713,7 @@ def submit_post(v):
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
for option in options:
|
for option in options:
|
||||||
c = Comment(author_id=AUTOPOLLER_ACCOUNT,
|
c = Comment(author_id=AUTOPOLLER_ID,
|
||||||
parent_submission=new_post.id,
|
parent_submission=new_post.id,
|
||||||
level=1,
|
level=1,
|
||||||
body_html=filter_title(option),
|
body_html=filter_title(option),
|
||||||
|
@ -812,7 +812,7 @@ def submit_post(v):
|
||||||
body_jannied_html = sanitize(body_md)
|
body_jannied_html = sanitize(body_md)
|
||||||
|
|
||||||
|
|
||||||
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
c_jannied = Comment(author_id=AUTOJANNY_ID,
|
||||||
parent_submission=new_post.id,
|
parent_submission=new_post.id,
|
||||||
level=1,
|
level=1,
|
||||||
over_18=False,
|
over_18=False,
|
||||||
|
@ -846,7 +846,7 @@ def submit_post(v):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
c_jannied = Comment(author_id=AUTOJANNY_ID,
|
||||||
parent_submission=new_post.id,
|
parent_submission=new_post.id,
|
||||||
level=1,
|
level=1,
|
||||||
over_18=False,
|
over_18=False,
|
||||||
|
@ -884,7 +884,7 @@ def submit_post(v):
|
||||||
if new_post.url:
|
if new_post.url:
|
||||||
if new_post.url.startswith('https://old.reddit.com/r/'):
|
if new_post.url.startswith('https://old.reddit.com/r/'):
|
||||||
rev = new_post.url.replace('https://old.reddit.com/', '')
|
rev = new_post.url.replace('https://old.reddit.com/', '')
|
||||||
rev = "* [reveddit.com](https://reveddit.com/{rev})\n"
|
rev = f"* [reveddit.com](https://reveddit.com/{rev})\n"
|
||||||
else: rev = ''
|
else: rev = ''
|
||||||
body += f"Snapshots:\n\n{rev}* [archive.org](https://web.archive.org/{new_post.url})\n* [archive.ph](https://archive.ph/?url={quote(new_post.url)}&run=1) (click to archive)\n\n"
|
body += f"Snapshots:\n\n{rev}* [archive.org](https://web.archive.org/{new_post.url})\n* [archive.ph](https://archive.ph/?url={quote(new_post.url)}&run=1) (click to archive)\n\n"
|
||||||
gevent.spawn(archiveorg, new_post.url)
|
gevent.spawn(archiveorg, new_post.url)
|
||||||
|
@ -898,7 +898,7 @@ def submit_post(v):
|
||||||
if "Snapshots:\n\n" not in body: body += "Snapshots:\n\n"
|
if "Snapshots:\n\n" not in body: body += "Snapshots:\n\n"
|
||||||
|
|
||||||
body += f'**[{title}]({href})**:\n\n'
|
body += f'**[{title}]({href})**:\n\n'
|
||||||
body += f'* [reveddit.com](https://reveddit.com/{href})\n'
|
body += f'* [reveddit.com](https://reveddit.com/{href.replace("https://old.reddit.com/", "")})\n'
|
||||||
body += f'* [archive.org](https://web.archive.org/{href})\n'
|
body += f'* [archive.org](https://web.archive.org/{href})\n'
|
||||||
body += f'* [archive.ph](https://archive.ph/?url={quote(href)}&run=1) (click to archive)\n\n'
|
body += f'* [archive.ph](https://archive.ph/?url={quote(href)}&run=1) (click to archive)\n\n'
|
||||||
gevent.spawn(archiveorg, href)
|
gevent.spawn(archiveorg, href)
|
||||||
|
@ -907,7 +907,7 @@ def submit_post(v):
|
||||||
body_html = sanitize(body_md)
|
body_html = sanitize(body_md)
|
||||||
|
|
||||||
if len(body_html) < 20000:
|
if len(body_html) < 20000:
|
||||||
c = Comment(author_id=SNAPPY_ACCOUNT,
|
c = Comment(author_id=SNAPPY_ID,
|
||||||
distinguish_level=6,
|
distinguish_level=6,
|
||||||
parent_submission=new_post.id,
|
parent_submission=new_post.id,
|
||||||
level=1,
|
level=1,
|
||||||
|
@ -919,7 +919,7 @@ def submit_post(v):
|
||||||
|
|
||||||
g.db.add(c)
|
g.db.add(c)
|
||||||
|
|
||||||
snappy = g.db.query(User).filter_by(id = SNAPPY_ACCOUNT).first()
|
snappy = g.db.query(User).filter_by(id = SNAPPY_ID).first()
|
||||||
snappy.comment_count += 1
|
snappy.comment_count += 1
|
||||||
snappy.coins += 1
|
snappy.coins += 1
|
||||||
g.db.add(snappy)
|
g.db.add(snappy)
|
||||||
|
|
|
@ -240,7 +240,7 @@ def settings_profile_post(v):
|
||||||
|
|
||||||
for x in notify_users:
|
for x in notify_users:
|
||||||
message = f"@{v.username} has added you to their friends list!"
|
message = f"@{v.username} has added you to their friends list!"
|
||||||
existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message, Comment.notifiedto == x).first()
|
existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ID, Comment.body == message, Comment.notifiedto == x).first()
|
||||||
if not existing: send_notification(x, message)
|
if not existing: send_notification(x, message)
|
||||||
|
|
||||||
v.friends = friends[:500]
|
v.friends = friends[:500]
|
||||||
|
@ -285,7 +285,7 @@ def settings_profile_post(v):
|
||||||
|
|
||||||
for x in notify_users:
|
for x in notify_users:
|
||||||
message = f"@{v.username} has added you to their enemies list!"
|
message = f"@{v.username} has added you to their enemies list!"
|
||||||
existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message, Comment.notifiedto == x).first()
|
existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ID, Comment.body == message, Comment.notifiedto == x).first()
|
||||||
if not existing: send_notification(x, message)
|
if not existing: send_notification(x, message)
|
||||||
|
|
||||||
v.enemies = enemies[:500]
|
v.enemies = enemies[:500]
|
||||||
|
@ -825,7 +825,7 @@ def settings_block_user(v):
|
||||||
if v.has_block(user):
|
if v.has_block(user):
|
||||||
return {"error": f"You have already blocked @{user.username}."}, 409
|
return {"error": f"You have already blocked @{user.username}."}, 409
|
||||||
|
|
||||||
if user.id == NOTIFICATIONS_ACCOUNT:
|
if user.id == NOTIFICATIONS_ID:
|
||||||
return {"error": "You can't block this user."}, 409
|
return {"error": "You can't block this user."}, 409
|
||||||
|
|
||||||
new_block = UserBlock(user_id=v.id,
|
new_block = UserBlock(user_id=v.id,
|
||||||
|
|
|
@ -255,7 +255,7 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="font-weight-bold"><a href="{{c.post.permalink}}">{{c.post.realtitle(v) | safe}}</a></span>
|
<span class="font-weight-bold"><a href="{{c.post.permalink}}">{{c.post.realtitle(v) | safe}}</a></span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% elif c.author_id==NOTIFICATIONS_ACCOUNT or c.author_id==AUTOJANNY_ACCOUNT %}
|
{% elif c.author_id==NOTIFICATIONS_ID or c.author_id==AUTOJANNY_ID %}
|
||||||
<span class="font-weight-bold">{{'SITE_NAME' | app_config}} Notification</span>
|
<span class="font-weight-bold">{{'SITE_NAME' | app_config}} Notification</span>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if c.sentto == 0 %}
|
{% if c.sentto == 0 %}
|
||||||
|
@ -347,7 +347,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
{% if not c.parent_submission and c.author_id!=NOTIFICATIONS_ACCOUNT and c.author_id!=AUTOJANNY_ACCOUNT and c.author_id!=v.id %}
|
{% if not c.parent_submission and c.author_id!=NOTIFICATIONS_ID and c.author_id!=AUTOJANNY_ID and c.author_id!=v.id %}
|
||||||
<a class="btn btn-primary" href="javascript:void(0)" onclick="document.getElementById('reply-m-{{c.id}}').classList.toggle('d-none')">Reply</a>
|
<a class="btn btn-primary" href="javascript:void(0)" onclick="document.getElementById('reply-m-{{c.id}}').classList.toggle('d-none')">Reply</a>
|
||||||
<pre></pre>
|
<pre></pre>
|
||||||
<div id="reply-m-{{c.id}}" class="d-none">
|
<div id="reply-m-{{c.id}}" class="d-none">
|
||||||
|
@ -579,7 +579,7 @@
|
||||||
</div>
|
</div>
|
||||||
{% elif replies %}
|
{% elif replies %}
|
||||||
<div id="morecomment-{{c.id}}" class="mt-2 more-comments text-small">
|
<div id="morecomment-{{c.id}}" class="mt-2 more-comments text-small">
|
||||||
<a {% if v %}href="{{c.shortlink}}#context"{% else %}href="/logged_out{{c.shortlink}}#context"{% endif %}>More comments <i class="fas fa-long-arrow-right ml-1"></i></a>
|
<a {% if v %}href="{{c.shortlink}}"{% else %}href="/logged_out{{c.shortlink}}"{% endif %}>More comments <i class="fas fa-long-arrow-right ml-1"></i></a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue