Merge remote-tracking branch 'upstream/frost' into 601_convert_created_utc_to_datetimez_for_follows

This commit is contained in:
Viet Than 2023-07-29 21:37:45 -04:00
commit 6b880dc539
119 changed files with 1319 additions and 1394 deletions

View file

@ -377,7 +377,7 @@ def leaderboard(v:User):
comments = SimpleLeaderboard(v, LeaderboardMeta("Comments", "comment count", "comments", "Comments", "comments"), g.db, users, User.comment_count)
received_awards = SimpleLeaderboard(v, LeaderboardMeta("Awards", "received awards", "awards", "Awards", None), g.db, users, User.received_award_count)
coins_spent = SimpleLeaderboard(v, LeaderboardMeta("Spent in shop", "coins spent in shop", "spent", "Coins", None), g.db, users, User.coins_spent)
truescore = SimpleLeaderboard(v, LeaderboardMeta("Truescore", "truescore", "truescore", "Truescore", None), g.db, users, User.truecoins)
truescore = SimpleLeaderboard(v, LeaderboardMeta("Truescore", "truescore", "truescore", "Truescore", None), g.db, users, User.truescore)
badges = BadgeMarseyLeaderboard(v, LeaderboardMeta("Badges", "badges", "badges", "Badges", None), g.db, Badge.user_id)
blocks = UserBlockLeaderboard(v, LeaderboardMeta("Blocked", "most blocked", "blocked", "Blocked By", "blockers"), g.db, UserBlock.target_id)
@ -619,7 +619,7 @@ def api_is_available(name):
def user_id(id:int):
user = get_account(id)
return redirect(user.url)
@app.get("/u/<username>")
def redditor_moment_redirect(username:str):
return redirect(f"/@{username}")
@ -646,13 +646,12 @@ def visitors(v):
return render_template("viewers.html", v=v, viewers=viewers)
@app.get("/@<username>")
@app.get("/@<username>/posts")
@auth_desired
def u_username(username, v=None):
u = get_user(username, v=v, include_blocks=True)
if username != u.username:
return redirect(SITE_FULL + request.full_path.replace(username, u.username)[:-1])
if username != u.username: return redirect(f'/@{u.username}/posts')
if u.reserved:
if request.headers.get("Authorization") or request.headers.get("xhr"): abort(403, f"That username is reserved for: {u.reserved}")
@ -698,7 +697,7 @@ def u_username(username, v=None):
if u.unban_utc:
if request.headers.get("Authorization"): {"data": [x.json for x in listing]}
return render_template("userpage.html",
return render_template("userpage_submissions.html",
unban=u.unban_string,
u=u,
v=v,
@ -712,7 +711,7 @@ def u_username(username, v=None):
if request.headers.get("Authorization"): return {"data": [x.json for x in listing]}
return render_template("userpage.html",
return render_template("userpage_submissions.html",
u=u,
v=v,
listing=listing,
@ -723,12 +722,13 @@ def u_username(username, v=None):
is_following=(v and u.has_follower(v)))
@app.get("/@<username>/comments")
@app.get("/@<username>/")
@auth_desired
def u_username_comments(username, v=None):
user = get_user(username, v=v, include_blocks=True)
if username != user.username: return redirect(f'/@{user.username}/comments')
if username != user.username:
return redirect(SITE_FULL + request.full_path.replace(username, user.username)[:-1])
u = user
if u.reserved:
@ -803,6 +803,7 @@ def u_user_id_info(id, v=None):
return user.json
@app.post("/follow/<username>")
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@auth_required
@ -935,13 +936,14 @@ def saved_posts(v, username):
listing = get_posts(ids, v=v, eager=True)
if request.headers.get("Authorization"): return {"data": [x.json for x in listing]}
return render_template("userpage.html",
u=v,
v=v,
listing=listing,
page=page,
next_exists=next_exists,
)
return render_template(
"userpage_submissions.html",
u=v,
v=v,
listing=listing,
page=page,
next_exists=next_exists,
)
@app.get("/@<username>/saved/comments")
@ -959,13 +961,15 @@ def saved_comments(v, username):
if request.headers.get("Authorization"): return {"data": [x.json for x in listing]}
return render_template("userpage_comments.html",
u=v,
v=v,
listing=listing,
page=page,
next_exists=next_exists,
standalone=True)
return render_template(
"userpage_comments.html",
u=v,
v=v,
listing=listing,
page=page,
next_exists=next_exists,
standalone=True
)
@app.post("/fp/<fp>")