From e8afa57299333cfee45ef9e6cd4d4b08f5c7368f Mon Sep 17 00:00:00 2001 From: atrc445 Date: Thu, 16 Sep 2021 21:37:39 +0200 Subject: [PATCH 01/64] new awards query --- files/routes/awards.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/routes/awards.py b/files/routes/awards.py index 60d5607053..cff39b8689 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -191,7 +191,7 @@ def get_awards(v): user_awards = v.awards for val in return_value: - val['owned'] = len([x for x in user_awards if x.kind == val['kind'] and not x.given]) + val['owned'] = user_awards.filter_by(kind=val['kind'], submission_id=None, comment_id=None).count() return jsonify(return_value) From 57bf5867a60c9ce2d234dc25cac7b8b64b60872e Mon Sep 17 00:00:00 2001 From: atrc445 Date: Thu, 16 Sep 2021 22:18:03 +0200 Subject: [PATCH 02/64] fix dramacoin transfers why the fuck are there 3 duplicates of post_toast and who broke mine --- files/routes/users.py | 3 +-- files/templates/userpage.html | 15 +-------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/files/routes/users.py b/files/routes/users.py index 9ec611b2a9..1bf46edf34 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -131,13 +131,12 @@ def transfer_coins(v, username): receiver.coins += amount g.db.add(receiver) g.db.add(v) + g.db.commit() transfer_message = f"🤑 [@{v.username}]({v.url}) has gifted you {amount} {app.config['COINS_NAME']}!" send_notification(v.id, receiver, transfer_message) return {"message": f"{amount} {app.config['COINS_NAME']} transferred!"}, 200 - g.db.commit() - return {"message": f"{app.config['COINS_NAME']} transferred!"} diff --git a/files/templates/userpage.html b/files/templates/userpage.html index 01d37ea875..b1d060c637 100644 --- a/files/templates/userpage.html +++ b/files/templates/userpage.html @@ -62,20 +62,7 @@ t.disabled = true; post_toast("/@{{u.username}}/transfer_coins", - xhr => { - if(xhr.status == 200) { - fetch("/@{{u.username}}/coins") - .then(r => r.json()) - .then(m => { - document.getElementById("profile-coins-amount").innerText = m["coins"]; - document.getElementById("profile-coins-amount-mobile").innerText = m["coins"]; - }) - - fetch("/@{{v.username}}/coins") - .then(r => r.json()) - .then(m => document.getElementById(`user-coins-amount`).innerText = m["coins"]) - } - }, + false, {"amount": document.getElementById(mobile ? "coins-transfer-amount-mobile" : "coins-transfer-amount").value} ); From 15d67f266d64dfbc9b2da85c14260f5a3fc8fcbc Mon Sep 17 00:00:00 2001 From: atrc445 Date: Thu, 16 Sep 2021 22:29:40 +0200 Subject: [PATCH 03/64] fix (some) notifications --- files/helpers/alerts.py | 1 + 1 file changed, 1 insertion(+) diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index 3ef0684401..3cc1179158 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -41,6 +41,7 @@ def send_notification(vid, user, text, db=None): notif = Notification(comment_id=new_comment.id, user_id=uid) db.add(notif) + db.commit() def send_follow_notif(vid, user, text): From fd4c3dccc93e5ef9f50d65460dadad7eb6a83b6a Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Thu, 16 Sep 2021 21:06:30 +0000 Subject: [PATCH 04/64] lol im aevann now --- files/routes/giphy.py | 4 ++-- files/routes/users.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/files/routes/giphy.py b/files/routes/giphy.py index e81ae0d328..91df322464 100644 --- a/files/routes/giphy.py +++ b/files/routes/giphy.py @@ -9,7 +9,7 @@ GIPHY_KEY = environ.get('GIPHY_KEY').rstrip() @app.route("/giphy", methods=["GET"]) @app.route("/giphy", methods=["GET"]) -def giphy(): +def giphy(path=None): searchTerm = request.args.get("searchTerm", "") limit = int(request.args.get("limit", 48)) @@ -19,4 +19,4 @@ def giphy(): url = f"https://api.giphy.com/v1/gifs/search?q={searchTerm}&api_key={GIPHY_KEY}&limit=48" else: url = f"https://api.giphy.com/v1/gifs?api_key={GIPHY_KEY}&limit=48" - return jsonify(requests.get(url).json()) \ No newline at end of file + return jsonify(requests.get(url).json()) diff --git a/files/routes/users.py b/files/routes/users.py index 1bf46edf34..e6953040cb 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -134,7 +134,7 @@ def transfer_coins(v, username): g.db.commit() transfer_message = f"🤑 [@{v.username}]({v.url}) has gifted you {amount} {app.config['COINS_NAME']}!" - send_notification(v.id, receiver, transfer_message) + send_notification(NOTIFICATIONS_ACCOUNT, receiver, transfer_message) return {"message": f"{amount} {app.config['COINS_NAME']} transferred!"}, 200 return {"message": f"{app.config['COINS_NAME']} transferred!"} From c4b5faa6ee172c7cd418f0f55dfc4e8b6ae706dd Mon Sep 17 00:00:00 2001 From: Aevann1 <59999695+Aevann1@users.noreply.github.com> Date: Fri, 17 Sep 2021 07:59:45 +0200 Subject: [PATCH 05/64] Update users.py --- files/routes/users.py | 1 - 1 file changed, 1 deletion(-) diff --git a/files/routes/users.py b/files/routes/users.py index e6953040cb..cdd5144059 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -135,7 +135,6 @@ def transfer_coins(v, username): transfer_message = f"🤑 [@{v.username}]({v.url}) has gifted you {amount} {app.config['COINS_NAME']}!" send_notification(NOTIFICATIONS_ACCOUNT, receiver, transfer_message) - return {"message": f"{amount} {app.config['COINS_NAME']} transferred!"}, 200 return {"message": f"{app.config['COINS_NAME']} transferred!"} From 6eab67f27f9e31b8db65173ebc9bab582bfbc9c3 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 10:00:58 +0200 Subject: [PATCH 06/64] fd --- files/routes/front.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/files/routes/front.py b/files/routes/front.py index 91fbc264fb..be89770d87 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -32,6 +32,8 @@ def notifications(v): notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26).all() comments = [] + + t = time.time() notifs = [] for index, x in enumerate(notifications): @@ -44,6 +46,7 @@ def notifications(v): g.db.bulk_update_mappings(Notification, notifs) g.db.commit() + print(time.time() - t) next_exists = (len(comments) > 25) listing = comments[:25] From 507be101f774d4f2086dfb7ceb5a138b94e3c1ce Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 10:02:13 +0200 Subject: [PATCH 07/64] df --- files/routes/front.py | 101 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/files/routes/front.py b/files/routes/front.py index be89770d87..25602dd901 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -114,6 +114,107 @@ def notifications(v): is_notification_page=True) +@app.get("/notifications2") +@auth_required +def notifications2(v): + try: page = int(request.args.get('page', 1)) + except: page = 1 + messages = request.args.get('messages', False) + modmail = request.args.get('modmail', False) + posts = request.args.get('posts', False) + if modmail and v.admin_level == 6: + comments = g.db.query(Comment).filter(Comment.sentto==0).order_by(Comment.created_utc.desc()).offset(25*(page-1)).limit(26).all() + next_exists = (len(comments) > 25) + comments = comments[:25] + elif messages: + comments = g.db.query(Comment).filter(or_(Comment.author_id==v.id, Comment.sentto==v.id), Comment.parent_submission == None).order_by(Comment.created_utc.desc(), not_(Comment.child_comments.any())).offset(25*(page-1)).limit(26).all() + next_exists = (len(comments) > 25) + comments = comments[:25] + elif posts: + notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26).all() + + comments = [] + + t = time.time() + + for index, x in enumerate(notifications): + c = x.comment + if x.read and index > 26: break + elif not x.read: + c.unread = True + x.read = True + g.db.add(x) + comments.append(c) + + g.db.commit() + print(time.time() - t) + + next_exists = (len(comments) > 25) + listing = comments[:25] + else: + + notifications = v.notifications.join(Notification.comment).filter( + Comment.is_banned == False, + Comment.deleted_utc == 0, + Comment.author_id != AUTOJANNY_ACCOUNT, + ).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26).all() + + next_exists = (len(notifications) > 25) + notifications = notifications[:25] + cids = [x.comment_id for x in notifications] + comments = get_comments(cids, v=v, load_parent=True) + + notifs = [] + i = 0 + for x in notifications: + try: + if not x.read: comments[i].unread = True + except: continue + notifs.append({'id': x.id, 'read': True}) + i += 1 + + g.db.bulk_update_mappings(Notification, notifs) + g.db.commit() + + if not posts: + listing = [] + for c in comments: + c._is_blocked = False + c._is_blocking = False + if c.parent_submission and c.parent_comment and c.parent_comment.author_id == v.id: + c.replies = [] + while c.parent_comment and c.parent_comment.author_id == v.id: + parent = c.parent_comment + if c not in parent.replies2: + parent.replies2 = parent.replies2 + [c] + parent.replies = parent.replies2 + c = parent + if c not in listing: + listing.append(c) + c.replies = c.replies2 + elif c.parent_submission: + c.replies = [] + if c not in listing: + listing.append(c) + else: + if c.parent_comment: + while c.level > 1: + c = c.parent_comment + + if c not in listing: + listing.append(c) + + + return render_template("notifications.html", + v=v, + notifications=listing, + next_exists=next_exists, + page=page, + standalone=True, + render_replies=True, + is_notification_page=True) + + @cache.memoize(timeout=86400) def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='', **kwargs): From 1b2add8c30407b503c9d9ee1e7a5b55a739c23f5 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 10:07:41 +0200 Subject: [PATCH 08/64] fd --- files/__main__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/files/__main__.py b/files/__main__.py index 73aec42248..7f2c778060 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -84,7 +84,8 @@ _engine=create_engine( app.config['DATABASE_URL'], poolclass=QueuePool, pool_size=int(environ.get("PG_POOL_SIZE",10)), - pool_use_lifo=True + pool_use_lifo=True, + echo=True ) def retry(f): From fcfc755d367cdba7088101ef9d435122c253723c Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 10:11:05 +0200 Subject: [PATCH 09/64] fd --- files/routes/front.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/files/routes/front.py b/files/routes/front.py index 25602dd901..ec6ebbe0d7 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -12,6 +12,23 @@ def slash_post(): # this is a test +@app.get("/testing") +def testing(v): + notifications = g.db.query(Notification).all() + + comments = [] + + t = time.time() + + for x in notifications: + x.read = True + g.db.add(x) + + g.db.commit() + print(time.time() - t) + return "sex" + + @app.get("/notifications") @auth_required def notifications(v): From 3e0b665c52154c329a47304e0b181e812cb33e30 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 10:11:49 +0200 Subject: [PATCH 10/64] fd --- files/routes/front.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/routes/front.py b/files/routes/front.py index ec6ebbe0d7..b343731f7c 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -13,7 +13,7 @@ def slash_post(): # this is a test @app.get("/testing") -def testing(v): +def testing(): notifications = g.db.query(Notification).all() comments = [] From e19497501f69ca2662e330df46a2c373cda4966c Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 10:12:40 +0200 Subject: [PATCH 11/64] fd --- files/routes/front.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/files/routes/front.py b/files/routes/front.py index b343731f7c..5b79677dba 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -15,8 +15,6 @@ def slash_post(): @app.get("/testing") def testing(): notifications = g.db.query(Notification).all() - - comments = [] t = time.time() From bfa9f591dc97f2d0271f8eb5f3e6c303ec1b6a7c Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 10:13:45 +0200 Subject: [PATCH 12/64] fd --- files/routes/front.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/routes/front.py b/files/routes/front.py index 5b79677dba..6731b4afa3 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -14,7 +14,7 @@ def slash_post(): @app.get("/testing") def testing(): - notifications = g.db.query(Notification).all() + notifications = g.db.query(Notification) t = time.time() From 0c8c84cd9ab26b6ca21295d7f2480cbdf7d01622 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 10:14:10 +0200 Subject: [PATCH 13/64] fd --- files/routes/front.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/routes/front.py b/files/routes/front.py index 6731b4afa3..8def5d9b55 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -14,7 +14,7 @@ def slash_post(): @app.get("/testing") def testing(): - notifications = g.db.query(Notification) + notifications = g.db.query(Notification).limit(25) t = time.time() From 0c7e16854fcbf099f9bec5c96e9ad3d0a8f86527 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 10:18:59 +0200 Subject: [PATCH 14/64] fd --- files/routes/front.py | 130 ++---------------------------------------- 1 file changed, 4 insertions(+), 126 deletions(-) diff --git a/files/routes/front.py b/files/routes/front.py index 8def5d9b55..38711964b4 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -10,23 +10,6 @@ defaulttimefilter = environ.get("DEFAULT_TIME_FILTER", "all").strip() def slash_post(): return redirect("/") -# this is a test - -@app.get("/testing") -def testing(): - notifications = g.db.query(Notification).limit(25) - - t = time.time() - - for x in notifications: - x.read = True - g.db.add(x) - - g.db.commit() - print(time.time() - t) - return "sex" - - @app.get("/notifications") @auth_required def notifications(v): @@ -48,110 +31,6 @@ def notifications(v): comments = [] - t = time.time() - notifs = [] - - for index, x in enumerate(notifications): - c = x.comment - if x.read and index > 26: break - elif not x.read: - c.unread = True - notifs.append({'id': x.id, 'read': True}) - comments.append(c) - - g.db.bulk_update_mappings(Notification, notifs) - g.db.commit() - print(time.time() - t) - - next_exists = (len(comments) > 25) - listing = comments[:25] - else: - - notifications = v.notifications.join(Notification.comment).filter( - Comment.is_banned == False, - Comment.deleted_utc == 0, - Comment.author_id != AUTOJANNY_ACCOUNT, - ).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26).all() - - next_exists = (len(notifications) > 25) - notifications = notifications[:25] - cids = [x.comment_id for x in notifications] - comments = get_comments(cids, v=v, load_parent=True) - - notifs = [] - i = 0 - for x in notifications: - try: - if not x.read: comments[i].unread = True - except: continue - notifs.append({'id': x.id, 'read': True}) - i += 1 - - g.db.bulk_update_mappings(Notification, notifs) - g.db.commit() - - if not posts: - listing = [] - for c in comments: - c._is_blocked = False - c._is_blocking = False - if c.parent_submission and c.parent_comment and c.parent_comment.author_id == v.id: - c.replies = [] - while c.parent_comment and c.parent_comment.author_id == v.id: - parent = c.parent_comment - if c not in parent.replies2: - parent.replies2 = parent.replies2 + [c] - parent.replies = parent.replies2 - c = parent - if c not in listing: - listing.append(c) - c.replies = c.replies2 - elif c.parent_submission: - c.replies = [] - if c not in listing: - listing.append(c) - else: - if c.parent_comment: - while c.level > 1: - c = c.parent_comment - - if c not in listing: - listing.append(c) - - - return render_template("notifications.html", - v=v, - notifications=listing, - next_exists=next_exists, - page=page, - standalone=True, - render_replies=True, - is_notification_page=True) - - -@app.get("/notifications2") -@auth_required -def notifications2(v): - try: page = int(request.args.get('page', 1)) - except: page = 1 - messages = request.args.get('messages', False) - modmail = request.args.get('modmail', False) - posts = request.args.get('posts', False) - if modmail and v.admin_level == 6: - comments = g.db.query(Comment).filter(Comment.sentto==0).order_by(Comment.created_utc.desc()).offset(25*(page-1)).limit(26).all() - next_exists = (len(comments) > 25) - comments = comments[:25] - elif messages: - comments = g.db.query(Comment).filter(or_(Comment.author_id==v.id, Comment.sentto==v.id), Comment.parent_submission == None).order_by(Comment.created_utc.desc(), not_(Comment.child_comments.any())).offset(25*(page-1)).limit(26).all() - next_exists = (len(comments) > 25) - comments = comments[:25] - elif posts: - notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26).all() - - comments = [] - - t = time.time() - for index, x in enumerate(notifications): c = x.comment if x.read and index > 26: break @@ -162,7 +41,6 @@ def notifications2(v): comments.append(c) g.db.commit() - print(time.time() - t) next_exists = (len(comments) > 25) listing = comments[:25] @@ -179,16 +57,16 @@ def notifications2(v): cids = [x.comment_id for x in notifications] comments = get_comments(cids, v=v, load_parent=True) - notifs = [] i = 0 for x in notifications: try: - if not x.read: comments[i].unread = True + if not x.read: + comments[i].unread = True + x.read = True + g.db.add(x) except: continue - notifs.append({'id': x.id, 'read': True}) i += 1 - g.db.bulk_update_mappings(Notification, notifs) g.db.commit() if not posts: From 32f82c636479632a0cca16b4ff8f0b0b2cc7d90e Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 10:19:43 +0200 Subject: [PATCH 15/64] fd --- files/routes/front.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/routes/front.py b/files/routes/front.py index 38711964b4..8bc49d50bd 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -27,7 +27,7 @@ def notifications(v): next_exists = (len(comments) > 25) comments = comments[:25] elif posts: - notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26).all() + notifications = v.notifications.options(lazyload('*')).join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26).all() comments = [] @@ -46,7 +46,7 @@ def notifications(v): listing = comments[:25] else: - notifications = v.notifications.join(Notification.comment).filter( + notifications = v.notifications.options(lazyload('*')).join(Notification.comment).filter( Comment.is_banned == False, Comment.deleted_utc == 0, Comment.author_id != AUTOJANNY_ACCOUNT, From ce5cee35709265afd49678d3bd83ea8913fb7135 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 10:21:32 +0200 Subject: [PATCH 16/64] fd --- files/routes/front.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/files/routes/front.py b/files/routes/front.py index 8bc49d50bd..b520473161 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -10,6 +10,12 @@ defaulttimefilter = environ.get("DEFAULT_TIME_FILTER", "all").strip() def slash_post(): return redirect("/") +@app.get("/testing") +def testing(): + notifications = g.db.query(Notification).options(lazyload('*')).join(Notification.comment).limit(26) + notifications2 = g.db.query(Notification).join(Notification.comment).limit(26) + return "sex" + @app.get("/notifications") @auth_required def notifications(v): From d58aa86dd6d4bb9a5548e6239d2220ab1fb5513a Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 10:24:44 +0200 Subject: [PATCH 17/64] fd --- files/routes/front.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/files/routes/front.py b/files/routes/front.py index b520473161..ee87ea5b8e 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -12,8 +12,9 @@ def slash_post(): @app.get("/testing") def testing(): - notifications = g.db.query(Notification).options(lazyload('*')).join(Notification.comment).limit(26) - notifications2 = g.db.query(Notification).join(Notification.comment).limit(26) + notifications = g.db.query(Notification).options(lazyload('*')) + print("FUCK\nFUCK\nFUCK") + notifications2 = g.db.query(Notification) return "sex" @app.get("/notifications") From a60fa1d8ec588ffcef9f2f785b8b8f21c7699012 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 10:25:11 +0200 Subject: [PATCH 18/64] fd --- files/routes/front.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/routes/front.py b/files/routes/front.py index ee87ea5b8e..979fb0de57 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -12,9 +12,9 @@ def slash_post(): @app.get("/testing") def testing(): - notifications = g.db.query(Notification).options(lazyload('*')) + notifications = g.db.query(Notification).options(lazyload('*')).all() print("FUCK\nFUCK\nFUCK") - notifications2 = g.db.query(Notification) + notifications2 = g.db.query(Notification).all() return "sex" @app.get("/notifications") From 1aa81273d5fc57939a7a2284104775a0dd51e938 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 10:29:05 +0200 Subject: [PATCH 19/64] sfd --- files/classes/clients.py | 4 +-- files/classes/user.py | 30 ++++++++-------- files/helpers/alerts.py | 2 +- files/helpers/filters.py | 2 +- files/helpers/get.py | 30 ++++++++-------- files/helpers/wrappers.py | 8 ++--- files/mail/mail.py | 2 +- files/routes/admin.py | 72 +++++++++++++++++++-------------------- files/routes/awards.py | 12 +++---- files/routes/comments.py | 22 ++++++------ files/routes/discord.py | 2 +- files/routes/front.py | 18 +++++----- files/routes/login.py | 30 ++++++++-------- files/routes/oauth.py | 22 ++++++------ files/routes/posts.py | 32 ++++++++--------- files/routes/reporting.py | 8 ++--- files/routes/search.py | 4 +-- files/routes/settings.py | 12 +++---- files/routes/static.py | 32 ++++++++--------- files/routes/users.py | 32 ++++++++--------- files/routes/votes.py | 12 +++---- 21 files changed, 194 insertions(+), 194 deletions(-) diff --git a/files/classes/clients.py b/files/classes/clients.py index b1449e11be..0721e240ed 100644 --- a/files/classes/clients.py +++ b/files/classes/clients.py @@ -27,7 +27,7 @@ class OauthApp(Base, Stndrd): def idlist(self, page=1, **kwargs): - posts = g.db.query(Submission.id).options(lazyload('*')).filter_by(app_id=self.id) + posts = g.db.query(Submission.id).options(lazyload('*')).options(lazyload('*')).filter_by(app_id=self.id) posts=posts.order_by(Submission.created_utc.desc()) @@ -37,7 +37,7 @@ class OauthApp(Base, Stndrd): def comments_idlist(self, page=1, **kwargs): - posts = g.db.query(Comment.id).options(lazyload('*')).filter_by(app_id=self.id) + posts = g.db.query(Comment.id).options(lazyload('*')).options(lazyload('*')).filter_by(app_id=self.id) posts=posts.order_by(Comment.created_utc.desc()) diff --git a/files/classes/user.py b/files/classes/user.py index 453eef3710..254d49ea35 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -155,7 +155,7 @@ class User(Base, Stndrd, Age_times): def has_block(self, target): - return g.db.query(UserBlock).filter_by( + return g.db.query(UserBlock).options(lazyload('*')).filter_by( user_id=self.id, target_id=target.id).first() @property @@ -164,7 +164,7 @@ class User(Base, Stndrd, Age_times): def any_block_exists(self, other): - return g.db.query(UserBlock).filter( + return g.db.query(UserBlock).options(lazyload('*')).filter( or_(and_(UserBlock.user_id == self.id, UserBlock.target_id == other.id), and_( UserBlock.user_id == other.id, UserBlock.target_id == self.id))).first() @@ -187,7 +187,7 @@ class User(Base, Stndrd, Age_times): if self.shadowbanned and not (v and (v.admin_level >= 3 or v.id == self.id)): return [] - submissions = g.db.query(Submission).options(lazyload('*')).filter_by(author_id=self.id, is_pinned=False) + submissions = g.db.query(Submission).options(lazyload('*')).options(lazyload('*')).filter_by(author_id=self.id, is_pinned=False) if not (v and (v.admin_level >= 3 or v.id == self.id)): submissions = submissions.filter_by(deleted_utc=0, is_banned=False, private=False) @@ -233,7 +233,7 @@ class User(Base, Stndrd, Age_times): def banned_by(self): if not self.is_suspended: return None - return g.db.query(User).filter_by(id=self.is_banned).first() + return g.db.query(User).options(lazyload('*')).filter_by(id=self.is_banned).first() def has_badge(self, badgedef_id): return self.badges.filter_by(badge_id=badgedef_id).first() @@ -310,11 +310,11 @@ class User(Base, Stndrd, Age_times): awards = {} - posts_idlist = g.db.query(Submission.id).filter_by(author_id=self.id).subquery() - comments_idlist = g.db.query(Comment.id).filter_by(author_id=self.id).subquery() + posts_idlist = g.db.query(Submission.id).options(lazyload('*')).filter_by(author_id=self.id).subquery() + comments_idlist = g.db.query(Comment.id).options(lazyload('*')).filter_by(author_id=self.id).subquery() - post_awards = g.db.query(AwardRelationship).filter(AwardRelationship.submission_id.in_(posts_idlist)).all() - comment_awards = g.db.query(AwardRelationship).filter(AwardRelationship.comment_id.in_(comments_idlist)).all() + post_awards = g.db.query(AwardRelationship).options(lazyload('*')).filter(AwardRelationship.submission_id.in_(posts_idlist)).all() + comment_awards = g.db.query(AwardRelationship).options(lazyload('*')).filter(AwardRelationship.comment_id.in_(comments_idlist)).all() total_awards = post_awards + comment_awards @@ -345,7 +345,7 @@ class User(Base, Stndrd, Age_times): @lazy def alts(self): - subq = g.db.query(Alt).filter( + subq = g.db.query(Alt).options(lazyload('*')).filter( or_( Alt.user1 == self.id, Alt.user2 == self.id @@ -407,7 +407,7 @@ class User(Base, Stndrd, Age_times): def has_follower(self, user): - return g.db.query(Follow).filter_by(target_id=self.id, user_id=user.id).first() + return g.db.query(Follow).options(lazyload('*')).filter_by(target_id=self.id, user_id=user.id).first() @property def banner_url(self): @@ -511,16 +511,16 @@ class User(Base, Stndrd, Age_times): OauthApp.id.asc()).all()] def subscribed_idlist(self, page=1): - posts = g.db.query(Subscription.submission_id).filter_by(user_id=self.id).all() + posts = g.db.query(Subscription.submission_id).options(lazyload('*')).filter_by(user_id=self.id).all() return [x[0] for x in posts] def saved_idlist(self, page=1): - posts = g.db.query(Submission.id).options(lazyload('*')).filter_by(is_banned=False, + posts = g.db.query(Submission.id).options(lazyload('*')).options(lazyload('*')).filter_by(is_banned=False, deleted_utc=0 ) - saved = g.db.query(SaveRelationship.submission_id).filter(SaveRelationship.user_id == self.id).subquery() + saved = g.db.query(SaveRelationship.submission_id).options(lazyload('*')).filter(SaveRelationship.user_id == self.id).subquery() posts = posts.filter(Submission.id.in_(saved)) if self.admin_level == 0: @@ -542,9 +542,9 @@ class User(Base, Stndrd, Age_times): def saved_comment_idlist(self, page=1): - comments = g.db.query(Comment.id).options(lazyload('*')).filter_by(is_banned=False, deleted_utc=0) + comments = g.db.query(Comment.id).options(lazyload('*')).options(lazyload('*')).filter_by(is_banned=False, deleted_utc=0) - saved = g.db.query(SaveRelationship.submission_id).filter(SaveRelationship.user_id == self.id).subquery() + saved = g.db.query(SaveRelationship.submission_id).options(lazyload('*')).filter(SaveRelationship.user_id == self.id).subquery() comments = comments.filter(Comment.id.in_(saved)) if self.admin_level == 0: diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index 3cc1179158..bc81e63ca5 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -187,7 +187,7 @@ def send_admin(vid, text): new_aux = CommentAux(id=new_comment.id, body=text, body_html=text_html) g.db.add(new_aux) - admins = g.db.query(User).filter(User.admin_level > 0).all() + admins = g.db.query(User).options(lazyload('*')).filter(User.admin_level > 0).all() for admin in admins: notif = Notification(comment_id=new_comment.id, user_id=admin.id) g.db.add(notif) diff --git a/files/helpers/filters.py b/files/helpers/filters.py index c4c33cebe0..e4c1698f2c 100644 --- a/files/helpers/filters.py +++ b/files/helpers/filters.py @@ -30,7 +30,7 @@ def filter_comment_html(html_text): # search db for domain rules that prohibit commenting bans = [ - x for x in g.db.query(BannedDomain).filter(BannedDomain.domain.in_(list(domain_list))).all()] + x for x in g.db.query(BannedDomain).options(lazyload('*')).filter(BannedDomain.domain.in_(list(domain_list))).all()] if bans: return bans diff --git a/files/helpers/get.py b/files/helpers/get.py index 864832ee78..c0ecd46c8d 100644 --- a/files/helpers/get.py +++ b/files/helpers/get.py @@ -24,7 +24,7 @@ def get_user(username, v=None, graceful=False): return None if v: - block = g.db.query(UserBlock).filter( + block = g.db.query(UserBlock).options(lazyload('*')).filter( or_( and_( UserBlock.user_id == v.id, @@ -43,16 +43,16 @@ def get_user(username, v=None, graceful=False): def get_account(id, v=None): - user = g.db.query(User).filter_by(id = id).first() + user = g.db.query(User).options(lazyload('*')).filter_by(id = id).first() if not user: try: id = int(str(id), 36) except: abort(404) - user = g.db.query(User).filter_by(id = id).first() + user = g.db.query(User).options(lazyload('*')).filter_by(id = id).first() if not user: abort(404) if v: - block = g.db.query(UserBlock).filter( + block = g.db.query(UserBlock).options(lazyload('*')).filter( or_( and_( UserBlock.user_id == v.id, @@ -73,7 +73,7 @@ def get_account(id, v=None): def get_post(i, v=None, graceful=False, **kwargs): if v: - vt = g.db.query(Vote).filter_by( + vt = g.db.query(Vote).options(lazyload('*')).filter_by( user_id=v.id, submission_id=i).subquery() blocking = v.blocking.subquery() @@ -122,7 +122,7 @@ def get_posts(pids, v=None): pids=tuple(pids) if v: - vt = g.db.query(Vote).filter( + vt = g.db.query(Vote).options(lazyload('*')).filter( Vote.submission_id.in_(pids), Vote.user_id==v.id ).subquery() @@ -155,7 +155,7 @@ def get_posts(pids, v=None): output[i]._is_blocking = query[i][2] or 0 output[i]._is_blocked = query[i][3] or 0 else: - output = g.db.query(Submission,).filter(Submission.id.in_(pids)).all() + output = g.db.query(Submission,).options(lazyload('*')).filter(Submission.id.in_(pids)).all() return sorted(output, key=lambda x: pids.index(x.id)) @@ -163,11 +163,11 @@ def get_comment(i, v=None, graceful=False, **kwargs): if v: - comment=g.db.query(Comment).filter(Comment.id == i).first() + comment=g.db.query(Comment).options(lazyload('*')).filter(Comment.id == i).first() if not comment and not graceful: abort(404) - block = g.db.query(UserBlock).filter( + block = g.db.query(UserBlock).options(lazyload('*')).filter( or_( and_( UserBlock.user_id == v.id, @@ -179,14 +179,14 @@ def get_comment(i, v=None, graceful=False, **kwargs): ) ).first() - vts = g.db.query(CommentVote).filter_by(user_id=v.id, comment_id=comment.id) - vt = g.db.query(CommentVote).filter_by(user_id=v.id, comment_id=comment.id).first() + vts = g.db.query(CommentVote).options(lazyload('*')).filter_by(user_id=v.id, comment_id=comment.id) + vt = g.db.query(CommentVote).options(lazyload('*')).filter_by(user_id=v.id, comment_id=comment.id).first() comment._is_blocking = block and block.user_id == v.id comment._is_blocked = block and block.target_id == v.id comment.voted = vt.vote_type if vt else 0 else: - comment = g.db.query(Comment).filter(Comment.id == i).first() + comment = g.db.query(Comment).options(lazyload('*')).filter(Comment.id == i).first() if not comment and not graceful:abort(404) return comment @@ -199,7 +199,7 @@ def get_comments(cids, v=None, load_parent=False): cids=tuple(cids) if v: - votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery() + votes = g.db.query(CommentVote).options(lazyload('*')).filter_by(user_id=v.id).subquery() blocking = v.blocking.subquery() @@ -238,7 +238,7 @@ def get_comments(cids, v=None, load_parent=False): output.append(comment) else: - output = g.db.query(Comment).join(Comment.author).filter(Comment.id.in_(cids), User.shadowbanned == False).all() + output = g.db.query(Comment).join(Comment.author).options(lazyload('*')).filter(Comment.id.in_(cids), User.shadowbanned == False).all() if load_parent: parents = [x.parent_comment_id for x in output if x.parent_comment_id] @@ -263,7 +263,7 @@ def get_domain(s): domain_list = tuple(list(domain_list)) - doms = [x for x in g.db.query(BannedDomain).filter( + doms = [x for x in g.db.query(BannedDomain).options(lazyload('*')).filter( BannedDomain.domain.in_(domain_list)).all()] if not doms: diff --git a/files/helpers/wrappers.py b/files/helpers/wrappers.py index cdc0d670a3..507adee0cc 100644 --- a/files/helpers/wrappers.py +++ b/files/helpers/wrappers.py @@ -13,7 +13,7 @@ def get_logged_in_user(): token = request.headers.get("Authorization") if not token: return None - client = g.db.query(ClientAuth).filter(ClientAuth.access_token == token).first() + client = g.db.query(ClientAuth).options(lazyload('*')).filter(ClientAuth.access_token == token).first() x = (client.user, client) if client else (None, None) @@ -24,7 +24,7 @@ def get_logged_in_user(): nonce = session.get("login_nonce", 0) if not uid: x= (None, None) try: - if g.db: v = g.db.query(User).filter_by(id=uid).first() + if g.db: v = g.db.query(User).options(lazyload('*')).filter_by(id=uid).first() else: v = None except: v = None @@ -54,7 +54,7 @@ def check_ban_evade(v): v.ban(reason="ban evasion") send_notification(NOTIFICATIONS_ACCOUNT, v, "Your account has been permanently suspended for the following reason:\n\n> ban evasion") - for post in g.db.query(Submission).filter_by(author_id=v.id).all(): + for post in g.db.query(Submission).options(lazyload('*')).filter_by(author_id=v.id).all(): if post.is_banned: continue @@ -74,7 +74,7 @@ def check_ban_evade(v): g.db.flush() - for comment in g.db.query(Comment).filter_by(author_id=v.id).all(): + for comment in g.db.query(Comment).options(lazyload('*')).filter_by(author_id=v.id).all(): if comment.is_banned: continue diff --git a/files/mail/mail.py b/files/mail/mail.py index de70932255..f0ca51c209 100644 --- a/files/mail/mail.py +++ b/files/mail/mail.py @@ -79,7 +79,7 @@ def activate(v): if not validate_hash(f"{email}+{id}+{timestamp}", token): abort(403) - user = g.db.query(User).filter_by(id=id).first() + user = g.db.query(User).options(lazyload('*')).filter_by(id=id).first() if not user: abort(404) diff --git a/files/routes/admin.py b/files/routes/admin.py index dacb398588..12baabaecb 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -31,14 +31,14 @@ def revert_actions(v, username): user = get_user(username) if not user: abort(404) - items = g.db.query(Submission).options(lazyload('*')).filter_by(removed_by=user.id).all() + g.db.query(Comment).options(lazyload('*')).filter_by(removed_by=user.id).all() + items = g.db.query(Submission).options(lazyload('*')).options(lazyload('*')).filter_by(removed_by=user.id).all() + g.db.query(Comment).options(lazyload('*')).options(lazyload('*')).filter_by(removed_by=user.id).all() for item in items: item.is_banned = False item.removed_by = None g.db.add(item) - users = g.db.query(User).options(lazyload('*')).filter_by(is_banned=user.id).all() + users = g.db.query(User).options(lazyload('*')).options(lazyload('*')).filter_by(is_banned=user.id).all() for user in users: user.unban() @@ -144,7 +144,7 @@ def monthly(v): if 'pcm' in request.host or ('rdrama' in request.host and v.id in [1,12,28,29,747,995,1480]) or ('rdrama' not in request.host and 'pcm' not in request.host): thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id _awards = [] - for u in g.db.query(User).filter(User.patron > 0).all(): + for u in g.db.query(User).options(lazyload('*')).filter(User.patron > 0).all(): grant_awards = {} if u.patron == 1: @@ -224,7 +224,7 @@ def post_rules(v): @auth_required def shadowbanned(v): if not (v and v.admin_level == 6): abort(404) - users = [x for x in g.db.query(User).filter_by(shadowbanned = True).all()] + users = [x for x in g.db.query(User).options(lazyload('*')).filter_by(shadowbanned = True).all()] return render_template("banned.html", v=v, users=users) @@ -232,7 +232,7 @@ def shadowbanned(v): @auth_required def agendaposters(v): if not (v and v.admin_level == 6): abort(404) - users = [x for x in g.db.query(User).filter_by(agendaposter = True).all()] + users = [x for x in g.db.query(User).options(lazyload('*')).filter_by(agendaposter = True).all()] return render_template("banned.html", v=v, users=users) @@ -260,7 +260,7 @@ def reported_posts(v): page = max(1, int(request.args.get("page", 1))) - posts = g.db.query(Submission).filter_by( + posts = g.db.query(Submission).options(lazyload('*')).filter_by( is_approved=0, is_banned=False ).join(Submission.flags).order_by(Submission.id.desc()).offset(25 * (page - 1)).limit(26) @@ -352,7 +352,7 @@ def badge_grant_post(v): except: abort(400) if user.has_badge(badge_id): - g.db.query(Badge).filter_by(badge_id=badge_id, user_id=user.id,).delete() + g.db.query(Badge).options(lazyload('*')).filter_by(badge_id=badge_id, user_id=user.id,).delete() return redirect("/admin/badge_grant") new_badge = Badge(badge_id=badge_id, @@ -376,7 +376,7 @@ def badge_grant_post(v): send_notification(NOTIFICATIONS_ACCOUNT, user, text) if badge_id == 16 and user.has_badge(17): - g.db.query(Badge).filter_by(badge_id=17, user_id=user.id).delete() + g.db.query(Badge).options(lazyload('*')).filter_by(badge_id=17, user_id=user.id).delete() elif badge_id in [21,22,23,24,28]: user.patron = int(str(badge_id)[-1]) @@ -446,7 +446,7 @@ def users_list(v): page = int(request.args.get("page", 1)) - users = g.db.query(User).filter_by(is_banned=0 + users = g.db.query(User).options(lazyload('*')).filter_by(is_banned=0 ).order_by(User.created_utc.desc() ).offset(25 * (page - 1)).limit(26) @@ -597,7 +597,7 @@ def admin_removed(v): page = int(request.args.get("page", 1)) - ids = g.db.query(Submission.id).options(lazyload('*')).filter_by(is_banned=True).order_by( + ids = g.db.query(Submission.id).options(lazyload('*')).options(lazyload('*')).filter_by(is_banned=True).order_by( Submission.id.desc()).offset(25 * (page - 1)).limit(26).all() ids=[x[0] for x in ids] @@ -621,7 +621,7 @@ def admin_removed(v): def admin_image_purge(v): name = request.form.get("url") - image = g.db.query(Image).filter(Image.text == name).first() + image = g.db.query(Image).options(lazyload('*')).filter(Image.text == name).first() if image: requests.delete(f'https://api.imgur.com/3/image/{image.deletehash}', headers = {"Authorization": f"Client-ID {IMGUR_KEY}"}) headers = {"Authorization": f"Bearer {CF_KEY}", "Content-Type": "application/json"} @@ -663,7 +663,7 @@ def admin_image_ban(v): h = ''.join([str(d) for d in bindigits]) #check db for existing - badpic = g.db.query(BadPic).filter_by( + badpic = g.db.query(BadPic).options(lazyload('*')).filter_by( phash=h ).first() @@ -688,7 +688,7 @@ def admin_image_ban(v): @admin_level_required(6) @validate_formkey def agendaposter(user_id, v): - user = g.db.query(User).filter_by(id=user_id).first() + user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first() expiry = request.form.get("days", 0) if expiry: @@ -741,7 +741,7 @@ def agendaposter(user_id, v): @admin_level_required(6) @validate_formkey def shadowban(user_id, v): - user = g.db.query(User).filter_by(id=user_id).first() + user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first() if user.admin_level != 0: abort(403) user.shadowbanned = True g.db.add(user) @@ -766,7 +766,7 @@ def shadowban(user_id, v): @admin_level_required(6) @validate_formkey def unshadowban(user_id, v): - user = g.db.query(User).filter_by(id=user_id).first() + user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first() if user.admin_level != 0: abort(403) user.shadowbanned = False g.db.add(user) @@ -790,7 +790,7 @@ def unshadowban(user_id, v): @admin_level_required(6) @validate_formkey def verify(user_id, v): - user = g.db.query(User).filter_by(id=user_id).first() + user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first() user.verified = "Verified" g.db.add(user) g.db.commit() @@ -800,7 +800,7 @@ def verify(user_id, v): @admin_level_required(6) @validate_formkey def unverify(user_id, v): - user = g.db.query(User).filter_by(id=user_id).first() + user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first() user.verified = None g.db.add(user) g.db.commit() @@ -812,7 +812,7 @@ def unverify(user_id, v): @validate_formkey def admin_title_change(user_id, v): - user = g.db.query(User).filter_by(id=user_id).first() + user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first() if user.admin_level != 0: abort(403) @@ -821,7 +821,7 @@ def admin_title_change(user_id, v): user.customtitleplain=new_name new_name = sanitize(new_name) - user=g.db.query(User).with_for_update().options(lazyload('*')).filter_by(id=user.id).first() + user=g.db.query(User).with_for_update().options(lazyload('*')).options(lazyload('*')).filter_by(id=user.id).first() user.customtitle=new_name user.flairchanged = bool(request.form.get("locked")) g.db.add(user) @@ -845,7 +845,7 @@ def admin_title_change(user_id, v): @validate_formkey def ban_user(user_id, v): - user = g.db.query(User).filter_by(id=user_id).first() + user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first() if user.admin_level >= v.admin_level: abort(403) @@ -913,7 +913,7 @@ def ban_user(user_id, v): @validate_formkey def unban_user(user_id, v): - user = g.db.query(User).filter_by(id=user_id).first() + user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first() if not user: abort(400) @@ -947,7 +947,7 @@ def unban_user(user_id, v): @validate_formkey def ban_post(post_id, v): - post = g.db.query(Submission).filter_by(id=post_id).first() + post = g.db.query(Submission).options(lazyload('*')).filter_by(id=post_id).first() if not post: abort(400) @@ -988,7 +988,7 @@ def ban_post(post_id, v): @validate_formkey def unban_post(post_id, v): - post = g.db.query(Submission).filter_by(id=post_id).first() + post = g.db.query(Submission).options(lazyload('*')).filter_by(id=post_id).first() if not post: abort(400) @@ -1018,7 +1018,7 @@ def unban_post(post_id, v): @validate_formkey def api_distinguish_post(post_id, v): - post = g.db.query(Submission).filter_by(id=post_id).first() + post = g.db.query(Submission).options(lazyload('*')).filter_by(id=post_id).first() if not post: abort(404) @@ -1042,7 +1042,7 @@ def api_distinguish_post(post_id, v): @admin_level_required(3) def api_sticky_post(post_id, v): - post = g.db.query(Submission).filter_by(id=post_id).first() + post = g.db.query(Submission).options(lazyload('*')).filter_by(id=post_id).first() if post: post.stickied = not (post.stickied) g.db.add(post) @@ -1064,7 +1064,7 @@ def api_sticky_post(post_id, v): @auth_required def api_pin_post(post_id, v): - post = g.db.query(Submission).filter_by(id=post_id).first() + post = g.db.query(Submission).options(lazyload('*')).filter_by(id=post_id).first() if post: post.is_pinned = not (post.is_pinned) g.db.add(post) @@ -1077,7 +1077,7 @@ def api_pin_post(post_id, v): @admin_level_required(1) def api_ban_comment(c_id, v): - comment = g.db.query(Comment).filter_by(id=c_id).first() + comment = g.db.query(Comment).options(lazyload('*')).filter_by(id=c_id).first() if not comment: abort(404) @@ -1100,7 +1100,7 @@ def api_ban_comment(c_id, v): @admin_level_required(1) def api_unban_comment(c_id, v): - comment = g.db.query(Comment).filter_by(id=c_id).first() + comment = g.db.query(Comment).options(lazyload('*')).filter_by(id=c_id).first() if not comment: abort(404) g.db.add(comment) @@ -1172,7 +1172,7 @@ def admin_toggle_ban_domain(v): reason=request.form.get("reason", "").strip() - d = g.db.query(BannedDomain).filter_by(domain=domain).first() + d = g.db.query(BannedDomain).options(lazyload('*')).filter_by(domain=domain).first() if d: g.db.delete(d) else: d = BannedDomain(domain=domain, reason=reason) @@ -1190,14 +1190,14 @@ def admin_nuke_user(v): user=get_user(request.form.get("user")) - for post in g.db.query(Submission).filter_by(author_id=user.id).all(): + for post in g.db.query(Submission).options(lazyload('*')).filter_by(author_id=user.id).all(): if post.is_banned: continue post.is_banned=True g.db.add(post) - for comment in g.db.query(Comment).filter_by(author_id=user.id).all(): + for comment in g.db.query(Comment).options(lazyload('*')).filter_by(author_id=user.id).all(): if comment.is_banned: continue @@ -1222,14 +1222,14 @@ def admin_nunuke_user(v): user=get_user(request.form.get("user")) - for post in g.db.query(Submission).filter_by(author_id=user.id).all(): + for post in g.db.query(Submission).options(lazyload('*')).filter_by(author_id=user.id).all(): if not post.is_banned: continue post.is_banned=False g.db.add(post) - for comment in g.db.query(Comment).filter_by(author_id=user.id).all(): + for comment in g.db.query(Comment).options(lazyload('*')).filter_by(author_id=user.id).all(): if not comment.is_banned: continue @@ -1273,11 +1273,11 @@ def chart(v): daily_times = [time.strftime("%d", time.gmtime(day_cutoffs[i + 1])) for i in range(len(day_cutoffs) - 1)][2:][::-1] - daily_signups = [g.db.query(User).filter(User.created_utc < day_cutoffs[i], User.created_utc > day_cutoffs[i + 1]).count() for i in range(len(day_cutoffs) - 1)][2:][::-1] + daily_signups = [g.db.query(User).options(lazyload('*')).filter(User.created_utc < day_cutoffs[i], User.created_utc > day_cutoffs[i + 1]).count() for i in range(len(day_cutoffs) - 1)][2:][::-1] - post_stats = [g.db.query(Submission).filter(Submission.created_utc < day_cutoffs[i], Submission.created_utc > day_cutoffs[i + 1], Submission.is_banned == False).count() for i in range(len(day_cutoffs) - 1)][2:][::-1] + post_stats = [g.db.query(Submission).options(lazyload('*')).filter(Submission.created_utc < day_cutoffs[i], Submission.created_utc > day_cutoffs[i + 1], Submission.is_banned == False).count() for i in range(len(day_cutoffs) - 1)][2:][::-1] - comment_stats = [g.db.query(Comment).filter(Comment.created_utc < day_cutoffs[i], Comment.created_utc > day_cutoffs[i + 1],Comment.is_banned == False, Comment.author_id != 1).count() for i in range(len(day_cutoffs) - 1)][2:][::-1] + comment_stats = [g.db.query(Comment).options(lazyload('*')).filter(Comment.created_utc < day_cutoffs[i], Comment.created_utc > day_cutoffs[i + 1],Comment.is_banned == False, Comment.author_id != 1).count() for i in range(len(day_cutoffs) - 1)][2:][::-1] # create multiple charts signup_chart = plt.subplot2grid((20, 4), (0, 0), rowspan=5, colspan=4) diff --git a/files/routes/awards.py b/files/routes/awards.py index cff39b8689..9a6034194e 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -209,7 +209,7 @@ def award_post(pid, v): if kind not in AWARDS: return {"error": "That award doesn't exist."}, 404 - post_award = g.db.query(AwardRelationship).filter( + post_award = g.db.query(AwardRelationship).options(lazyload('*')).filter( and_( AwardRelationship.kind == kind, AwardRelationship.user_id == v.id, @@ -221,7 +221,7 @@ def award_post(pid, v): if not post_award: return {"error": "You don't have that award."}, 404 - post = g.db.query(Submission).filter_by(id=pid).first() + post = g.db.query(Submission).options(lazyload('*')).filter_by(id=pid).first() if not post or post.is_banned or post.deleted_utc > 0: return {"error": "That post doesn't exist or has been deleted or removed."}, 404 @@ -229,7 +229,7 @@ def award_post(pid, v): if post.author_id == v.id: return {"error": "You can't award yourself."}, 403 - existing_award = g.db.query(AwardRelationship).filter( + existing_award = g.db.query(AwardRelationship).options(lazyload('*')).filter( and_( AwardRelationship.submission_id == post.id, AwardRelationship.user_id == v.id, @@ -275,7 +275,7 @@ def award_comment(cid, v): if kind not in AWARDS: return {"error": "That award doesn't exist."}, 404 - comment_award = g.db.query(AwardRelationship).filter( + comment_award = g.db.query(AwardRelationship).options(lazyload('*')).filter( and_( AwardRelationship.kind == kind, AwardRelationship.user_id == v.id, @@ -287,7 +287,7 @@ def award_comment(cid, v): if not comment_award: return {"error": "You don't have that award."}, 404 - c = g.db.query(Comment).filter_by(id=cid).first() + c = g.db.query(Comment).options(lazyload('*')).filter_by(id=cid).first() if not c or c.is_banned or c.deleted_utc > 0: return {"error": "That comment doesn't exist or has been deleted or removed."}, 404 @@ -295,7 +295,7 @@ def award_comment(cid, v): if c.author_id == v.id: return {"error": "You can't award yourself."}, 403 - existing_award = g.db.query(AwardRelationship).filter( + existing_award = g.db.query(AwardRelationship).options(lazyload('*')).filter( and_( AwardRelationship.comment_id == c.id, AwardRelationship.user_id == v.id, diff --git a/files/routes/comments.py b/files/routes/comments.py index 7deb489b9b..c5fd329a2c 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -82,7 +82,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): post.replies=[top_comment] if v: - votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery() + votes = g.db.query(CommentVote).options(lazyload('*')).filter_by(user_id=v.id).subquery() blocking = v.blocking.subquery() @@ -184,7 +184,7 @@ def api_comment(v): return {"error": reason}, 401 # check existing - existing = g.db.query(Comment).join(CommentAux).filter(Comment.author_id == v.id, + existing = g.db.query(Comment).join(CommentAux).options(lazyload('*')).filter(Comment.author_id == v.id, Comment.deleted_utc == 0, Comment.parent_comment_id == parent_comment_id, Comment.parent_submission == parent_submission, @@ -260,7 +260,7 @@ def api_comment(v): fragment='') check_url = urlunparse(check_url) - badlink = g.db.query(BadLink).filter( + badlink = g.db.query(BadLink).options(lazyload('*')).filter( literal(check_url).contains( BadLink.link)).first() @@ -527,7 +527,7 @@ def api_comment(v): # queue up notification for parent author notify_users = set() - for x in g.db.query(Subscription.user_id).filter_by(submission_id=c.parent_submission).all(): + for x in g.db.query(Subscription.user_id).options(lazyload('*')).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) @@ -537,7 +537,7 @@ def api_comment(v): for mention in mentions: username = mention["href"].split("@")[1] - user = g.db.query(User).filter_by(username=username).first() + user = g.db.query(User).options(lazyload('*')).filter_by(username=username).first() if user: if v.any_block_exists(user): @@ -581,7 +581,7 @@ def api_comment(v): v.comment_count = v.comments.filter(Comment.parent_submission != None).filter_by(is_banned=False, deleted_utc=0).count() g.db.add(v) - parent_post.comment_count = g.db.query(Comment).filter_by(parent_submission=parent_post.id).count() + parent_post.comment_count = g.db.query(Comment).options(lazyload('*')).filter_by(parent_submission=parent_post.id).count() g.db.add(parent_post) g.db.commit() @@ -650,7 +650,7 @@ def edit_comment(cid, v): fragment='') check_url = urlunparse(check_url) - badlink = g.db.query(BadLink).filter( + badlink = g.db.query(BadLink).options(lazyload('*')).filter( literal(check_url).contains( BadLink.link)).first() @@ -795,7 +795,7 @@ def edit_comment(cid, v): for mention in mentions: username = mention["href"].split("@")[1] - user = g.db.query(User).filter_by(username=username).first() + user = g.db.query(User).options(lazyload('*')).filter_by(username=username).first() if user: if v.any_block_exists(user): @@ -819,7 +819,7 @@ def edit_comment(cid, v): @validate_formkey def delete_comment(cid, v): - c = g.db.query(Comment).filter_by(id=cid).first() + c = g.db.query(Comment).options(lazyload('*')).filter_by(id=cid).first() if not c: abort(404) @@ -842,7 +842,7 @@ def delete_comment(cid, v): @validate_formkey def undelete_comment(cid, v): - c = g.db.query(Comment).filter_by(id=cid).first() + c = g.db.query(Comment).options(lazyload('*')).filter_by(id=cid).first() if not c: abort(404) @@ -912,7 +912,7 @@ def unsave_comment(cid, v): comment=get_comment(cid) - save=g.db.query(SaveRelationship).filter_by(user_id=v.id, submission_id=comment.id, type=2).first() + save=g.db.query(SaveRelationship).options(lazyload('*')).filter_by(user_id=v.id, submission_id=comment.id, type=2).first() if save: g.db.delete(save) diff --git a/files/routes/discord.py b/files/routes/discord.py index 5246274e94..3a0f20071f 100644 --- a/files/routes/discord.py +++ b/files/routes/discord.py @@ -97,7 +97,7 @@ def discord_redirect(v): url=f"https://discord.com/api/guilds/{SERVER_ID}/members/{v.discord_id}" requests.delete(url, headers=headers) - if g.db.query(User).filter(User.id!=v.id, User.discord_id==x["id"]).first(): + if g.db.query(User).options(lazyload('*')).filter(User.id!=v.id, User.discord_id==x["id"]).first(): return render_template("message.html", title="Discord account already linked.", error="That Discord account is already in use by another user.", v=v) v.discord_id=x["id"] diff --git a/files/routes/front.py b/files/routes/front.py index b520473161..495c3a264b 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -25,11 +25,11 @@ def notifications(v): modmail = request.args.get('modmail', False) posts = request.args.get('posts', False) if modmail and v.admin_level == 6: - comments = g.db.query(Comment).filter(Comment.sentto==0).order_by(Comment.created_utc.desc()).offset(25*(page-1)).limit(26).all() + comments = g.db.query(Comment).options(lazyload('*')).filter(Comment.sentto==0).order_by(Comment.created_utc.desc()).offset(25*(page-1)).limit(26).all() next_exists = (len(comments) > 25) comments = comments[:25] elif messages: - comments = g.db.query(Comment).filter(or_(Comment.author_id==v.id, Comment.sentto==v.id), Comment.parent_submission == None).order_by(Comment.created_utc.desc(), not_(Comment.child_comments.any())).offset(25*(page-1)).limit(26).all() + comments = g.db.query(Comment).options(lazyload('*')).filter(or_(Comment.author_id==v.id, Comment.sentto==v.id), Comment.parent_submission == None).order_by(Comment.created_utc.desc(), not_(Comment.child_comments.any())).offset(25*(page-1)).limit(26).all() next_exists = (len(comments) > 25) comments = comments[:25] elif posts: @@ -209,8 +209,8 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words=' # g.db.add(vote) # try: g.db.flush() # except: g.db.rollback() - # post.upvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=1).count() - # post.downvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=-1).count() + # post.upvotes = g.db.query(Vote).options(lazyload('*')).filter_by(submission_id=post.id, vote_type=1).count() + # post.downvotes = g.db.query(Vote).options(lazyload('*')).filter_by(submission_id=post.id, vote_type=-1).count() # post.views = post.views + random.randint(7,10) # g.db.add(post) @@ -218,7 +218,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words=' posts = posts[:25] - if page == 1: posts = g.db.query(Submission).filter_by(stickied=True).all() + posts + if page == 1: posts = g.db.query(Submission).options(lazyload('*')).filter_by(stickied=True).all() + posts if ids_only: posts = [x.id for x in posts] @@ -271,7 +271,7 @@ def front_all(v): @cache.memoize(timeout=86400) def changeloglist(v=None, sort="new", page=1 ,t="all", **kwargs): - posts = g.db.query(Submission).options(lazyload('*')).filter_by(is_banned=False, private=False,).filter(Submission.deleted_utc == 0) + posts = g.db.query(Submission).options(lazyload('*')).options(lazyload('*')).filter_by(is_banned=False, private=False,).filter(Submission.deleted_utc == 0) if v and v.admin_level == 0: blocking = g.db.query( @@ -373,7 +373,7 @@ def changelog(v): @auth_desired def random_post(v): - x = g.db.query(Submission).filter(Submission.deleted_utc == 0, Submission.is_banned == False) + x = g.db.query(Submission).options(lazyload('*')).filter(Submission.deleted_utc == 0, Submission.is_banned == False) total = x.count() n = random.randint(1, total - 2) @@ -384,11 +384,11 @@ def random_post(v): def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all", **kwargs): posts = g.db.query(Submission).options(lazyload('*')) - cc_idlist = g.db.query(Submission.id).filter(Submission.club == True).subquery() + cc_idlist = g.db.query(Submission.id).options(lazyload('*')).filter(Submission.club == True).subquery() posts = posts.subquery() - comments = g.db.query(Comment).options(lazyload('*')).filter(Comment.parent_submission.notin_(cc_idlist)) + comments = g.db.query(Comment).options(lazyload('*')).options(lazyload('*')).filter(Comment.parent_submission.notin_(cc_idlist)) if v and v.admin_level <= 3: blocking = g.db.query( diff --git a/files/routes/login.py b/files/routes/login.py index 4e5a0d9e58..230e371c4a 100644 --- a/files/routes/login.py +++ b/files/routes/login.py @@ -32,9 +32,9 @@ def check_for_alts(current_id): if past_id == current_id: continue - check1 = g.db.query(Alt).filter_by( + check1 = g.db.query(Alt).options(lazyload('*')).filter_by( user1=current_id, user2=past_id).first() - check2 = g.db.query(Alt).filter_by( + check2 = g.db.query(Alt).options(lazyload('*')).filter_by( user1=past_id, user2=current_id).first() if not check1 and not check2: @@ -45,7 +45,7 @@ def check_for_alts(current_id): except BaseException: pass - otheralts = g.db.query(Alt).filter(or_(Alt.user1 == past_id, Alt.user2 == past_id, Alt.user1 == current_id, Alt.user2 == current_id)).all() + otheralts = g.db.query(Alt).options(lazyload('*')).filter(or_(Alt.user1 == past_id, Alt.user2 == past_id, Alt.user1 == current_id, Alt.user2 == current_id)).all() for a in otheralts: new_alt = Alt(user1=a.user1, user2=past_id) g.db.add(new_alt) @@ -70,7 +70,7 @@ def login_post(): if not username: abort(400) if "@" in username: - account = g.db.query(User).filter( + account = g.db.query(User).options(lazyload('*')).filter( User.email.ilike(username)).first() else: account = get_user(username, graceful=True) @@ -174,7 +174,7 @@ def sign_up_get(v): # check for referral in link ref = request.args.get("ref", None) if ref: - ref_user = g.db.query(User).filter(User.username.ilike(ref)).first() + ref_user = g.db.query(User).options(lazyload('*')).filter(User.username.ilike(ref)).first() else: ref_user = None @@ -247,7 +247,7 @@ def sign_up_post(v): args = {"error": error} if request.form.get("referred_by"): - user = g.db.query(User).filter_by( + user = g.db.query(User).options(lazyload('*')).filter_by( id=request.form.get("referred_by")).first() if user: args["ref"] = user.username @@ -318,7 +318,7 @@ def sign_up_post(v): lazyload('*')).filter_by(id=ref_id).first() if ref_user: # check self-setting badges - badge_types = g.db.query(BadgeDef).filter(BadgeDef.qualification_expr.isnot(None)).all() + badge_types = g.db.query(BadgeDef).options(lazyload('*')).filter(BadgeDef.qualification_expr.isnot(None)).all() for badge in badge_types: if eval(badge.qualification_expr, {}, {'v': ref_user}): if not ref_user.has_badge(badge.id): @@ -330,7 +330,7 @@ def sign_up_post(v): g.db.add(ref_user) - id_1 = g.db.query(User).filter_by(id=6).count() + id_1 = g.db.query(User).options(lazyload('*')).filter_by(id=6).count() users_count = g.db.query(User).count() #paranoid if id_1 == 0 and users_count < 6: admin_level=6 else: admin_level=0 @@ -344,9 +344,9 @@ def sign_up_post(v): email=email, created_utc=int(time.time()), referred_by=ref_id or None, - ban_evade = int(any([x.is_banned and not x.unban_utc for x in g.db.query(User).filter(User.id.in_(tuple(session.get("history", [])))).all() if x])), - agendaposter = any([x.agendaposter for x in g.db.query(User).filter(User.id.in_(tuple(session.get("history", [])))).all() if x]), - club_banned=any([x.club_banned for x in g.db.query(User).filter(User.id.in_(tuple(session.get("history", [])))).all() if x]) + ban_evade = int(any([x.is_banned and not x.unban_utc for x in g.db.query(User).options(lazyload('*')).filter(User.id.in_(tuple(session.get("history", [])))).all() if x])), + agendaposter = any([x.agendaposter for x in g.db.query(User).options(lazyload('*')).filter(User.id.in_(tuple(session.get("history", [])))).all() if x]), + club_banned=any([x.club_banned for x in g.db.query(User).options(lazyload('*')).filter(User.id.in_(tuple(session.get("history", [])))).all() if x]) ) g.db.add(new_user) @@ -391,7 +391,7 @@ def post_forgot(): email=email.replace("_","\_") - user = g.db.query(User).filter( + user = g.db.query(User).options(lazyload('*')).filter( User.username.ilike(username), User.email.ilike(email)).first() @@ -400,7 +400,7 @@ def post_forgot(): email=email.split('+')[0] email=email.replace('.','') email=f"{email}@gmail.com" - user = g.db.query(User).filter( + user = g.db.query(User).options(lazyload('*')).filter( User.username.ilike(username), User.email.ilike(email)).first() @@ -435,7 +435,7 @@ def get_reset(): title="Password reset link expired", error="That password reset link has expired.") - user = g.db.query(User).filter_by(id=user_id).first() + user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first() if not validate_hash(f"{user_id}+{timestamp}+forgot+{user.login_nonce}", token): abort(400) @@ -472,7 +472,7 @@ def post_reset(v): title="Password reset expired", error="That password reset form has expired.") - user = g.db.query(User).filter_by(id=user_id).first() + user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first() if not validate_hash(f"{user_id}+{timestamp}+reset+{user.login_nonce}", token): abort(400) diff --git a/files/routes/oauth.py b/files/routes/oauth.py index 30d3157317..76c37208be 100644 --- a/files/routes/oauth.py +++ b/files/routes/oauth.py @@ -10,7 +10,7 @@ from files.__main__ import app @auth_required def authorize_prompt(v): client_id = request.args.get("client_id") - application = g.db.query(OauthApp).filter_by(client_id=client_id).first() + application = g.db.query(OauthApp).options(lazyload('*')).filter_by(client_id=client_id).first() if not application: return {"oauth_error": "Invalid `client_id`"}, 401 return render_template("oauth.html", v=v, application=application) @@ -21,7 +21,7 @@ def authorize_prompt(v): def authorize(v): client_id = request.form.get("client_id") - application = g.db.query(OauthApp).filter_by(client_id=client_id).first() + application = g.db.query(OauthApp).options(lazyload('*')).filter_by(client_id=client_id).first() if not application: return {"oauth_error": "Invalid `client_id`"}, 401 access_token = secrets.token_urlsafe(128)[:128] new_auth = ClientAuth( @@ -63,9 +63,9 @@ def request_api_keys(v): def delete_oauth_app(v, aid): aid = int(aid) - app = g.db.query(OauthApp).filter_by(id=aid).first() + app = g.db.query(OauthApp).options(lazyload('*')).filter_by(id=aid).first() - for auth in g.db.query(ClientAuth).filter_by(oauth_client=app.id).all(): + for auth in g.db.query(ClientAuth).options(lazyload('*')).filter_by(oauth_client=app.id).all(): g.db.delete(auth) g.db.delete(app) @@ -81,7 +81,7 @@ def delete_oauth_app(v, aid): def edit_oauth_app(v, aid): aid = int(aid) - app = g.db.query(OauthApp).filter_by(id=aid).first() + app = g.db.query(OauthApp).options(lazyload('*')).filter_by(id=aid).first() app.redirect_uri = request.form.get('redirect_uri') app.app_name = request.form.get('name') @@ -99,7 +99,7 @@ def edit_oauth_app(v, aid): @validate_formkey def admin_app_approve(v, aid): - app = g.db.query(OauthApp).filter_by(id=aid).first() + app = g.db.query(OauthApp).options(lazyload('*')).filter_by(id=aid).first() user = app.author app.client_id = secrets.token_urlsafe(64)[:64] @@ -126,9 +126,9 @@ def admin_app_approve(v, aid): @validate_formkey def admin_app_revoke(v, aid): - app = g.db.query(OauthApp).filter_by(id=aid).first() + app = g.db.query(OauthApp).options(lazyload('*')).filter_by(id=aid).first() if app.id: - for auth in g.db.query(ClientAuth).filter_by(oauth_client=app.id).all(): g.db.delete(auth) + for auth in g.db.query(ClientAuth).options(lazyload('*')).filter_by(oauth_client=app.id).all(): g.db.delete(auth) g.db.flush() send_notification(NOTIFICATIONS_ACCOUNT, app.author, f"Your application `{app.app_name}` has been revoked.") @@ -145,9 +145,9 @@ def admin_app_revoke(v, aid): @validate_formkey def admin_app_reject(v, aid): - app = g.db.query(OauthApp).filter_by(id=aid).first() + app = g.db.query(OauthApp).options(lazyload('*')).filter_by(id=aid).first() - for auth in g.db.query(ClientAuth).filter_by(oauth_client=app.id).all(): g.db.delete(auth) + for auth in g.db.query(ClientAuth).options(lazyload('*')).filter_by(oauth_client=app.id).all(): g.db.delete(auth) g.db.flush() send_notification(NOTIFICATIONS_ACCOUNT, app.author, f"Your application `{app.app_name}` has been rejected.") @@ -229,7 +229,7 @@ def reroll_oauth_tokens(aid, v): aid = aid - a = g.db.query(OauthApp).filter_by(id=aid).first() + a = g.db.query(OauthApp).options(lazyload('*')).filter_by(id=aid).first() if a.author_id != v.id: abort(403) diff --git a/files/routes/posts.py b/files/routes/posts.py index bab6c03184..94080eea20 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -103,15 +103,15 @@ def post_id(pid, anything=None, v=None): if post.club and not (v and v.paid_dues): abort(403) if v: - votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery() + votes = g.db.query(CommentVote).options(lazyload('*')).filter_by(user_id=v.id).subquery() blocking = v.blocking.subquery() blocked = v.blocked.subquery() if not (v and v.shadowbanned) and not (v and v.admin_level == 6): - shadowbanned = g.db.query(User.id).filter(User.shadowbanned == True).subquery() - comments = g.db.query(Comment).filter(Comment.author_id.notin_(shadowbanned)) + shadowbanned = g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).subquery() + comments = g.db.query(Comment).options(lazyload('*')).filter(Comment.author_id.notin_(shadowbanned)) comments = g.db.query( Comment, @@ -121,7 +121,7 @@ def post_id(pid, anything=None, v=None): ) if not (v and v.shadowbanned) and not (v and v.admin_level == 6): - shadowbanned = g.db.query(User.id).filter(User.shadowbanned == True).subquery() + shadowbanned = g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).subquery() comments = comments.filter(Comment.author_id.notin_(shadowbanned)) if v.admin_level >=4: @@ -170,9 +170,9 @@ def post_id(pid, anything=None, v=None): post.preloaded_comments = output else: - shadowbanned = g.db.query(User.id).filter(User.shadowbanned == True).subquery() + shadowbanned = g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).subquery() - comments = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.author_id.notin_(shadowbanned)) + comments = g.db.query(Comment).options(lazyload('*')).filter(Comment.parent_submission == post.id, Comment.author_id.notin_(shadowbanned)) if sort == "top": comments = sorted(comments.all(), key=lambda x: x.score, reverse=True) @@ -202,8 +202,8 @@ def post_id(pid, anything=None, v=None): # g.db.add(vote) # try: g.db.flush() # except: g.db.rollback() - # comment.upvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=1).count() - # comment.downvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=-1).count() + # comment.upvotes = g.db.query(CommentVote).options(lazyload('*')).filter_by(comment_id=comment.id, vote_type=1).count() + # comment.downvotes = g.db.query(CommentVote).options(lazyload('*')).filter_by(comment_id=comment.id, vote_type=-1).count() # g.db.add(comment) post.preloaded_comments = comments @@ -285,7 +285,7 @@ def edit_post(pid, v): fragment='') check_url = urlunparse(check_url) - badlink = g.db.query(BadLink).filter( + badlink = g.db.query(BadLink).options(lazyload('*')).filter( literal(check_url).contains( BadLink.link)).first() if badlink: @@ -379,7 +379,7 @@ def edit_post(pid, v): soup = BeautifulSoup(body_html, features="html.parser") for mention in soup.find_all("a", href=re.compile("^/@(\w+)")): username = mention["href"].split("@")[1] - user = g.db.query(User).filter_by(username=username).first() + user = g.db.query(User).options(lazyload('*')).filter_by(username=username).first() if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user) for x in notify_users: send_notification(NOTIFICATIONS_ACCOUNT, x, f"@{v.username} has mentioned you: https://{site}{p.permalink}") @@ -622,7 +622,7 @@ def submit_post(v): url = url.replace(".png", "_d.png").replace(".jpg", "_d.jpg").replace(".jpeg", "_d.jpeg") if "_d." in url: url += "?maxwidth=9999" - repost = g.db.query(Submission).join(Submission.submission_aux).filter( + repost = g.db.query(Submission).join(Submission.submission_aux).options(lazyload('*')).filter( SubmissionAux.url.ilike(url), Submission.deleted_utc == 0, Submission.is_banned == False @@ -665,7 +665,7 @@ def submit_post(v): body = request.form.get("body", "") # check for duplicate - dup = g.db.query(Submission).join(Submission.submission_aux).filter( + dup = g.db.query(Submission).join(Submission.submission_aux).options(lazyload('*')).filter( Submission.author_id == v.id, Submission.deleted_utc == 0, @@ -843,7 +843,7 @@ def submit_post(v): fragment='') check_url = urlunparse(check_url) - badlink = g.db.query(BadLink).filter( + badlink = g.db.query(BadLink).options(lazyload('*')).filter( literal(check_url).contains( BadLink.link)).first() if badlink: @@ -966,7 +966,7 @@ def submit_post(v): soup = BeautifulSoup(body_html, features="html.parser") for mention in soup.find_all("a", href=re.compile("^/@(\w+)")): username = mention["href"].split("@")[1] - user = g.db.query(User).filter_by(username=username).first() + user = g.db.query(User).options(lazyload('*')).filter_by(username=username).first() if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user) for x in notify_users: send_notification(NOTIFICATIONS_ACCOUNT, x, f"@{v.username} has mentioned you: https://{site}{new_post.permalink}") @@ -1150,7 +1150,7 @@ def undelete_post_pid(pid, v): @validate_formkey def toggle_comment_nsfw(cid, v): - comment = g.db.query(Comment).filter_by(id=cid).first() + comment = g.db.query(Comment).options(lazyload('*')).filter_by(id=cid).first() if not comment.author_id == v.id and not v.admin_level >= 3: abort(403) comment.over_18 = not comment.over_18 g.db.add(comment) @@ -1209,7 +1209,7 @@ def unsave_post(pid, v): post=get_post(pid) - save=g.db.query(SaveRelationship).filter_by(user_id=v.id, submission_id=post.id, type=1).first() + save=g.db.query(SaveRelationship).options(lazyload('*')).filter_by(user_id=v.id, submission_id=post.id, type=1).first() if save: g.db.delete(save) diff --git a/files/routes/reporting.py b/files/routes/reporting.py index 60ecc9e643..8b075216f3 100644 --- a/files/routes/reporting.py +++ b/files/routes/reporting.py @@ -12,7 +12,7 @@ def api_flag_post(pid, v): post = get_post(pid) if v: - existing = g.db.query(Flag).filter_by(user_id=v.id, post_id=post.id).first() + existing = g.db.query(Flag).options(lazyload('*')).filter_by(user_id=v.id, post_id=post.id).first() if existing: return "", 409 @@ -43,7 +43,7 @@ def api_flag_comment(cid, v): comment = get_comment(cid) if v: - existing = g.db.query(CommentFlag).filter_by( + existing = g.db.query(CommentFlag).options(lazyload('*')).filter_by( user_id=v.id, comment_id=comment.id).first() if existing: return "", 409 @@ -75,9 +75,9 @@ def remove_report(report_fn, v): return {"error": "go outside"}, 403 if report_fn.startswith('c'): - report = g.db.query(CommentFlag).filter_by(id=int(report_fn.lstrip('c'))).first() + report = g.db.query(CommentFlag).options(lazyload('*')).filter_by(id=int(report_fn.lstrip('c'))).first() elif report_fn.startswith('p'): - report = g.db.query(Flag).filter_by(id=int(report_fn.lstrip('p'))).first() + report = g.db.query(Flag).options(lazyload('*')).filter_by(id=int(report_fn.lstrip('p'))).first() else: return {"error": "Invalid report ID"}, 400 diff --git a/files/routes/search.py b/files/routes/search.py index 7a826eb4e1..483489d2fe 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -150,7 +150,7 @@ def searchlisting(criteria, v=None, page=1, t="None", sort="top", b=None): def searchcommentlisting(criteria, v=None, page=1, t="None", sort="top"): - comments = g.db.query(Comment).options(lazyload('*')).filter(Comment.parent_submission != None).join(Comment.comment_aux) + comments = g.db.query(Comment).options(lazyload('*')).options(lazyload('*')).filter(Comment.parent_submission != None).join(Comment.comment_aux) if 'q' in criteria: words=criteria['q'].split() @@ -278,7 +278,7 @@ def searchusers(v): term=term.replace('\\','') term=term.replace('_','\_') - users=g.db.query(User).filter(User.username.ilike(f'%{term}%')) + users=g.db.query(User).options(lazyload('*')).filter(User.username.ilike(f'%{term}%')) users=users.order_by(User.username.ilike(term).desc(), User.stored_subscriber_count.desc()) diff --git a/files/routes/settings.py b/files/routes/settings.py index 3bf55d0b21..dc78ccb2ae 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -417,7 +417,7 @@ def settings_security_post(v): return redirect("/settings/security?error=That email is already yours!") # check to see if email is in use - existing = g.db.query(User).filter(User.id != v.id, + existing = g.db.query(User).options(lazyload('*')).filter(User.id != v.id, func.lower(User.email) == new_email.lower()).first() if existing: return redirect("/settings/security?error=" + @@ -652,7 +652,7 @@ def settings_block_user(v): - existing = g.db.query(Notification).filter_by(blocksender=v.id, user_id=user.id).first() + existing = g.db.query(Notification).options(lazyload('*')).filter_by(blocksender=v.id, user_id=user.id).first() if not existing: send_block_notif(v.id, user.id, f"@{v.username} has blocked you!") if v.admin_level == 1: return {"message": f"@{user.username} banned!"} @@ -679,7 +679,7 @@ def settings_unblock_user(v): - existing = g.db.query(Notification).filter_by(unblocksender=v.id, user_id=user.id).first() + existing = g.db.query(Notification).options(lazyload('*')).filter_by(unblocksender=v.id, user_id=user.id).first() if not existing: send_unblock_notif(v.id, user.id, f"@{v.username} has unblocked you!") if v.admin_level == 1: return {"message": f"@{user.username} unbanned!"} @@ -759,7 +759,7 @@ def settings_name_change(v): v=v, error=f"Username `{new_name}` is already in use.") - v=g.db.query(User).with_for_update().options(lazyload('*')).filter_by(id=v.id).first() + v=g.db.query(User).with_for_update().options(lazyload('*')).options(lazyload('*')).filter_by(id=v.id).first() v.username=new_name v.name_changed_utc=int(time.time()) @@ -778,7 +778,7 @@ def settings_name_change(v): def settings_song_change(v): song=request.form.get("song").strip() - if song == "" and v.song and path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User).filter_by(song=v.song).count() == 1: + if song == "" and v.song and path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User).options(lazyload('*')).filter_by(song=v.song).count() == 1: os.remove(f"/songs/{v.song}.mp3") v.song=None g.db.add(v) @@ -821,7 +821,7 @@ def settings_song_change(v): error=f"Duration of the video must not exceed 10 minutes.") - if v.song and path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User).filter_by(song=v.song).count() == 1: + if v.song and path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User).options(lazyload('*')).filter_by(song=v.song).count() == 1: os.remove(f"/songs/{v.song}.mp3") ydl_opts = { diff --git a/files/routes/static.py b/files/routes/static.py index 8c32260351..f90a548db3 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -33,28 +33,28 @@ def participation_stats(v): day = now - 86400 data = {"valid_users": g.db.query(User).count(), - "private_users": g.db.query(User).filter_by(is_private=True).count(), - "banned_users": g.db.query(User).filter(User.is_banned > 0).count(), - "verified_email_users": g.db.query(User).filter_by(is_activated=True).count(), + "private_users": g.db.query(User).options(lazyload('*')).filter_by(is_private=True).count(), + "banned_users": g.db.query(User).options(lazyload('*')).filter(User.is_banned > 0).count(), + "verified_email_users": g.db.query(User).options(lazyload('*')).filter_by(is_activated=True).count(), "total_coins": g.db.query(func.sum(User.coins)).scalar(), - "signups_last_24h": g.db.query(User).filter(User.created_utc > day).count(), + "signups_last_24h": g.db.query(User).options(lazyload('*')).filter(User.created_utc > day).count(), "total_posts": g.db.query(Submission).count(), "posting_users": g.db.query(Submission.author_id).distinct().count(), - "listed_posts": g.db.query(Submission).filter_by(is_banned=False).filter(Submission.deleted_utc == 0).count(), - "removed_posts": g.db.query(Submission).filter_by(is_banned=True).count(), - "deleted_posts": g.db.query(Submission).filter(Submission.deleted_utc > 0).count(), - "posts_last_24h": g.db.query(Submission).filter(Submission.created_utc > day).count(), + "listed_posts": g.db.query(Submission).options(lazyload('*')).filter_by(is_banned=False).filter(Submission.deleted_utc == 0).count(), + "removed_posts": g.db.query(Submission).options(lazyload('*')).filter_by(is_banned=True).count(), + "deleted_posts": g.db.query(Submission).options(lazyload('*')).filter(Submission.deleted_utc > 0).count(), + "posts_last_24h": g.db.query(Submission).options(lazyload('*')).filter(Submission.created_utc > day).count(), "total_comments": g.db.query(Comment).count(), "commenting_users": g.db.query(Comment.author_id).distinct().count(), - "removed_comments": g.db.query(Comment).filter_by(is_banned=True).count(), - "deleted_comments": g.db.query(Comment).filter(Comment.deleted_utc>0).count(), - "comments_last_24h": g.db.query(Comment).filter(Comment.created_utc > day).count(), + "removed_comments": g.db.query(Comment).options(lazyload('*')).filter_by(is_banned=True).count(), + "deleted_comments": g.db.query(Comment).options(lazyload('*')).filter(Comment.deleted_utc>0).count(), + "comments_last_24h": g.db.query(Comment).options(lazyload('*')).filter(Comment.created_utc > day).count(), "post_votes": g.db.query(Vote).count(), "post_voting_users": g.db.query(Vote.user_id).distinct().count(), "comment_votes": g.db.query(CommentVote).count(), "comment_voting_users": g.db.query(CommentVote.user_id).distinct().count(), "total_awards": g.db.query(AwardRelationship).count(), - "awards_given": g.db.query(AwardRelationship).filter(or_(AwardRelationship.submission_id != None, AwardRelationship.comment_id != None)).count() + "awards_given": g.db.query(AwardRelationship).options(lazyload('*')).filter(or_(AwardRelationship.submission_id != None, AwardRelationship.comment_id != None)).count() } @@ -89,7 +89,7 @@ def patrons(v): @app.get("/badmins") @auth_desired def admins(v): - admins = g.db.query(User).filter_by(admin_level=6).order_by(User.coins.desc()).all() + admins = g.db.query(User).options(lazyload('*')).filter_by(admin_level=6).order_by(User.coins.desc()).all() return render_template("admins.html", v=v, admins=admins) @app.get("/log") @@ -100,7 +100,7 @@ def log(v): page=int(request.args.get("page",1)) if v and v.admin_level == 6: actions = g.db.query(ModAction).order_by(ModAction.id.desc()).offset(25 * (page - 1)).limit(26).all() - else: actions=g.db.query(ModAction).filter(ModAction.kind!="shadowban", ModAction.kind!="unshadowban", ModAction.kind!="club", ModAction.kind!="unclub").order_by(ModAction.id.desc()).offset(25*(page-1)).limit(26).all() + else: actions=g.db.query(ModAction).options(lazyload('*')).filter(ModAction.kind!="shadowban", ModAction.kind!="unshadowban", ModAction.kind!="club", ModAction.kind!="unclub").order_by(ModAction.id.desc()).offset(25*(page-1)).limit(26).all() next_exists=len(actions)==26 actions=actions[:25] @@ -116,7 +116,7 @@ def log_item(id, v): try: id = int(id, 36) except: abort(404) - action=g.db.query(ModAction).filter_by(id=id).first() + action=g.db.query(ModAction).options(lazyload('*')).filter_by(id=id).first() if not action: abort(404) @@ -228,7 +228,7 @@ def blocks(v): def banned(v): - users = [x for x in g.db.query(User).filter(User.is_banned > 0, User.unban_utc == 0).all()] + users = [x for x in g.db.query(User).options(lazyload('*')).filter(User.is_banned > 0, User.unban_utc == 0).all()] return render_template("banned.html", v=v, users=users) @app.get("/formatting") diff --git a/files/routes/users.py b/files/routes/users.py index cdd5144059..c7314a824d 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -77,16 +77,16 @@ def steal(v): @app.get("/rentoids") @auth_desired def rentoids(v): - users = g.db.query(User).filter(User.rent_utc > 0).all() + users = g.db.query(User).options(lazyload('*')).filter(User.rent_utc > 0).all() return render_template("rentoids.html", v=v, users=users) @app.get("/thiefs") @auth_desired def thiefs(v): - successful = g.db.query(User).filter(User.steal_utc > 0).all() - failed = g.db.query(User).filter(User.fail_utc > 0).all() - failed2 = g.db.query(User).filter(User.fail2_utc > 0).all() + successful = g.db.query(User).options(lazyload('*')).filter(User.steal_utc > 0).all() + failed = g.db.query(User).options(lazyload('*')).filter(User.fail_utc > 0).all() + failed2 = g.db.query(User).options(lazyload('*')).filter(User.fail2_utc > 0).all() return render_template("thiefs.html", v=v, successful=successful, failed=failed, failed2=failed2) @@ -175,7 +175,7 @@ def get_profilecss(username): def songs(id): try: id = int(id) except: return "", 400 - user = g.db.query(User).filter_by(id=id).first() + user = g.db.query(User).options(lazyload('*')).filter_by(id=id).first() return redirect(f"/song/{user.song}.mp3") @app.get("/song/") @@ -196,7 +196,7 @@ def subscribe(v, post_id): @app.post("/unsubscribe/") @auth_required def unsubscribe(v, post_id): - sub=g.db.query(Subscription).filter_by(user_id=v.id, submission_id=post_id).first() + sub=g.db.query(Subscription).options(lazyload('*')).filter_by(user_id=v.id, submission_id=post_id).first() g.db.delete(sub) g.db.commit() return {"message": "Post unsubscribed!"} @@ -214,7 +214,7 @@ def message2(v, username): message = message.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n") # check existing - existing = g.db.query(Comment).join(CommentAux).filter(Comment.author_id == v.id, + existing = g.db.query(Comment).join(CommentAux).options(lazyload('*')).filter(Comment.author_id == v.id, Comment.sentto == user.id, CommentAux.body == message, ).options(contains_eager(Comment.comment_aux)).first() @@ -254,7 +254,7 @@ def messagereply(v): message = message.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n") # check existing - existing = g.db.query(Comment).join(CommentAux).filter(Comment.author_id == v.id, + existing = g.db.query(Comment).join(CommentAux).options(lazyload('*')).filter(Comment.author_id == v.id, Comment.sentto == user.id, CommentAux.body == message, ).options(contains_eager(Comment.comment_aux)).first() @@ -382,7 +382,7 @@ def u_username(username, v=None): # viewers if v and u.id != v.id: - view = g.db.query(ViewerRelationship).filter( + view = g.db.query(ViewerRelationship).options(lazyload('*')).filter( and_( ViewerRelationship.viewer_id == v.id, ViewerRelationship.user_id == u.id @@ -434,7 +434,7 @@ def u_username(username, v=None): # If page 1, check for sticky if page == 1: sticky = [] - sticky = g.db.query(Submission).filter_by(is_pinned=True, author_id=u.id).all() + sticky = g.db.query(Submission).options(lazyload('*')).filter_by(is_pinned=True, author_id=u.id).all() if sticky: for p in sticky: ids = [p.id] + ids @@ -595,15 +595,15 @@ def follow_user(username, v): if target.id==v.id: return {"error": "You can't follow yourself!"}, 400 # check for existing follow - if g.db.query(Follow).filter_by(user_id=v.id, target_id=target.id).first(): return {"message": "User followed!"} + if g.db.query(Follow).options(lazyload('*')).filter_by(user_id=v.id, target_id=target.id).first(): return {"message": "User followed!"} new_follow = Follow(user_id=v.id, target_id=target.id) g.db.add(new_follow) - target.stored_subscriber_count = g.db.query(Follow).filter_by(target_id=target.id).count() + target.stored_subscriber_count = g.db.query(Follow).options(lazyload('*')).filter_by(target_id=target.id).count() g.db.add(target) - existing = g.db.query(Notification).filter_by(followsender=v.id, user_id=target.id).first() + existing = g.db.query(Notification).options(lazyload('*')).filter_by(followsender=v.id, user_id=target.id).first() if not existing: send_follow_notif(v.id, target.id, f"@{v.username} has followed you!") g.db.commit() @@ -617,15 +617,15 @@ def unfollow_user(username, v): target = get_user(username) # check for existing follow - follow = g.db.query(Follow).filter_by(user_id=v.id, target_id=target.id).first() + follow = g.db.query(Follow).options(lazyload('*')).filter_by(user_id=v.id, target_id=target.id).first() if not follow: return {"message": "User unfollowed!"} g.db.delete(follow) - target.stored_subscriber_count = g.db.query(Follow).filter_by(target_id=target.id).count() + target.stored_subscriber_count = g.db.query(Follow).options(lazyload('*')).filter_by(target_id=target.id).count() g.db.add(target) - existing = g.db.query(Notification).filter_by(unfollowsender=v.id, user_id=target.id).first() + existing = g.db.query(Notification).options(lazyload('*')).filter_by(unfollowsender=v.id, user_id=target.id).first() if not existing: send_unfollow_notif(v.id, target.id, f"@{v.username} has unfollowed you!") g.db.commit() diff --git a/files/routes/votes.py b/files/routes/votes.py index 3be315e7a5..fd11176a2e 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -69,7 +69,7 @@ def api_vote_post(post_id, new, v): post = get_post(post_id) # check for existing vote - existing = g.db.query(Vote).filter_by(user_id=v.id, submission_id=post.id).first() + existing = g.db.query(Vote).options(lazyload('*')).filter_by(user_id=v.id, submission_id=post.id).first() if existing and existing.vote_type == new: return "", 204 @@ -96,8 +96,8 @@ def api_vote_post(post_id, new, v): ) g.db.add(vote) - post.upvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=1).count() - post.downvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=-1).count() + post.upvotes = g.db.query(Vote).options(lazyload('*')).filter_by(submission_id=post.id, vote_type=1).count() + post.downvotes = g.db.query(Vote).options(lazyload('*')).filter_by(submission_id=post.id, vote_type=-1).count() g.db.add(post) g.db.commit() return "", 204 @@ -121,7 +121,7 @@ def api_vote_comment(comment_id, new, v): comment = get_comment(comment_id) # check for existing vote - existing = g.db.query(CommentVote).filter_by(user_id=v.id, comment_id=comment.id).first() + existing = g.db.query(CommentVote).options(lazyload('*')).filter_by(user_id=v.id, comment_id=comment.id).first() if existing and existing.vote_type == new: return "", 204 @@ -149,8 +149,8 @@ def api_vote_comment(comment_id, new, v): g.db.add(vote) - comment.upvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=1).count() - comment.downvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=-1).count() + comment.upvotes = g.db.query(CommentVote).options(lazyload('*')).filter_by(comment_id=comment.id, vote_type=1).count() + comment.downvotes = g.db.query(CommentVote).options(lazyload('*')).filter_by(comment_id=comment.id, vote_type=-1).count() g.db.add(comment) g.db.commit() return "", 204 \ No newline at end of file From d96d827586aa52c7636e197f3c0c685aaefacaa9 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 10:30:47 +0200 Subject: [PATCH 20/64] fd --- files/__main__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/files/__main__.py b/files/__main__.py index 7f2c778060..300759570f 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -9,7 +9,7 @@ from flask_compress import Compress from flask_limiter.util import get_ipaddr from flaskext.markdown import Markdown from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy.orm import sessionmaker, scoped_session, Query as _Query +from sqlalchemy.orm import lazyload, sessionmaker, scoped_session, Query as _Query from sqlalchemy import * from sqlalchemy.pool import QueuePool import redis @@ -84,8 +84,7 @@ _engine=create_engine( app.config['DATABASE_URL'], poolclass=QueuePool, pool_size=int(environ.get("PG_POOL_SIZE",10)), - pool_use_lifo=True, - echo=True + pool_use_lifo=True ) def retry(f): From 9a238785d2a550aad96dd7b77ed03eb6235d9f01 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 10:34:36 +0200 Subject: [PATCH 21/64] df --- files/__main__.py | 2 +- files/helpers/filters.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/files/__main__.py b/files/__main__.py index 300759570f..73aec42248 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -9,7 +9,7 @@ from flask_compress import Compress from flask_limiter.util import get_ipaddr from flaskext.markdown import Markdown from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy.orm import lazyload, sessionmaker, scoped_session, Query as _Query +from sqlalchemy.orm import sessionmaker, scoped_session, Query as _Query from sqlalchemy import * from sqlalchemy.pool import QueuePool import redis diff --git a/files/helpers/filters.py b/files/helpers/filters.py index e4c1698f2c..d6f5658ef6 100644 --- a/files/helpers/filters.py +++ b/files/helpers/filters.py @@ -2,6 +2,7 @@ from bs4 import BeautifulSoup from flask import * from urllib.parse import urlparse from files.classes import BannedDomain +from sqlalchemy.orm import lazyload def filter_comment_html(html_text): From 9c13a93afb422c54f1e3d36faa4ad91f5c0050c6 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 10:38:59 +0200 Subject: [PATCH 22/64] fd --- files/routes/front.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/files/routes/front.py b/files/routes/front.py index 495c3a264b..69e69e5fd3 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -10,12 +10,6 @@ defaulttimefilter = environ.get("DEFAULT_TIME_FILTER", "all").strip() def slash_post(): return redirect("/") -@app.get("/testing") -def testing(): - notifications = g.db.query(Notification).options(lazyload('*')).join(Notification.comment).limit(26) - notifications2 = g.db.query(Notification).join(Notification.comment).limit(26) - return "sex" - @app.get("/notifications") @auth_required def notifications(v): From c2b1f50099b025892ed24937f40d550e64fefcb8 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 10:55:55 +0200 Subject: [PATCH 23/64] df --- files/helpers/alerts.py | 15 ++++++--------- files/helpers/wrappers.py | 3 +-- files/mail/mail.py | 1 + files/routes/admin.py | 26 ++++++++++++-------------- files/routes/awards.py | 3 +-- files/routes/oauth.py | 4 +--- files/routes/posts.py | 17 ++++++++--------- files/routes/users.py | 3 ++- 8 files changed, 32 insertions(+), 40 deletions(-) diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index bc81e63ca5..dd81fc4934 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -7,7 +7,7 @@ from .sanitize import * from .const import * -def send_notification(vid, user, text, db=None): +def send_notification(vid, user, text): # for when working outside request context if isinstance(user, int): @@ -15,9 +15,6 @@ def send_notification(vid, user, text, db=None): else: uid = user.id - if not db: - db = g.db - text = text.replace('r/', 'r\/').replace('u/', 'u\/') text = text.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n") text_html = CustomRenderer().render(mistletoe.Document(text)) @@ -28,20 +25,20 @@ def send_notification(vid, user, text, db=None): parent_submission=None, distinguish_level=6, ) - db.add(new_comment) + g.db.add(new_comment) - db.flush() + g.db.flush() new_aux = CommentAux(id=new_comment.id, body=text, body_html=text_html, ) - db.add(new_aux) + g.db.add(new_aux) notif = Notification(comment_id=new_comment.id, user_id=uid) - db.add(notif) - db.commit() + g.db.add(notif) + g.db.commit() def send_follow_notif(vid, user, text): diff --git a/files/helpers/wrappers.py b/files/helpers/wrappers.py index 507adee0cc..8e31ef2c0c 100644 --- a/files/helpers/wrappers.py +++ b/files/helpers/wrappers.py @@ -92,15 +92,14 @@ def check_ban_evade(v): g.db.add(ma) except: pass - g.db.flush() try: abort(403) except Exception as e: print(e) else: v.ban_evade +=1 g.db.add(v) - g.db.flush() + g.db.commit() diff --git a/files/mail/mail.py b/files/mail/mail.py index f0ca51c209..ac5f5291bd 100644 --- a/files/mail/mail.py +++ b/files/mail/mail.py @@ -96,5 +96,6 @@ def activate(v): g.db.add(mail_badge) g.db.add(user) + g.db.commit() return render_template("message_success.html", v=v, title="Email verified.", message=f"Your email {email} has been verified. Thank you.") diff --git a/files/routes/admin.py b/files/routes/admin.py index 12baabaecb..40475a8f0b 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -42,7 +42,7 @@ def revert_actions(v, username): for user in users: user.unban() - g.db.commit() + g.db.commit() return {"message": "Admin actions reverted!"} @app.post("/@/club_allow") @@ -97,7 +97,7 @@ def make_admin(v, username): if not user: abort(404) user.admin_level = 6 g.db.add(user) - g.db.commit() + g.db.commit() return {"message": "User has been made admin!"} @@ -109,7 +109,7 @@ def remove_admin(v, username): if not user: abort(404) user.admin_level = 0 g.db.add(user) - g.db.commit() + g.db.commit() return {"message": "Admin removed!"} @@ -121,7 +121,7 @@ def make_fake_admin(v, username): if not user: abort(404) user.admin_level = 1 g.db.add(user) - g.db.commit() + g.db.commit() return {"message": "User has been made fake admin!"} @@ -133,7 +133,7 @@ def remove_fake_admin(v, username): if not user: abort(404) user.admin_level = 0 g.db.add(user) - g.db.commit() + g.db.commit() return {"message": "Fake admin removed!"} @@ -436,7 +436,7 @@ def badge_grant_post(v): g.db.add(user) - g.db.commit() + g.db.commit() return redirect("/admin/badge_grant") @@ -720,7 +720,6 @@ def agendaposter(user_id, v): note = note ) g.db.add(ma) - g.db.flush() if user.agendaposter: if not user.has_badge(26): @@ -891,8 +890,6 @@ def ban_user(user_id, v): ) g.db.add(ma) - g.db.commit() - if 'reason' in request.args: if reason.startswith("/post/"): post = reason.split("/post/")[1].split("/")[0] @@ -904,8 +901,11 @@ def ban_user(user_id, v): comment = get_comment(comment) comment.bannedfor = True g.db.add(comment) + g.db.commit() return {"message": f"@{user.username} was banned!"} - else: return redirect(user.url) + else: + g.db.commit() + return redirect(user.url) @app.post("/unban_user/") @@ -937,10 +937,8 @@ def unban_user(user_id, v): g.db.commit() - if "@" in request.referrer: - return redirect(user.url) - else: - return {"message": f"@{user.username} was unbanned!"} + if "@" in request.referrer: return redirect(user.url) + else: return {"message": f"@{user.username} was unbanned!"} @app.post("/ban_post/") @admin_level_required(3) diff --git a/files/routes/awards.py b/files/routes/awards.py index 9a6034194e..f6d103ff51 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -252,8 +252,7 @@ def award_post(pid, v): send_notification(NOTIFICATIONS_ACCOUNT, post.author, msg) - if kind in ACTIONS: - ACTIONS[kind](post=post) + if kind in ACTIONS: ACTIONS[kind](post=post) post.author.received_award_count += 1 g.db.add(post.author) diff --git a/files/routes/oauth.py b/files/routes/oauth.py index 76c37208be..7704da7897 100644 --- a/files/routes/oauth.py +++ b/files/routes/oauth.py @@ -130,12 +130,11 @@ def admin_app_revoke(v, aid): if app.id: for auth in g.db.query(ClientAuth).options(lazyload('*')).filter_by(oauth_client=app.id).all(): g.db.delete(auth) - g.db.flush() send_notification(NOTIFICATIONS_ACCOUNT, app.author, f"Your application `{app.app_name}` has been revoked.") g.db.delete(app) - g.db.commit() + g.db.commit() return {"message": f"App revoked"} @@ -149,7 +148,6 @@ def admin_app_reject(v, aid): for auth in g.db.query(ClientAuth).options(lazyload('*')).filter_by(oauth_client=app.id).all(): g.db.delete(auth) - g.db.flush() send_notification(NOTIFICATIONS_ACCOUNT, app.author, f"Your application `{app.app_name}` has been rejected.") g.db.delete(app) diff --git a/files/routes/posts.py b/files/routes/posts.py index 94080eea20..8d21c6b3bc 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -448,7 +448,7 @@ def filter_title(title): IMGUR_KEY = environ.get("IMGUR_KEY", "").strip() -def check_processing_thread(v, post, link, db): +def check_processing_thread(v, post, link): image_id = link.split('/')[-1].rstrip('.mp4') headers = {"Authorization": f"Client-ID {IMGUR_KEY}"} @@ -463,16 +463,15 @@ def check_processing_thread(v, post, link, db): status = req.json()['data']['processing']['status'] if status == 'completed': post.processing = False - db.add(post) + g.db.add(post) send_notification( NOTIFICATIONS_ACCOUNT, v, - f"Your video has finished processing and your [post](/post/{post.id}) is now live.", - db=db + f"Your video has finished processing and your [post](/post/{post.id}) is now live." ) - db.commit() + g.db.commit() break # just in case elif status == 'failed': @@ -933,7 +932,7 @@ def submit_post(v): post_url += 'mp4' new_post.url = post_url new_post.processing = True - gevent.spawn(check_processing_thread, v.id, new_post, post_url, g.db) + gevent.spawn(check_processing_thread, v.id, new_post, post_url) except UploadException as e: if request.headers.get("Authorization"): return { @@ -1211,8 +1210,8 @@ def unsave_post(pid, v): save=g.db.query(SaveRelationship).options(lazyload('*')).filter_by(user_id=v.id, submission_id=post.id, type=1).first() - if save: g.db.delete(save) - - g.db.commit() + if save: + g.db.delete(save) + g.db.commit() return {"message": "Post unsaved!"} diff --git a/files/routes/users.py b/files/routes/users.py index c7314a824d..89b6515754 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -131,11 +131,12 @@ def transfer_coins(v, username): receiver.coins += amount g.db.add(receiver) g.db.add(v) - g.db.commit() transfer_message = f"🤑 [@{v.username}]({v.url}) has gifted you {amount} {app.config['COINS_NAME']}!" send_notification(NOTIFICATIONS_ACCOUNT, receiver, transfer_message) + g.db.commit() + return {"message": f"{app.config['COINS_NAME']} transferred!"} From 64c79c0aeb5e932a61efcc6e1d4d7a8815f0fb4e Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 11:12:54 +0200 Subject: [PATCH 24/64] fd --- files/__main__.py | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/files/__main__.py b/files/__main__.py index 73aec42248..dd011542fa 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -83,7 +83,7 @@ limiter = Limiter( _engine=create_engine( app.config['DATABASE_URL'], poolclass=QueuePool, - pool_size=int(environ.get("PG_POOL_SIZE",10)), + pool_size=197, pool_use_lifo=True ) diff --git a/requirements.txt b/requirements.txt index fe3e4319d0..489932b054 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,7 +17,7 @@ pyotp qrcode redis requests -SQLAlchemy==1.3.19 +SQLAlchemy psycopg2-binary pusher_push_notifications youtube-dl From 37fe5981d49795ae6f55cbab3cda6062d3117b51 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 11:28:19 +0200 Subject: [PATCH 25/64] fd --- files/helpers/alerts.py | 1 - 1 file changed, 1 deletion(-) diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index dd81fc4934..e95a99f766 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -38,7 +38,6 @@ def send_notification(vid, user, text): notif = Notification(comment_id=new_comment.id, user_id=uid) g.db.add(notif) - g.db.commit() def send_follow_notif(vid, user, text): From b0f0f4a1be276f4d52695e2990a8f73a5cf158d1 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 11:33:56 +0200 Subject: [PATCH 26/64] fd --- files/routes/awards.py | 1 + files/templates/shop.html | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/files/routes/awards.py b/files/routes/awards.py index f6d103ff51..635e3eee83 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -7,6 +7,7 @@ from files.classes.award import * from flask import g, request @app.get("/shop") +@app.get("/settings/shop") @auth_required def shop(v): if site_name == "Drama": diff --git a/files/templates/shop.html b/files/templates/shop.html index 690382d34b..70970420c5 100644 --- a/files/templates/shop.html +++ b/files/templates/shop.html @@ -1,4 +1,4 @@ -{% extends "default.html" %} +{% extends "settings.html" %} {% block title %} Shop From 253f49b9a895445edccdf1cafce97e39e380e5af Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 11:37:13 +0200 Subject: [PATCH 27/64] fd --- files/templates/settings.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/files/templates/settings.html b/files/templates/settings.html index 927795b15c..d594176879 100644 --- a/files/templates/settings.html +++ b/files/templates/settings.html @@ -156,6 +156,9 @@ + @@ -186,6 +189,9 @@ + From 8ab7b35518e01ac815c389c6db047cd3591e3aff Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 11:38:53 +0200 Subject: [PATCH 28/64] fd --- files/templates/settings.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/templates/settings.html b/files/templates/settings.html index d594176879..b30bccb51f 100644 --- a/files/templates/settings.html +++ b/files/templates/settings.html @@ -157,7 +157,7 @@ Apps From a3d83f9413d5b3f3313c3fc99c0f9ac240c21e4c Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 11:42:08 +0200 Subject: [PATCH 29/64] fd --- files/templates/emoji_modal.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/files/templates/emoji_modal.html b/files/templates/emoji_modal.html index 601deb7d25..2c4355d71f 100644 --- a/files/templates/emoji_modal.html +++ b/files/templates/emoji_modal.html @@ -1,5 +1,5 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/files/templates/index.html b/files/templates/index.html deleted file mode 100644 index 7bc1312cfb..0000000000 --- a/files/templates/index.html +++ /dev/null @@ -1,8 +0,0 @@ - -
-

{{greeting}}

-

[[ greeting ]]

-
- - - \ No newline at end of file diff --git a/files/templates/shop.html b/files/templates/settings_shop.html similarity index 100% rename from files/templates/shop.html rename to files/templates/settings_shop.html From 50ab21b262b906faa93fdbe5874a5bcc1af7400e Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 13:19:06 +0200 Subject: [PATCH 34/64] fdfd --- files/templates/submit.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/templates/submit.html b/files/templates/submit.html index a81f555a03..772cad0adf 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -7,7 +7,7 @@ - + + + + + +NIGGER NIGGER NIGGER \ No newline at end of file diff --git a/files/templates/comments.html b/files/templates/comments.html index 6a04f25f59..b0f0053c76 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -271,8 +271,7 @@
  • Save
  • {% if v.id!=c.author_id %} -
  • Give Award
  • +
  • Give Award
  • {% endif %}
  • Reply
  • From c9c207ed1ff8fb66db13002bf3b139809fab61cc Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 13:25:14 +0200 Subject: [PATCH 37/64] fd --- files/templates/award_modal.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/templates/award_modal.html b/files/templates/award_modal.html index d69b4fe452..5f5a17a8d5 100644 --- a/files/templates/award_modal.html +++ b/files/templates/award_modal.html @@ -1,7 +1,7 @@ - +{% if v %} + {% include "gif_modal.html" %} + {% include "emoji_modal.html" %} + {% include "award_modal.html" %} + {% include "delete_comment_modal.html" %} +{% endif %} +{% include "expanded_image_modal.html" %} +{% include "flag_comment_modal.html" %} \ No newline at end of file diff --git a/files/templates/default.html b/files/templates/default.html index 8647c9751d..82566c6adb 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -1297,7 +1297,7 @@ {% block mobilenavbar %} -{% include "mobile_navigation_bar.html" %} + {% include "mobile_navigation_bar.html" %} {% endblock %} {% block actionsModal %} @@ -1337,17 +1337,6 @@ -{% if v %} -{% include "award_modal.html" %} -{% include "flag_post_modal.html" %} -{% include "flag_comment_modal.html" %} -{% include "gif_modal.html" %} -{% include "delete_comment_modal.html" %} -{% include "delete_post_modal.html" %} -{% endif %} - -{% include "expanded_image_modal.html" %} - diff --git a/files/templates/submission.html b/files/templates/submission.html index 4b6ef7b459..83767f63e6 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -669,7 +669,7 @@ {% if p.replies %}
    {% with comments=p.replies %} - {% include "comments.html" %} + {% include "comments.html" %} {% endwith %}
    {% elif not p.replies and p.deleted_utc == 0 %} @@ -692,11 +692,9 @@ {% if v and v.id==p.author_id %} -{% include "delete_post_modal.html" %} + {% include "delete_post_modal.html" %} {% endif %} -{% include "delete_comment_modal.html" %} - {% endblock %} @@ -709,8 +707,8 @@ {% endblock %} {% block GIFpicker %} -{% if v %} -{% include "gif_modal.html" %} -{% include "emoji_modal.html" %} -{% endif %} -{% endblock %} + {% if v %} + {% include "award_modal.html" %} + {% endif %} + {% include "expanded_image_modal.html" %} +{% endblock %} \ No newline at end of file diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index 0652025caa..9c09dcb450 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -496,4 +496,9 @@ {% endfor %} -{% include "delete_post_modal.html" %} \ No newline at end of file +{% if v %} + {% include "award_modal.html" %} + {% include "delete_post_modal.html" %} +{% endif %} +{% include "expanded_image_modal.html" %} +{% include "flag_post_modal.html" %} \ No newline at end of file From 9f6b5783b036d6ede3e079c2781aab7d060875c6 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 13:44:09 +0200 Subject: [PATCH 39/64] fdfd --- files/classes/user.py | 73 +++++++++++++++++++++++++------- files/routes/awards.py | 14 ------ files/templates/award_modal.html | 2 +- 3 files changed, 59 insertions(+), 30 deletions(-) diff --git a/files/classes/user.py b/files/classes/user.py index 254d49ea35..024cf9b35e 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -23,6 +23,53 @@ defaultcolor = environ.get("DEFAULT_COLOR", "fff").strip() defaulttimefilter = environ.get("DEFAULT_TIME_FILTER", "all").strip() cardview = bool(int(environ.get("CARD_VIEW", 1))) +if site_name == "Drama": + AWARDS = { + "ban": { + "kind": "ban", + "title": "One-Day Ban", + "description": "Bans the author for a day.", + "icon": "fas fa-gavel", + "color": "text-danger", + "price": 5000 + }, + "shit": { + "kind": "shit", + "title": "Shit", + "description": "Makes flies swarm a post.", + "icon": "fas fa-poop", + "color": "text-black-50", + "price": 1000 + }, + "stars": { + "kind": "stars", + "title": "Stars", + "description": "Puts stars on the post.", + "icon": "fas fa-sparkles", + "color": "text-warning", + "price": 1000 + } + } +else: + AWARDS = { + "shit": { + "kind": "shit", + "title": "shit", + "description": "Makes flies swarm a post.", + "icon": "fas fa-poop", + "color": "text-black-50", + "price": 1000 + }, + "stars": { + "kind": "stars", + "title": "Stars", + "description": "Puts stars on the post.", + "icon": "fas fa-sparkles", + "color": "text-warning", + "price": 1000 + } + } + class User(Base, Stndrd, Age_times): __tablename__ = "users" id = Column(Integer, primary_key=True) @@ -288,21 +335,6 @@ class User(Base, Stndrd, Age_times): return f"Unban in {text}" - @property - @lazy - def display_awards(self): - - awards = {} - active_awards = [x for x in self.awards if not x.given] - - for a in active_awards: - if a.kind in awards: - awards[a.kind]['count'] += 1 - else: - awards[a.kind] = a.type - awards[a.kind]['count'] = 1 - - return sorted(list(awards.values()), key=lambda x: x['kind'], reverse=True) @property @lazy @@ -626,3 +658,14 @@ class ViewerRelationship(Base): else: years = int(months / 12) return f"{years}yr ago" + +@property +@lazy +def user_awards(v): + + return_value = list(AWARDS.values()) + + user_awards = v.awards + for val in return_value: val['owned'] = user_awards.filter_by(kind=val['kind'], submission_id=None, comment_id=None).count() + + return jsonify(return_value) diff --git a/files/routes/awards.py b/files/routes/awards.py index 8ec44509cb..bc230d0d83 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -183,20 +183,6 @@ ALLOW_MULTIPLE = ( "stars" ) - -@app.get("/awards") -@auth_required -def get_awards(v): - - return_value = list(AWARDS.values()) - - user_awards = v.awards - for val in return_value: - val['owned'] = user_awards.filter_by(kind=val['kind'], submission_id=None, comment_id=None).count() - - return jsonify(return_value) - - @app.post("/post//awards") @auth_required @validate_formkey diff --git a/files/templates/award_modal.html b/files/templates/award_modal.html index c2d2ff91d6..3f8e6c34c0 100644 --- a/files/templates/award_modal.html +++ b/files/templates/award_modal.html @@ -1,6 +1,6 @@ -
    {{awards}}
    +
    {{v.user_awards}}
    + + \ No newline at end of file From 28acb84d5eee7623f3c506bbf32f9eb7df10974b Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 17 Sep 2021 16:02:05 +0200 Subject: [PATCH 63/64] fddf --- files/templates/award_modal.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/templates/award_modal.html b/files/templates/award_modal.html index 54fdeaccf0..eecf2c7f08 100644 --- a/files/templates/award_modal.html +++ b/files/templates/award_modal.html @@ -11,7 +11,7 @@