remotes/1693045480750635534/spooky-22
Aevann1 2021-07-28 12:57:26 +02:00
parent a3516cd1c9
commit 0ce8a0645c
2 changed files with 6 additions and 14 deletions

View File

@ -17,7 +17,7 @@ def feeds_user(sort='hot', t='all'):
page=page,
t=t,
v=None,
ids_only=False)
)
domain = environ.get(
"domain", environ.get(

View File

@ -70,7 +70,7 @@ def notifications(v):
is_notification_page=True)
@cache.memoize(timeout=1500)
def frontlist(v=None, sort="hot", page=1,t="all", ids_only=True, filter_words='', **kwargs):
def frontlist(v=None, sort="hot", page=1,t="all", filter_words='', **kwargs):
posts = g.db.query(Submission).options(lazyload('*')).filter_by(is_banned=False,stickied=False,private=False).filter(Submission.deleted_utc == 0)
if v and v.admin_level == 0:
@ -169,12 +169,7 @@ def frontlist(v=None, sort="hot", page=1,t="all", ids_only=True, filter_words=''
post.views = post.views + random.randint(7,10)
g.db.add(post)
posts = [x for x in posts if not (x.author and x.author.shadowbanned) or (v and v.id == x.author_id)][:26]
if ids_only:
posts = [x.id for x in posts]
return posts
return posts
return [x for x in posts if not (x.author and x.author.shadowbanned) or (v and v.id == x.author_id)][:26]
@app.get("/")
@app.get("/api/v1/listing")
@ -198,7 +193,7 @@ def front_all(v):
sort=request.args.get("sort", defaultsorting)
t=request.args.get('t', defaulttime)
ids = frontlist(sort=sort,
posts = frontlist(sort=sort,
page=page,
t=t,
v=v,
@ -208,11 +203,8 @@ def front_all(v):
)
# check existence of next page
next_exists = (len(ids) == 26)
ids = ids[0:25]
# check if ids exist
posts = get_posts(ids, v=v)
next_exists = (len(posts) == 26)
posts = posts[0:25]
if request.path == "/": return render_template("home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page)
else: return jsonify({"data": [x.json for x in posts], "next_exists": next_exists})