From 775b378de2cf7a102a7c41301cf486c0c0f5ff58 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 21 Jan 2022 19:21:46 +0200 Subject: [PATCH] cxvcvx --- files/classes/mod_logs.py | 2 +- files/helpers/sanitize.py | 4 ++-- files/routes/users.py | 17 +++++++---------- files/templates/comments.html | 28 ++++++++++++++-------------- 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/files/classes/mod_logs.py b/files/classes/mod_logs.py index 59db52b3e0..ee9aa003db 100644 --- a/files/classes/mod_logs.py +++ b/files/classes/mod_logs.py @@ -92,7 +92,7 @@ class ModAction(Base): if self.target_user: return f'{self.target_user.username}' elif self.target_post: if self.target_post.club: return f'{CC} ONLY' - return f'{self.target_post.title.replace("<","").replace(">","")}' + return f'{self.target_post.title.replace("<","")}' elif self.target_comment_id: return f'comment' @property diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index d205648f46..a2868ccb6f 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -110,7 +110,7 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False): if u: sanitized = sanitized.replace(i.group(0), f'''

@{u.username}'s profile picture@{u.username}''', 1) else: - sanitized = re.sub('(^|\s|\n|

)\/?((r|u)\/\w{3,25})', r'\1\2', sanitized) + sanitized = re.sub('(^|\s|\n|

)\/?((r|u)\/(\w|-){3,25})', r'\1\2', sanitized) for i in re.finditer('(^|\s|\n|

)@((\w|-){1,25})', sanitized): u = get_user(i.group(2), graceful=True) @@ -268,7 +268,7 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False): def filter_emojis_only(title): - title = title.replace('<','').replace('>','').replace("\n", "").replace("\r", "").replace("\t", "").strip() + title = title.replace('<','').replace("\n", "").replace("\r", "").replace("\t", "").strip() title = bleach.clean(title, tags=[]) diff --git a/files/routes/users.py b/files/routes/users.py index 8aa09c0d22..3a5dcae3de 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -111,15 +111,15 @@ def downvoters(v, username): @app.get("/@/upvoting") @auth_required +@cache.memoize(timeout=3600) def upvoting(v, username): id = get_user(username).id votes = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote, Vote.submission_id==Submission.id).filter(Vote.vote_type==1, Vote.user_id==id).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).all() - # votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(CommentVote.vote_type==1, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all() + votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(CommentVote.vote_type==1, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all() - votes = Counter(dict(votes)) - # + Counter(dict(votes2)) + votes = Counter(dict(votes)) + Counter(dict(votes2)) users = g.db.query(User).filter(User.id.in_(votes.keys())).all() users2 = [] @@ -131,15 +131,15 @@ def upvoting(v, username): @app.get("/@/downvoting") @auth_required +@cache.memoize(timeout=3600) def downvoting(v, username): id = get_user(username).id votes = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote, Vote.submission_id==Submission.id).filter(Vote.vote_type==-1, Vote.user_id==id).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).all() - # votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(CommentVote.vote_type==-1, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all() + votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(CommentVote.vote_type==-1, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all() - votes = Counter(dict(votes)) - # + Counter(dict(votes2)) + votes = Counter(dict(votes)) + Counter(dict(votes2)) users = g.db.query(User).filter(User.id.in_(votes.keys())).all() users2 = [] @@ -778,12 +778,9 @@ def u_username_comments(username, v=None): if v and request.path.startswith('/logged_out'): v = None - - user = get_user(username, v=v) - - if username != user.username: return redirect(f'/id/{user.id}/comments') + if username != user.username: return redirect(f'/@{user.username}/comments') u = user diff --git a/files/templates/comments.html b/files/templates/comments.html index d39963fcab..7ab78d8bfe 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -267,16 +267,16 @@

- +   - +   - +   - +   - +