From fbe7089d2a7a3372f1f1859266cd4b6cc1a60d17 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 11 Sep 2022 16:32:00 +0200 Subject: [PATCH] more detailed success message description --- files/routes/admin.py | 24 ++++++++++++------------ files/routes/awards.py | 2 +- files/routes/hats.py | 6 +++--- files/routes/oauth.py | 8 ++++---- files/routes/subs.py | 32 ++++++++++++++++++-------------- files/routes/users.py | 20 ++++++++++---------- 6 files changed, 48 insertions(+), 44 deletions(-) diff --git a/files/routes/admin.py b/files/routes/admin.py index e8c40bfdc..dce01c2a4 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -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("/@/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/") @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("/@/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("/@/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/") @@ -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/") @@ -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/") @@ -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/") @@ -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//") @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) diff --git a/files/routes/awards.py b/files/routes/awards.py index 7d7c597a8..9d078f085 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -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//") @limiter.limit("1/second;30/minute;200/hour;1000/day") diff --git a/files/routes/hats.py b/files/routes/hats.py index 25d910a92..a4e3499cf 100644 --- a/files/routes/hats.py +++ b/files/routes/hats.py @@ -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/") @@ -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/") @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/") @auth_required diff --git a/files/routes/oauth.py b/files/routes/oauth.py index ac97d16b5..ef5701601 100644 --- a/files/routes/oauth.py +++ b/files/routes/oauth.py @@ -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/") @@ -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/") @@ -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/") @@ -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} diff --git a/files/routes/subs.py b/files/routes/subs.py index 5128f843b..7a734cf45 100644 --- a/files/routes/subs.py +++ b/files/routes/subs.py @@ -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//unexile/") @@ -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//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//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//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//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//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//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//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/") @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//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!"} \ No newline at end of file + return {"message": f"Stealth mode has been disabled for /h/{sub.name} successfully!"} \ No newline at end of file diff --git a/files/routes/users.py b/files/routes/users.py index 77f7c9a88..f50a02c12 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -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("/@/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/") @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("/@/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/") @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/") @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/") @app.get("/uid//pic")