diff --git a/files/helpers/get.py b/files/helpers/get.py index 2fce1abf9..8a1f42f00 100644 --- a/files/helpers/get.py +++ b/files/helpers/get.py @@ -1,6 +1,5 @@ from files.classes import * from flask import g -from sqlalchemy.orm import joinedload def get_user(username, v=None, graceful=False): @@ -83,8 +82,6 @@ def get_post(i, v=None, graceful=False, **kwargs): blocking.c.id, ) - if v.admin_level>=4: - items=items.options(joinedload(Submission.oauth_app)) items=items.filter(Submission.id == i ).join( vt, @@ -214,7 +211,7 @@ def get_comments(cids, v=None, load_parent=False): if not (v and v.shadowbanned) and not (v and v.admin_level == 6): shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).all()] - comments = g.db.query(Comment).options(lazyload('*')).filter(Comment.author_id.notin_(shadowbanned)) + comments = comments.filter(Comment.author_id.notin_(shadowbanned)) comments = comments.join( votes, diff --git a/files/routes/comments.py b/files/routes/comments.py index 69c53d091..d7ffd2700 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -86,11 +86,8 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): if not (v and v.shadowbanned) and not (v and v.admin_level == 6): shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).all()] - comments = g.db.query(Comment).options(lazyload('*')).filter(Comment.author_id.notin_(shadowbanned)) - - if v.admin_level >=4: - comments=comments.options(joinedload(Comment.oauth_app)) - + comments = comments.filter(Comment.author_id.notin_(shadowbanned)) + comments=comments.filter( Comment.parent_submission == post.id ).join( diff --git a/files/routes/front.py b/files/routes/front.py index 818674cbb..e16e9b866 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -193,12 +193,9 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words=' for word in filter_words: posts=posts.filter(not_(Submission.title.ilike(f'%{word}%'))) - gt = kwargs.get("gt") - lt = kwargs.get("lt") - if not (v and v.shadowbanned): shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).all()] - posts = g.db.query(Submission).options(lazyload('*')).filter(Submission.author_id.notin_(shadowbanned)) + posts = posts.filter(Submission.author_id.notin_(shadowbanned)) if sort == "hot": ti = int(time.time()) + 3600 diff --git a/files/routes/oauth.py b/files/routes/oauth.py index f80e98a52..450e60b33 100644 --- a/files/routes/oauth.py +++ b/files/routes/oauth.py @@ -5,6 +5,7 @@ from files.helpers.const import * from files.classes import * from flask import * from files.__main__ import app +from sqlalchemy.orm import joinedload @app.get("/authorize") @auth_required diff --git a/files/routes/posts.py b/files/routes/posts.py index 5d373e7fd..03b81e69a 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -112,10 +112,6 @@ def post_id(pid, anything=None, v=None): blocked = v.blocked.subquery() - if not (v and v.shadowbanned) and not (v and v.admin_level == 6): - shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).all()] - comments = g.db.query(Comment).options(lazyload('*')).filter(Comment.author_id.notin_(shadowbanned)) - comments = g.db.query( Comment, votes.c.vote_type, @@ -126,9 +122,6 @@ def post_id(pid, anything=None, v=None): if not (v and v.shadowbanned) and not (v and v.admin_level == 6): shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).all()] comments = comments.filter(Comment.author_id.notin_(shadowbanned)) - - if v.admin_level >=4: - comments=comments.options(joinedload(Comment.oauth_app)) comments=comments.filter( Comment.parent_submission == post.id diff --git a/files/routes/votes.py b/files/routes/votes.py index eee45d731..8aba1347d 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -3,6 +3,7 @@ from files.helpers.get import * from files.classes import * from flask import * from files.__main__ import app +from sqlalchemy.orm import joinedload @app.get("/votes")