forked from MarseyWorld/MarseyWorld
fds
parent
44055f3e52
commit
88dc847861
|
@ -57,7 +57,7 @@ app.config["RATELIMIT_ENABLED"] = True
|
|||
app.config["RATELIMIT_DEFAULTS_DEDUCT_WHEN"]=lambda:True
|
||||
app.config["RATELIMIT_DEFAULTS_EXEMPT_WHEN"]=lambda:False
|
||||
app.config["RATELIMIT_HEADERS_ENABLED"]=True
|
||||
app.config["CACHE_TYPE"] = "redis"
|
||||
app.config["CACHE_TYPE"] = "filesystem"
|
||||
app.config["CACHE_DIR"] = "cache"
|
||||
app.config["RATELIMIT_STORAGE_URL"] = environ.get("REDIS_URL", "redis://localhost")
|
||||
app.config['MAIL_SERVER'] = 'smtp.gmail.com'
|
||||
|
|
|
@ -1029,14 +1029,14 @@ def api_sticky_post(post_id, v):
|
|||
post = g.db.query(Submission).filter_by(id=post_id).first()
|
||||
if post:
|
||||
if post.stickied:
|
||||
if post.stickied.startswith("t:"): return {"error": "Can't unpin temporary pins!"}, 403
|
||||
if post.stickied.startswith("t:"): return {"error": "Can't unpin award pins!"}, 403
|
||||
else: post.stickied = None
|
||||
else:
|
||||
pins = g.db.query(Submission.id).filter(Submission.stickied != None, Submission.is_banned == False).count()
|
||||
if pins > 2:
|
||||
if v.admin_level > 2:
|
||||
t = int(time.time()) + 3600
|
||||
post.stickied = f"t:{t}"
|
||||
post.stickied = f"j:{t}"
|
||||
else: return {"error": "Can't exceed 3 pinned posts limit!"}, 403
|
||||
else: post.stickied = v.username
|
||||
g.db.add(post)
|
||||
|
|
|
@ -276,10 +276,20 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
|
|||
blocked = [x[0] for x in g.db.query(UserBlock.user_id).filter_by(target_id=v.id).all()]
|
||||
pins = pins.filter(Submission.author_id.notin_(blocking), Submission.author_id.notin_(blocked))
|
||||
|
||||
posts = pins.all() + posts
|
||||
pins = pins.all()
|
||||
|
||||
for pin in pins:
|
||||
if (pin.stickied.startswith("t:") or pin.stickied.startswith("j:")) and int(time.time()) > int(pin.stickied[2:]):
|
||||
pin.stickied = None
|
||||
g.db.add(pin)
|
||||
pins.remove(pin)
|
||||
|
||||
posts = pins + posts
|
||||
|
||||
if ids_only: posts = [x.id for x in posts]
|
||||
|
||||
g.db.commit()
|
||||
|
||||
return posts, next_exists
|
||||
|
||||
|
||||
|
|
|
@ -217,6 +217,12 @@ def post_id(pid, anything=None, v=None):
|
|||
if len(comments) == len(comments2): offset = None
|
||||
comments = comments2
|
||||
|
||||
for pin in pinned:
|
||||
if pin.is_pinned.startswith("t:") and int(time.time()) > int(pin.is_pinned[2:]):
|
||||
pin.is_pinned = None
|
||||
g.db.add(pin)
|
||||
pinned.remove(pin)
|
||||
|
||||
post.replies = pinned + comments
|
||||
|
||||
post.views += 1
|
||||
|
|
|
@ -5,7 +5,6 @@ from files.classes import *
|
|||
from flask import *
|
||||
from files.__main__ import app, limiter, cache
|
||||
from sqlalchemy.orm import joinedload
|
||||
from .front import frontlist
|
||||
from os import environ
|
||||
|
||||
defaultcolor = environ.get("DEFAULT_COLOR").strip()
|
||||
|
@ -114,11 +113,6 @@ def api_vote_post(post_id, new, v):
|
|||
real = real
|
||||
)
|
||||
g.db.add(vote)
|
||||
|
||||
if post.stickied and post.stickied.startswith("t:") and int(time.time()) > int(post.stickied[2:]):
|
||||
post.stickied = None
|
||||
g.db.add(post)
|
||||
cache.delete_memoized(frontlist)
|
||||
|
||||
try:
|
||||
g.db.flush()
|
||||
|
@ -187,10 +181,6 @@ def api_vote_comment(comment_id, new, v):
|
|||
|
||||
g.db.add(vote)
|
||||
|
||||
if comment.is_pinned and comment.is_pinned.startswith("t:") and int(time.time()) > int(comment.is_pinned[2:]):
|
||||
comment.is_pinned = None
|
||||
g.db.add(comment)
|
||||
|
||||
try:
|
||||
g.db.flush()
|
||||
comment.upvotes = g.db.query(CommentVote.id).filter_by(comment_id=comment.id, vote_type=1).count()
|
||||
|
|
|
@ -323,7 +323,7 @@
|
|||
{% endif %}
|
||||
{% if v and v.admin_level > 1 and p.author.shadowbanned %}<i class="fas fa-user-times text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" data-bs-original-title="Shadowbanned by @{{p.author.shadowbanned}}"></i>{% endif %}
|
||||
|
||||
{% if p.stickied and p.stickied.startswith('t:') %}
|
||||
{% if p.stickied and (p.stickied.startswith('t:') or p.stickied.startswith('j:')) %}
|
||||
<i id='pinned-{{p.id}}' onmouseover="pinned_timestamp('pinned-{{p.id}}')" class="fas fa-thumbtack fa-rotate--45 text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" data-timestamp={{p.stickied[2:]}}></i>
|
||||
{% elif p.stickied %}
|
||||
<i id='pinned-{{p.id}}' class="fas fa-thumbtack fa-rotate--45 text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" data-bs-original-title="Pinned by @{{p.stickied}}"></i>
|
||||
|
|
|
@ -166,7 +166,7 @@
|
|||
{% endif %}
|
||||
{% if v and v.admin_level > 1 and p.author.shadowbanned %}<i class="fas fa-user-times text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" data-bs-original-title="Shadowbanned by @{{p.author.shadowbanned}}"></i>{% endif %}
|
||||
|
||||
{% if p.stickied and p.stickied.startswith('t:') %}
|
||||
{% if p.stickied and (p.stickied.startswith('t:') or p.stickied.startswith('j:')) %}
|
||||
<i id='pinned-{{p.id}}' onmouseover="pinned_timestamp('pinned-{{p.id}}')" class="fas fa-thumbtack fa-rotate--45 text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" data-timestamp={{p.stickied[2:]}}*1000></i>
|
||||
{% elif p.stickied %}
|
||||
<i id='pinned-{{p.id}}' class="fas fa-thumbtack fa-rotate--45 text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" data-bs-original-title="Pinned by @{{p.stickied}}"></i>
|
||||
|
|
|
@ -34,5 +34,4 @@ INSERT INTO public.users (
|
|||
'', 'dark', '30409f', false, false, '', '', 0, false, 0,
|
||||
0, 0, '', true, 0);
|
||||
|
||||
|
||||
SELECT pg_catalog.setval('public.users_id_seq', 6, true);
|
||||
SELECT pg_catalog.setval('public.users_id_seq', 7, true);
|
Loading…
Reference in New Issue