Merge branch 'frost' of https://github.com/Aevann1/rDrama into frost

master
Aevann1 2022-09-11 14:39:10 +00:00
commit c015c6ee48
12 changed files with 61 additions and 54 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 497 KiB

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

@ -26,7 +26,7 @@ class Sub(Base):
followers = relationship("SubSubscription", primaryjoin="SubSubscription.sub==Sub.name")
def __repr__(self):
return f"<Sub(name={self.name})>"
return self.name
@property
@lazy

View File

@ -170,7 +170,7 @@ def make_admin(v, username):
)
g.db.add(ma)
return {"message": "User has been made admin!"}
return {"message": f"@{user.username} has been made admin!"}
@app.post("/@<username>/remove_admin")
@ -187,7 +187,7 @@ def remove_admin(v, username):
)
g.db.add(ma)
return {"message": "Admin removed!"}
return {"message": f"@{user.username} has been removed as admin!"}
@app.post("/distribute/<option_id>")
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@ -299,7 +299,7 @@ def revert_actions(v, username):
send_repeatable_notification(u.id, f"@{v.username} has unbanned you!")
g.db.add(u)
return {"message": "Admin actions reverted!"}
return {"message": f"@{user.username}'s admin actions has been reverted!"}
@app.post("/@<username>/club_allow")
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@ -326,7 +326,7 @@ def club_allow(v, username):
)
g.db.add(ma)
return {"message": f"@{username} has been allowed into the {CC_TITLE}!"}
return {"message": f"@{u.username} has been allowed into the {CC_TITLE}!"}
@app.post("/@<username>/club_ban")
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@ -352,7 +352,7 @@ def club_ban(v, username):
)
g.db.add(ma)
return {"message": f"@{username} has been kicked from the {CC_TITLE}. Deserved."}
return {"message": f"@{u.username} has been kicked from the {CC_TITLE}. Deserved."}
@app.get("/admin/shadowbanned")
@ -897,7 +897,7 @@ def unagendaposter(user_id, v):
send_repeatable_notification(user.id, f"@{v.username} has unmarked you as a chud.")
return {"message": "Chud theme disabled!"}
return {"message": f"@{user.username}'s chud theme has been disabled!"}
@app.post("/shadowban/<user_id>")
@ -922,7 +922,7 @@ def shadowban(user_id, v):
g.db.add(ma)
cache.delete_memoized(frontlist)
return {"message": "User shadowbanned!"}
return {"message": f"@{user.username} has been shadowbanned!"}
@app.post("/unshadowban/<user_id>")
@ -947,7 +947,7 @@ def unshadowban(user_id, v):
cache.delete_memoized(frontlist)
return {"message": "User unshadowbanned!"}
return {"message": f"@{user.username} has been unshadowbanned!"}
@app.post("/admin/title_change/<user_id>")
@ -1045,7 +1045,7 @@ def ban_user(user_id, v):
g.db.add(comment)
if 'redir' in request.values: return redirect(user.url)
else: return {"message": f"@{user.username} was banned!"}
else: return {"message": f"@{user.username} has been banned!"}
@app.post("/unban_user/<user_id>")
@ -1079,7 +1079,7 @@ def unban_user(user_id, v):
g.db.add(ma)
if "@" in request.referrer: return redirect(user.url)
else: return {"message": f"@{user.username} was unbanned!"}
else: return {"message": f"@{user.username} has been unbanned!"}
@app.post("/mute_user/<int:user_id>/<int:mute_status>")
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@ -1090,11 +1090,11 @@ def mute_user(v, user_id, mute_status):
if mute_status != 0 and not user.is_muted:
user.is_muted = True
log_action = 'mod_mute_user'
success_msg = f"@{user.username} was muted!"
success_msg = f"@{user.username} has been muted!"
elif mute_status == 0 and user.is_muted:
user.is_muted = False
log_action = 'mod_unmute_user'
success_msg = f"@{user.username} was un-muted!"
success_msg = f"@{user.username} has been un-muted!"
else:
abort(400)

View File

@ -221,11 +221,14 @@ def submit_hat(v):
os.remove(highquality)
return error("Images must be 100x130")
if len(list(Iterator(i))) > 1: price = 1000
else: price = 500
filename = f'/asset_submissions/hats/{name}.webp'
copyfile(highquality, filename)
process_image(filename)
hat = HatDef(name=name, author_id=author.id, description=description, price=500, submitter_id=v.id)
hat = HatDef(name=name, author_id=author.id, description=description, price=price, submitter_id=v.id)
g.db.add(hat)
g.db.commit()

View File

@ -116,7 +116,7 @@ def buy(v, award):
send_repeatable_notification(CARP_ID, f"@{v.username} has bought a `{award}` award!")
return {"message": "Award bought!"}
return {"message": f"{award} award bought!"}
@app.post("/award/<thing_type>/<id>")
@limiter.limit("1/second;30/minute;200/hour;1000/day")

View File

@ -76,7 +76,7 @@ def buy_hat(v, hat_id):
elif v.num_of_owned_hats >= 25:
badge_grant(user=v, badge_id=152)
return {"message": "Hat bought!"}
return {"message": f"'{hat.name}' bought!"}
@app.post("/equip_hat/<hat_id>")
@ -93,7 +93,7 @@ def equip_hat(v, hat_id):
hat.equipped = True
g.db.add(hat)
return {"message": "Hat equipped!"}
return {"message": f"'{hat.name}' equipped!"}
@app.post("/unequip_hat/<hat_id>")
@auth_required
@ -109,7 +109,7 @@ def unequip_hat(v, hat_id):
hat.equipped = False
g.db.add(hat)
return {"message": "Hat unequipped!"}
return {"message": f"'{hat.name}' unequipped!"}
@app.get("/hat_owners/<hat_id>")
@auth_required

View File

@ -164,7 +164,7 @@ def admin_app_approve(v, aid):
g.db.add(ma)
return {"message": "Application approved"}
return {"message": f"'{app.app_name}' approved!"}
@app.post("/admin/app/revoke/<aid>")
@ -189,7 +189,7 @@ def admin_app_revoke(v, aid):
g.db.add(ma)
return {"message": "App revoked"}
return {"message": f"'{app.app_name}' revoked!"}
@app.post("/admin/app/reject/<aid>")
@ -214,7 +214,7 @@ def admin_app_reject(v, aid):
g.db.add(ma)
return {"message": "App rejected"}
return {"message": f"'{app.app_name}' rejected!"}
@app.get("/admin/app/<aid>")
@ -290,4 +290,4 @@ def reroll_oauth_tokens(aid, v):
g.db.add(a)
return {"message": "Client ID Rerolled", "id": a.client_id}
return {"message": f"Client ID for '{a.app_name}' has been rerolled!", "id": a.client_id}

View File

@ -315,7 +315,7 @@ def namecolor(v):
if color.startswith('#'): color = color[1:]
if not color_regex.fullmatch(color):
return render_template("settings_profile.html", v=v, error="Invalid color code")
return render_template("settings_profile.html", v=v, error="Invalid color hex code")
v.namecolor = color
g.db.add(v)
@ -331,7 +331,7 @@ def themecolor(v):
if themecolor.startswith('#'): themecolor = themecolor[1:]
if not color_regex.fullmatch(themecolor):
return render_template("settings_profile.html", v=v, error="Invalid color code")
return render_template("settings_profile.html", v=v, error="Invalid color hex code")
v.themecolor = themecolor
g.db.add(v)
@ -384,7 +384,7 @@ def titlecolor(v):
if titlecolor.startswith('#'): titlecolor = titlecolor[1:]
if not color_regex.fullmatch(titlecolor):
return render_template("settings_profile.html", v=v, error="Invalid color code")
return render_template("settings_profile.html", v=v, error="Invalid color hex code")
v.titlecolor = titlecolor
g.db.add(v)
return redirect("/settings/profile")
@ -396,7 +396,7 @@ def titlecolor(v):
def verifiedcolor(v):
verifiedcolor = str(request.values.get("verifiedcolor", "")).strip()
if verifiedcolor.startswith('#'): verifiedcolor = verifiedcolor[1:]
if len(verifiedcolor) != 6: return render_template("settings_profile.html", v=v, error="Invalid color code")
if len(verifiedcolor) != 6: return render_template("settings_profile.html", v=v, error="Invalid color hex code")
v.verifiedcolor = verifiedcolor
g.db.add(v)
return redirect("/settings/profile")

View File

@ -30,7 +30,7 @@ def exile_post(v, pid):
send_notification(u.id, f"@{v.username} has exiled you from /h/{sub} for [{p.title}]({p.shortlink})")
return {"message": "User exiled successfully!"}
return {"message": f"@{u.username} has been exiled from /h/{sub.name} successfully!"}
@ -57,7 +57,7 @@ def exile_comment(v, cid):
send_notification(u.id, f"@{v.username} has exiled you from /h/{sub} for [{c.permalink}]({c.shortlink})")
return {"message": "User exiled successfully!"}
return {"message": f"@{u.username} has been exiled from /h/{sub.name} successfully!"}
@app.post("/h/<sub>/unexile/<uid>")
@ -75,7 +75,10 @@ def unexile(v, sub, uid):
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"message": "User unexiled successfully!"}
if request.headers.get("Authorization") or request.headers.get("xhr"):
return {"message": f"@{u.username} has been unexiled from /h/{sub.name} successfully!"}
return redirect(f'/h/{sub}/exilees')
@ -98,7 +101,7 @@ def block_sub(v, sub):
g.db.add(block)
cache.delete_memoized(frontlist)
return {"message": "Action successful!"}
return {"message": f"/h/{sub.name} blocked successfully!"}
@app.post("/h/<sub>/unblock")
@ -114,7 +117,7 @@ def unblock_sub(v, sub):
g.db.delete(block)
cache.delete_memoized(frontlist)
return {"message": "Action successful!"}
return {"message": f"/h/{sub.name} unblocked successfully!"}
@app.post("/h/<sub>/subscribe")
@ -131,7 +134,7 @@ def subscribe_sub(v, sub):
g.db.add(subscribe)
cache.delete_memoized(frontlist)
return {"message": "Action successful!"}
return {"message": f"/h/{sub.name} unblocked successfully!"}
@app.post("/h/<sub>/unsubscribe")
@auth_required
@ -146,7 +149,7 @@ def unsubscribe_sub(v, sub):
g.db.delete(subscribe)
cache.delete_memoized(frontlist)
return {"message": "Action successful!"}
return {"message": f"/h/{sub.name} blocked successfully!"}
@app.post("/h/<sub>/follow")
@auth_required
@ -161,7 +164,7 @@ def follow_sub(v, sub):
g.db.add(subscription)
cache.delete_memoized(frontlist)
return {"message": f"Action successful!"}
return {"message": f"/h/{sub.name} followed successfully!"}
@app.post("/h/<sub>/unfollow")
@auth_required
@ -175,7 +178,7 @@ def unfollow_sub(v, sub):
g.db.delete(subscription)
cache.delete_memoized(frontlist)
return {"message": f"Action successful!"}
return {"message": f"/h/{sub.name} unfollowed successfully!"}
@app.get("/h/<sub>/mods")
@auth_required
@ -345,12 +348,13 @@ def kick(v, pid):
if not post.sub: abort(403)
if not v.mods(post.sub): abort(403)
old = post.sub
post.sub = None
g.db.add(post)
cache.delete_memoized(frontlist)
return {"message": "Post kicked successfully!"}
return {"message": f"Post kicked from /h/{old} successfully!"}
@app.get('/h/<sub>/settings')
@is_not_permabanned
@ -518,7 +522,7 @@ def hole_pin(v, pid):
message = f"@{v.username} (Mod) has pinned your [post]({p.shortlink}) in /h/{p.sub}"
send_repeatable_notification(p.author_id, message)
return {"message": f"Post pinned to /h/{p.sub}"}
return {"message": f"Post pinned to /h/{p.sub} successfully!"}
@app.post("/hole_unpin/<pid>")
@auth_required
@ -536,7 +540,7 @@ def hole_unpin(v, pid):
message = f"@{v.username} (Mod) has unpinned your [post]({p.shortlink}) in /h/{p.sub}"
send_repeatable_notification(p.author_id, message)
return {"message": f"Post unpinned from /h/{p.sub}"}
return {"message": f"Post unpinned from /h/{p.sub} successfully!"}
@app.post('/h/<sub>/stealth')
@ -554,6 +558,6 @@ def sub_stealth(v, sub):
cache.delete_memoized(frontlist)
if sub.stealth:
return {"message": f"Stealth mode enabled!"}
return {"message": f"Stealth mode has been enabled for /h/{sub.name} successfully!"}
else:
return {"message": f"Stealth mode disabled!"}
return {"message": f"Stealth mode has been disabled for /h/{sub.name} successfully!"}

View File

@ -398,7 +398,7 @@ def suicide(v, username):
suicide = f"Hi there,\n\nA [concerned user](/id/{v.id}) reached out to us about you.\n\nWhen you're in the middle of something painful, it may feel like you don't have a lot of options. But whatever you're going through, you deserve help and there are people who are here for you.\n\nThere are resources available in your area that are free, confidential, and available 24/7:\n\n- Call, Text, or Chat with Canada's [Crisis Services Canada](https://www.crisisservicescanada.ca/en/)\n- Call, Email, or Visit the UK's [Samaritans](https://www.samaritans.org/)\n- Text CHAT to America's [Crisis Text Line](https://www.crisistextline.org/) at 741741.\nIf you don't see a resource in your area above, the moderators keep a comprehensive list of resources and hotlines for people organized by location. Find Someone Now\n\nIf you think you may be depressed or struggling in another way, don't ignore it or brush it aside. Take yourself and your feelings seriously, and reach out to someone.\n\nIt may not feel like it, but you have options. There are people available to listen to you, and ways to move forward.\n\nYour fellow users care about you and there are people who want to help."
if not v.shadowbanned:
send_notification(user.id, suicide)
return {"message": "Help message sent!"}
return {"message": f"Help message sent to @{user.username}"}
@app.get("/@<username>/coins")
@ -448,7 +448,7 @@ def transfer_coins(v, username):
g.db.add(receiver)
g.db.add(v)
return {"message": f"{amount-tax} coins transferred!"}, 200
return {"message": f"{amount-tax} coins have been transferred to @{receiver.username}"}, 200
return {"message": "You can't transfer coins to yourself!"}, 400
@ -489,7 +489,7 @@ def transfer_bux(v, username):
g.db.add(receiver)
g.db.add(v)
return {"message": f"{amount} marseybux transferred!"}, 200
return {"message": f"{amount} marseybux have been transferred to @{receiver.username}"}, 200
return {"message": "You can't transfer marseybux to yourself!"}, 400
@ -669,7 +669,7 @@ def song(song):
def subscribe(v, post_id):
new_sub = Subscription(user_id=v.id, submission_id=post_id)
g.db.add(new_sub)
return {"message": "Post subscribed!"}
return {"message": "Subscribed to post successfully!"}
@app.post("/unsubscribe/<post_id>")
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@ -679,7 +679,7 @@ def unsubscribe(v, post_id):
sub=g.db.query(Subscription).filter_by(user_id=v.id, submission_id=post_id).one_or_none()
if sub:
g.db.delete(sub)
return {"message": "Post unsubscribed!"}
return {"message": "Unsubscribed from post successfully!"}
@app.post("/@<username>/message")
@limiter.limit("1/second;10/minute;20/hour;50/day")
@ -1163,7 +1163,7 @@ def follow_user(username, v):
return {"error": "This user has disallowed other users from following them!"}, 403
if g.db.query(Follow).filter_by(user_id=v.id, target_id=target.id).one_or_none():
return {"message": "User followed!"}
return {"message": f"@{target.username} has been followed!"}
new_follow = Follow(user_id=v.id, target_id=target.id)
g.db.add(new_follow)
@ -1176,7 +1176,7 @@ def follow_user(username, v):
send_notification(target.id, f"@{v.username} has followed you!")
return {"message": "User followed!"}
return {"message": f"@{target.username} has been followed!"}
@app.post("/unfollow/<username>")
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@ -1204,7 +1204,7 @@ def unfollow_user(username, v):
send_notification(target.id, f"@{v.username} has unfollowed you!")
return {"message": "User unfollowed!"}
return {"message": f"@{target.username} has been unfollowed!"}
@app.post("/remove_follow/<username>")
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@ -1215,7 +1215,7 @@ def remove_follow(username, v):
follow = g.db.query(Follow).filter_by(user_id=target.id, target_id=v.id).one_or_none()
if not follow: return {"message": "Follower removed!"}
if not follow: return {"message": f"@{target.username} has been removed as a follower!"}
g.db.delete(follow)
@ -1226,7 +1226,7 @@ def remove_follow(username, v):
send_repeatable_notification(target.id, f"@{v.username} has removed your follow!")
return {"message": "Follower removed!"}
return {"message": f"@{target.username} has been removed as a follower!"}
@app.get("/pp/<id>")
@app.get("/uid/<id>/pic")

View File

@ -168,7 +168,7 @@
</div>
<p class="text-small mb-2">Or type a color code:</p>
<p class="text-small mb-2">Or type a color hex code:</p>
<div class="d-flex">
<form action="/settings/themecolor" id="color-code-form" method="post">
<input type="hidden" name="formkey" value="{{v.formkey}}">
@ -451,7 +451,7 @@
</div>
<p class="text-small mb-2">Or type a color code:</p>
<p class="text-small mb-2">Or type a color hex code:</p>
<div class="d-flex">
<form action="/settings/namecolor" id="color-code-form" method="post">
<input type="hidden" name="formkey" value="{{v.formkey}}">
@ -528,7 +528,7 @@
<p class="text-small mb-2">Or type a color code:</p>
<p class="text-small mb-2">Or type a color hex code:</p>
<div class="d-flex">
<form action="/settings/titlecolor" id="color-code-form" method="post">
<input type="hidden" name="formkey" value="{{v.formkey}}">
@ -571,7 +571,7 @@
</div>
<p class="text-small mb-2">Or type a color code:</p>
<p class="text-small mb-2">Or type a color hex code:</p>
<div class="d-flex">
<form action="/settings/verifiedcolor" id="color-code-form" method="post">
<input type="hidden" name="formkey" value="{{v.formkey}}">