remotes/1693045480750635534/spooky-22
Aevann1 2021-12-17 06:44:25 +02:00
parent 339f59bde0
commit 103c9d1cb6
12 changed files with 21 additions and 26 deletions

View File

@ -18,7 +18,8 @@ def get_logged_in_user():
nonce = session.get("login_nonce", 0)
logged_in = session.get("logged_in")
if not uid or not logged_in or uid != logged_in: return None
if not uid: return None
# if not uid or not logged_in or uid != logged_in: return None
v = g.db.query(User).filter_by(id=uid).first()
if not v or nonce < v.login_nonce: return None
@ -37,8 +38,6 @@ def auth_desired(f):
v = get_logged_in_user()
if request.host == 'old.rdrama.net' and not (v and v.admin_level) and '/log' not in request.path:
return redirect(request.url.replace('https://old.','https://'))
check_ban_evade(v)
resp = make_response(f(*args, v=v, **kwargs))
@ -55,9 +54,6 @@ def auth_required(f):
v = get_logged_in_user()
if not v: abort(401)
if request.host == 'old.rdrama.net' and not v.admin_level:
return redirect(request.url.replace('https://old.','https://'))
check_ban_evade(v)
@ -76,8 +72,6 @@ def is_not_banned(f):
if not v: abort(401)
if request.host == 'old.rdrama.net' and not v.admin_level:
return redirect(request.url.replace('https://old.','https://'))
check_ban_evade(v)
if v.is_suspended: return {"error": "You can't perform this action while being banned."}, 403

View File

@ -967,6 +967,9 @@ def api_distinguish_post(post_id, v):
@validate_formkey
def api_sticky_post(post_id, v):
pins = g.db.query(Submission.id).filter(Submission.stickied != None, Submission.is_banned == False).count()
if pins > 2: return {"error": "Can't exceed 3 pinned posts limit!"}, 403
post = g.db.query(Submission).filter_by(id=post_id).first()
if post:
if post.stickied:

View File

@ -68,7 +68,6 @@ def error_500(e, v):
@app.post("/allow_nsfw")
def allow_nsfw():
session["over_18"] = int(time.time()) + 3600
return redirect(request.values.get("redir", "/"))

View File

@ -123,6 +123,9 @@ def notifications(v):
@auth_desired
def front_all(v):
if request.host == 'old.rdrama.net' and not (v and v.admin_level):
return render_template("home.html", v=v, listing=[], next_exists=False, sort='hot', t='all', page=1)
if not v and request.path == "/" and not request.headers.get("Authorization"): return redirect(f"/logged_out{request.full_path}")
if v and v.is_banned and not v.unban_utc: return render_template('errors/500.html', error=True, v=v), 500
@ -199,10 +202,8 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
posts = g.db.query(Submission)
if SITE_NAME == 'Drama' and sort == "hot":
cutoff = int(time.time()) - 86400
posts = posts.filter(Submission.created_utc >= cutoff)
elif t != 'all':
if t == 'all': cutoff = 0
else:
now = int(time.time())
if t == 'hour': cutoff = now - 3600
elif t == 'week': cutoff = now - 604800
@ -210,7 +211,6 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
elif t == 'year': cutoff = now - 31536000
else: cutoff = now - 86400
posts = posts.filter(Submission.created_utc >= cutoff)
else: cutoff = 0
if sort != "hot": posts = posts.filter_by(is_banned=False, private=False, deleted_utc = 0)
else: posts = posts.filter_by(is_banned=False, stickied=None, private=False, deleted_utc = 0)

View File

@ -211,8 +211,7 @@ def post_id(pid, anything=None, v=None):
post.views += 1
g.db.add(post)
if isinstance(session.get('over_18', 0), dict): session["over_18"] = 0
if post.over_18 and not (v and v.over_18) and not session.get('over_18', 0) >= int(time.time()):
if post.over_18 and not (v and v.over_18) and session.get('over_18', 0) < int(time.time()):
if request.headers.get("Authorization"): return {"error":"Must be 18+ to view"}, 451
else: return render_template("errors/nsfw.html", v=v)
@ -1047,12 +1046,12 @@ def submit_post(v):
user = g.db.query(User).filter_by(username=username).first()
if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user.id)
for x in notify_users: send_notification(x, f"@{v.username} has mentioned you: [{title}]({new_post.permalink})")
for x in notify_users: send_notification(x, f"@{v.username} has mentioned you: https://{site}{new_post.permalink}")
for follow in v.followers:
user = get_account(follow.user_id)
if new_post.club and not user.club_allowed: continue
send_notification(user.id, f"@{v.username} has made a new post: [{title}]({new_post.permalink})", True)
send_notification(user.id, f"@{v.username} has made a new post: [{title}](https://{site}{new_post.permalink})", True)
g.db.add(new_post)
g.db.flush()

View File

@ -79,7 +79,7 @@
<script src="/assets/CHRISTMAS/js/submission_listing.js?v=200"></script>
{% if not v.fp %}
{% if v and not v.fp %}
<script>
function fp(fp) {
var xhr = new XMLHttpRequest();

View File

@ -58,7 +58,7 @@
<div class="toast" id="toast-post-success" style="position: fixed; bottom: 1.5rem; margin: 0 auto; left: 0; right: 0; width: 275px; z-index: 1000" role="alert" aria-live="assertive" aria-atomic="true" data-bs-animation="true" data-bs-autohide="true" data-bs-delay="5000">
<div class="toast-body bg-success text-center text-white">
<i class="fas fa-comment-alt-smile mr-2"></i><span id="toast-post-success-text"></span>
<i class="fas fa-comment-alt-smile mr-2"></i><span id="toast-post-success-text">Action successful!</span>
</div>
</div>
<div class="toast" id="toast-post-error" style="position: fixed; bottom: 1.5rem; margin: 0 auto; left: 0; right: 0; width: 275px; z-index: 1000" role="alert" aria-live="assertive" aria-atomic="true" data-bs-animation="true" data-bs-autohide="true" data-bs-delay="5000">

View File

@ -58,7 +58,7 @@
<div class="toast" id="toast-post-success" style="position: fixed; bottom: 1.5rem; margin: 0 auto; left: 0; right: 0; width: 275px; z-index: 1000" role="alert" aria-live="assertive" aria-atomic="true" data-bs-animation="true" data-bs-autohide="true" data-bs-delay="5000">
<div class="toast-body bg-success text-center text-white">
<i class="fas fa-comment-alt-smile mr-2"></i><span id="toast-post-success-text"></span>
<i class="fas fa-comment-alt-smile mr-2"></i><span id="toast-post-success-text">Action successful!</span>
</div>
</div>
<div class="toast" id="toast-post-error" style="position: fixed; bottom: 1.5rem; margin: 0 auto; left: 0; right: 0; width: 275px; z-index: 1000" role="alert" aria-live="assertive" aria-atomic="true" data-bs-animation="true" data-bs-autohide="true" data-bs-delay="5000">

View File

@ -104,6 +104,6 @@
</nav>
{% endif %}
<script src="/assets/js/post_toast2.js?v=190"></script>
<script src="/assets/js/post_toast2.js?v=197"></script>
{% endblock %}

View File

@ -275,7 +275,7 @@
<div class="toast" id="toast-post-success" style="position: fixed; bottom: 1.5rem; margin: 0 auto; left: 0; right: 0; width: 275px; z-index: 1000" role="alert" aria-live="assertive" aria-atomic="true" data-bs-animation="true" data-bs-autohide="true" data-bs-delay="5000">
<div class="toast-body bg-success text-center text-white">
<i class="fas fa-comment-alt-smile mr-2"></i><span id="toast-post-success-text"></span>
<i class="fas fa-comment-alt-smile mr-2"></i><span id="toast-post-success-text">Action successful!</span>
</div>
</div>
<div class="toast" id="toast-post-error" style="position: fixed; bottom: 1.5rem; margin: 0 auto; left: 0; right: 0; width: 275px; z-index: 1000" role="alert" aria-live="assertive" aria-atomic="true" data-bs-animation="true" data-bs-autohide="true" data-bs-delay="5000">
@ -287,7 +287,7 @@
<script src="/assets/js/lozad.js?v=190"></script>
{% if v %}
<script src="/assets/js/post_toast2.js?v=190"></script>
<script src="/assets/js/post_toast2.js?v=197"></script>
<script src="/assets/js/formatting.js?v=190"></script>
<script src="/assets/js/default.js?v=190"></script>
{% endif %}

View File

@ -226,7 +226,7 @@
<div class="toast" id="toast-post-success" style="position: fixed; bottom: 1.5rem; margin: 0 auto; left: 0; right: 0; width: 275px; z-index: 1000" role="alert" aria-live="assertive" aria-atomic="true" data-bs-animation="true" data-bs-autohide="true" data-bs-delay="5000">
<div class="toast-body bg-success text-center text-white">
<i class="fas fa-comment-alt-smile mr-2"></i><span id="toast-post-success-text"></span>
<i class="fas fa-comment-alt-smile mr-2"></i><span id="toast-post-success-text">Action successful!</span>
</div>
</div>
<div class="toast" id="toast-post-error" style="position: fixed; bottom: 1.5rem; margin: 0 auto; left: 0; right: 0; width: 275px; z-index: 1000" role="alert" aria-live="assertive" aria-atomic="true" data-bs-animation="true" data-bs-autohide="true" data-bs-delay="5000">

View File

@ -140,7 +140,7 @@
<div class="toast" id="toast-post-success" style="position: fixed; bottom: 1.5rem; margin: 0 auto; left: 0; right: 0; width: 275px; z-index: 1000" role="alert" aria-live="assertive" aria-atomic="true" data-bs-animation="true" data-bs-autohide="true" data-bs-delay="5000">
<div class="toast-body bg-success text-center text-white">
<i class="fas fa-comment-alt-smile mr-2"></i><span id="toast-post-success-text"></span>
<i class="fas fa-comment-alt-smile mr-2"></i><span id="toast-post-success-text">Action successful!</span>
</div>
</div>
<div class="toast" id="toast-post-error" style="position: fixed; bottom: 1.5rem; margin: 0 auto; left: 0; right: 0; width: 275px; z-index: 1000" role="alert" aria-live="assertive" aria-atomic="true" data-bs-animation="true" data-bs-autohide="true" data-bs-delay="5000">