diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index 5c016e230..a67b8f544 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -252,7 +252,6 @@ FEATURES = { 'BOTS': True, 'IP_LOGGING': False, 'BLOCK_MUTE_EXILE_EXPIRY': False, - 'ADMIN_TRANSPARENCY': True, } if SITE_NAME == 'rDrama': @@ -769,8 +768,6 @@ elif SITE == 'watchpeopledie.tv': FEATURES['BOTS'] = False FEATURES['HAT_SUBMISSIONS'] = False FEATURES['IP_LOGGING'] = True - FEATURES['ADMIN_TRANSPARENCY'] = False - HOUSES = ["Furry","Femboy","Vampire","Edgy"] PERMS['POST_COMMENT_EDITING'] = 3 @@ -1178,8 +1175,3 @@ if not IS_LOCALHOST: with open("includes/content-security-policy", "w") as f: f.write(f'add_header Content-Security-Policy "{csp}";') - -def admin_str(v): - if FEATURES['ADMIN_TRANSPARENCY']: - return f'@{v.username} (a site admin)' - return 'Site admins' diff --git a/files/routes/admin.py b/files/routes/admin.py index d334045bb..b55a744cf 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -117,7 +117,7 @@ def make_admin(v, username): ) g.db.add(ma) - send_repeatable_notification(user.id, f"{admin_str(v)} added you as an admin!") + send_repeatable_notification(user.id, f"@{v.username} (a site admin) added you as an admin!") return {"message": f"@{user.username} has been made admin!"} @@ -148,7 +148,7 @@ def remove_admin(v, username): ) g.db.add(ma) - send_repeatable_notification(user.id, f"{admin_str(v)} removed you as an admin!") + send_repeatable_notification(user.id, f"@{v.username} (a site admin) removed you as an admin!") return {"message": f"@{user.username} has been removed as admin!"} @@ -260,7 +260,7 @@ def revert_actions(v, username): user.shadowban_reason = None if user.is_banned: user.is_banned = None - send_repeatable_notification(user.id, f"{admin_str(v)} unbanned you!") + send_repeatable_notification(user.id, f"@{v.username} (a site admin) has unbanned you!") g.db.add(user) for u in get_alt_graph(user.id): @@ -270,7 +270,7 @@ def revert_actions(v, username): u.shadowban_reason = None if u.is_banned: u.is_banned = None - send_repeatable_notification(u.id, f"{admin_str(v)} unbanned you!") + send_repeatable_notification(u.id, f"@{v.username} (a site admin) has unbanned you!") g.db.add(u) return {"message": f"@{revertee.username}'s admin actions have been reverted!"} @@ -523,7 +523,7 @@ def badge_grant_post(v): g.db.flush() if v.id != user.id: - text = f"{admin_str(v)} given you the following profile badge:\n\n{new_badge.path}\n\n**{new_badge.name}**\n\n{new_badge.badge.description}" + text = f"@{v.username} (a site admin) has given you the following profile badge:\n\n{new_badge.path}\n\n**{new_badge.name}**\n\n{new_badge.badge.description}" if new_badge.description: text += f'\n\n> {new_badge.description}' if new_badge.url: @@ -573,7 +573,7 @@ def badge_remove_post(v): if not badge: continue if v.id != user.id: - text = f"{admin_str(v)} removed the following profile badge from you:\n\n{badge.path}\n\n**{badge.name}**\n\n{badge.badge.description}" + text = f"@{v.username} (a site admin) has removed the following profile badge from you:\n\n{badge.path}\n\n**{badge.name}**\n\n{badge.badge.description}" send_repeatable_notification(user.id, text) ma = ModAction( @@ -856,7 +856,7 @@ def unchud(fullname, v): badge = user.has_badge(58) if badge: g.db.delete(badge) - send_repeatable_notification(user.id, f"{admin_str(v)} unchudded you.") + send_repeatable_notification(user.id, f"@{v.username} (a site admin) has unchudded you.") return {"message": f"@{user.username} has been unchudded!"} @@ -973,9 +973,9 @@ def admin_change_flair(user_id, v): g.db.add(ma) if user.flairchanged: - message = f"{admin_str(v)} locked your flair to `{user.flair}`." + message = f"@{v.username} (a site admin) has locked your flair to `{user.flair}`." else: - message = f"{admin_str(v)} changed your flair to `{user.flair}`. You can change it back in the settings." + message = f"@{v.username} (a site admin) has changed your flair to `{user.flair}`. You can change it back in the settings." send_repeatable_notification(user.id, message) @@ -1037,11 +1037,11 @@ def ban_user(fullname, v): if days_txt.endswith('.0'): days_txt = days_txt[:-2] duration = f"for {days_txt} day" if days != 1: duration += "s" - if reason: text = f"{admin_str(v)} banned you for **{days_txt}** days for the following reason:\n\n> {reason}" - else: text = f"{admin_str(v)} banned you for **{days_txt}** days." + if reason: text = f"@{v.username} (a site admin) has banned you for **{days_txt}** days for the following reason:\n\n> {reason}" + else: text = f"@{v.username} (a site admin) has banned you for **{days_txt}** days." else: - if reason: text = f"{admin_str(v)} banned you permanently for the following reason:\n\n> {reason}" - else: text = f"{admin_str(v)} banned you permanently." + if reason: text = f"@{v.username} (a site admin) has banned you permanently for the following reason:\n\n> {reason}" + else: text = f"@{v.username} (a site admin) has banned you permanently." user.ban(admin=v, reason=reason, days=days) @@ -1147,7 +1147,7 @@ def chud(fullname, v): user.chud_phrase = request.values.get("chud_phrase").strip().lower() - text = f"{admin_str(v)} chudded you **{duration}**" + text = f"@{v.username} (a site admin) has chudded you **{duration}**" if reason: text += f" for the following reason:\n\n> {reason}" text += f"\n\n**You now have to say this phrase in all posts and comments you make {duration}:**\n\n> {user.chud_phrase}" @@ -1219,11 +1219,11 @@ def unban_user(fullname, v): user.is_banned = None user.unban_utc = None user.ban_reason = None - send_repeatable_notification(user.id, f"{admin_str(v)} unbanned you!") + send_repeatable_notification(user.id, f"@{v.username} (a site admin) has unbanned you!") g.db.add(user) for x in get_alt_graph(user.id): - if x.is_banned: send_repeatable_notification(x.id, f"{admin_str(v)} unbanned you!") + if x.is_banned: send_repeatable_notification(x.id, f"@{v.username} (a site admin) has unbanned you!") x.is_banned = None x.unban_utc = None x.ban_reason = None @@ -1258,7 +1258,7 @@ def mute_user(v, user_id): g.db.add(ma) check_for_alts(user) - send_repeatable_notification(user.id, f"{admin_str(v)} muted you!") + send_repeatable_notification(user.id, f"@{v.username} (a site admin) has muted you!") return {"message": f"@{user.username} has been muted!"} @@ -1287,7 +1287,7 @@ def unmute_user(v, user_id): x.is_muted = False g.db.add(x) - send_repeatable_notification(user.id, f"{admin_str(v)} unmuted you!") + send_repeatable_notification(user.id, f"@{v.username} (a site admin) has unmuted you!") return {"message": f"@{user.username} has been unmuted!"} @@ -1466,7 +1466,7 @@ def pin_post(post_id, v): pin_time = 'for 1 hour' code = 200 if v.id != post.author_id: - send_repeatable_notification(post.author_id, f"{admin_str(v)} pinned [{post.title}]({post.shortlink})") + send_repeatable_notification(post.author_id, f"@{v.username} (a site admin) has pinned [{post.title}]({post.shortlink})") else: if pins >= PIN_LIMIT + 1: abort(403, f"Can't exceed {PIN_LIMIT} pinned posts limit!") @@ -1515,7 +1515,7 @@ def unpin_post(post_id, v): g.db.add(ma) if v.id != post.author_id: - send_repeatable_notification(post.author_id, f"{admin_str(v)} unpinned [{post.title}]({post.shortlink})") + send_repeatable_notification(post.author_id, f"@{v.username} (a site admin) has unpinned [{post.title}]({post.shortlink})") cache.delete_memoized(frontlist) return {"message": "Post unpinned!"} @@ -1547,7 +1547,7 @@ def pin_comment_admin(cid, v): g.db.add(ma) if v.id != comment.author_id: - message = f"{admin_str(v)} pinned your [comment]({comment.shortlink})" + message = f"@{v.username} (a site admin) has pinned your [comment]({comment.shortlink})" send_repeatable_notification(comment.author_id, message) comment.pin_parents() @@ -1580,7 +1580,7 @@ def unpin_comment_admin(cid, v): g.db.add(ma) if v.id != comment.author_id: - message = f"{admin_str(v)} unpinned your [comment]({comment.shortlink})" + message = f"@{v.username} (a site admin) has unpinned your [comment]({comment.shortlink})" send_repeatable_notification(comment.author_id, message) comment.unpin_parents() @@ -1900,7 +1900,7 @@ def admin_reset_password(user_id, v): ) g.db.add(ma) - text = f"At your request, {admin_str(v)} reset your password to `{new_password}`, please change this to something else for personal security reasons. And be sure to save it this time, retard." + text = f"At your request, @{v.username} (a site admin) has reset your password to `{new_password}`, please change this to something else for personal security reasons. And be sure to save it this time, retard." send_repeatable_notification(user.id, text) text = f"@{user.username}'s new password is `{new_password}`" @@ -2144,7 +2144,7 @@ def mark_effortpost(pid, v): p.author.pay_account('coins', coins) if v.id != p.author_id: - send_repeatable_notification(p.author_id, f":marseyclapping: {admin_str(v)} marked [{p.title}](/post/{p.id}) as an effortpost, it now gets x{mul} coins from votes. You have received {coins} coins retroactively, thanks! :!marseyclapping:") + send_repeatable_notification(p.author_id, f":marseyclapping: @{v.username} (a site admin) has marked [{p.title}](/post/{p.id}) as an effortpost, it now gets x{mul} coins from votes. You have received {coins} coins retroactively, thanks! :!marseyclapping:") return {"message": "Post has been marked as an effortpost!"} @@ -2181,6 +2181,6 @@ def unmark_effortpost(pid, v): p.author.charge_account('coins', coins) if v.id != p.author_id: - send_repeatable_notification(p.author_id, f":marseyitsover: {admin_str(v)} unmarked [{p.title}](/post/{p.id}) as an effortpost. {coins} coins have been deducted from you. :!marseyitsover:") + send_repeatable_notification(p.author_id, f":marseyitsover: @{v.username} (a site admin) has unmarked [{p.title}](/post/{p.id}) as an effortpost. {coins} coins have been deducted from you. :!marseyitsover:") return {"message": "Post has been unmarked as an effortpost!"} diff --git a/files/routes/asset_submissions.py b/files/routes/asset_submissions.py index bd7d9cfbc..7d038d49c 100644 --- a/files/routes/asset_submissions.py +++ b/files/routes/asset_submissions.py @@ -229,7 +229,7 @@ def approve_emoji(v, name): g.db.add(author) if v.id != author.id: - msg = f"{admin_str(v)} approved an emoji you made: :{emoji.name}:\n\nYou have received {amount} coins as a reward!" + msg = f"@{v.username} (a site admin) has approved an emoji you made: :{emoji.name}:\n\nYou have received {amount} coins as a reward!" comment = request.values.get("comment") if comment: @@ -238,7 +238,7 @@ def approve_emoji(v, name): send_repeatable_notification(author.id, msg) if v.id != emoji.submitter_id and author.id != emoji.submitter_id: - msg = f"{admin_str(v)} approved an emoji you submitted: :{emoji.name}:" + msg = f"@{v.username} (a site admin) has approved an emoji you submitted: :{emoji.name}:" comment = request.values.get("comment") if comment: @@ -438,7 +438,7 @@ def approve_hat(v, name): if v.id != author.id: - msg = f"{admin_str(v)} approved a hat you made: `'{hat.name}'`" + msg = f"@{v.username} (a site admin) has approved a hat you made: `'{hat.name}'`" comment = request.values.get("comment") if comment: @@ -447,7 +447,7 @@ def approve_hat(v, name): send_repeatable_notification(author.id, msg) if v.id != hat.submitter_id and author.id != hat.submitter_id: - msg = f"{admin_str(v)} approved a hat you submitted: `'{hat.name}'`" + msg = f"@{v.username} (a site admin) has approved a hat you submitted: `'{hat.name}'`" comment = request.values.get("comment") if comment: diff --git a/files/routes/holes.py b/files/routes/holes.py index ede737178..1703bed03 100644 --- a/files/routes/holes.py +++ b/files/routes/holes.py @@ -1122,7 +1122,7 @@ def change_hole(pid, v): _note=f'{hole_from_str} → {hole_to_str}', ) g.db.add(ma) - actor_str = admin_str(v) + position = 'a site admin' else: ma = HoleAction( hole=hole_from, @@ -1132,14 +1132,14 @@ def change_hole(pid, v): _note=f'{hole_from_str} → {hole_to_str}', ) g.db.add(ma) - actor_str = f'@{v.username} (a /h/{hole_from} mod)' + position = f'a /h/{hole_from} mod' if hole_from == None: hole_from_in_notif = 'the main feed' else: hole_from_in_notif = f'/h/{hole_from}' - message = f"{actor_str} moved [{post.title}]({post.shortlink}) from {hole_from_in_notif} to {hole_to_in_notif}" + message = f"@{v.username} ({position}) has moved [{post.title}]({post.shortlink}) from {hole_from_in_notif} to {hole_to_in_notif}" send_repeatable_notification(post.author_id, message) cache.delete_memoized(frontlist) diff --git a/files/routes/login.py b/files/routes/login.py index d7efc6e3d..3a2afc002 100644 --- a/files/routes/login.py +++ b/files/routes/login.py @@ -105,12 +105,9 @@ def login_post(v): return redirect('/') def log_failed_admin_login_attempt(account, type): - if not account or account.admin_level < PERMS['WARN_ON_FAILED_LOGIN']: - return - + if not account or account.admin_level < PERMS['WARN_ON_FAILED_LOGIN']: return ip = get_IP() - print(f"{ip} failed to login to account @{account.user_name} (invalid {type})") - + print(f"A site admin from {ip} failed to login to account @{account.user_name} (invalid {type})") t = time.strftime("%d/%B/%Y %H:%M:%S UTC", time.gmtime(time.time())) log_file(f"{t}, {ip}, {account.username}, {type}", "admin_failed_logins.log") diff --git a/files/routes/oauth.py b/files/routes/oauth.py index 19df2ad25..2ef87687c 100644 --- a/files/routes/oauth.py +++ b/files/routes/oauth.py @@ -157,7 +157,7 @@ def admin_app_approve(v, aid): g.db.add(new_auth) - send_repeatable_notification(user.id, f"{admin_str(v)} approved your application `{app.app_name}`. Here's your access token: ||{access_token}||\n\nPlease check the guide [here](/api) if you don't know what to do next!") + send_repeatable_notification(user.id, f"@{v.username} (a site admin) has approved your application `{app.app_name}`. Here's your access token: ||{access_token}||\n\nPlease check the guide [here](/api) if you don't know what to do next!") ma = ModAction( kind="approve_app", @@ -183,7 +183,7 @@ def admin_app_revoke(v, aid): for auth in g.db.query(ClientAuth).filter_by(oauth_client=app.id): g.db.delete(auth) if v.id != app.author.id: - send_repeatable_notification(app.author.id, f"{admin_str(v)} revoked your application `{app.app_name}`.") + send_repeatable_notification(app.author.id, f"@{v.username} (a site admin) has revoked your application `{app.app_name}`.") g.db.delete(app) @@ -212,7 +212,7 @@ def admin_app_reject(v, aid): for auth in g.db.query(ClientAuth).filter_by(oauth_client=app.id): g.db.delete(auth) if v.id != app.author.id: - send_repeatable_notification(app.author.id, f"{admin_str(v)} rejected your application `{app.app_name}`.") + send_repeatable_notification(app.author.id, f"@{v.username} (a site admin) has rejected your application `{app.app_name}`.") g.db.delete(app) diff --git a/files/routes/posts.py b/files/routes/posts.py index 7919a2671..febcf1c58 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -825,7 +825,7 @@ def mark_post_nsfw(pid, v): target_post_id = p.id, ) g.db.add(ma) - actor_str = admin_str(v) + position = 'a site admin' else: ma = HoleAction( hole = p.hole, @@ -834,9 +834,9 @@ def mark_post_nsfw(pid, v): target_post_id = p.id, ) g.db.add(ma) - actor_str = f'@{v.username} (a /h/{hole_from} mod)' + position = f'a /h/{p.hole} mod' - send_repeatable_notification(p.author_id, f"{actor_str} marked [{p.title}](/post/{p.id}) as NSFW") + send_repeatable_notification(p.author_id, f"@{v.username} ({position}) has marked [{p.title}](/post/{p.id}) as NSFW") return {"message": "Post has been marked as NSFW!"} @@ -867,7 +867,7 @@ def unmark_post_nsfw(pid, v): target_post_id = p.id, ) g.db.add(ma) - actor_str = admin_str(v) + position = 'a site admin' else: ma = HoleAction( hole = p.hole, @@ -876,9 +876,9 @@ def unmark_post_nsfw(pid, v): target_post_id = p.id, ) g.db.add(ma) - actor_str = f'@{v.username} (a /h/{hole_from} mod)' + position = f'a /h/{p.hole} mod' - send_repeatable_notification(p.author_id, f"{actor_str} unmarked [{p.title}](/post/{p.id}) as NSFW") + send_repeatable_notification(p.author_id, f"@{v.username} ({position}) has unmarked [{p.title}](/post/{p.id}) as NSFW") return {"message": "Post has been unmarked as NSFW!"} @@ -953,7 +953,7 @@ def set_new_sort(post_id, v): target_post_id = p.id, ) g.db.add(ma) - send_repeatable_notification(p.author_id, f"{admin_str(v)} changed the the default sorting of comments on [{p.title}](/post/{p.id}) to `new`") + send_repeatable_notification(p.author_id, f"@{v.username} (a site admin) has changed the the default sorting of comments on [{p.title}](/post/{p.id}) to `new`") return {"message": "Changed the the default sorting of comments on this post to 'new'"} @@ -975,7 +975,7 @@ def unset_new_sort(post_id, v): target_post_id = p.id, ) g.db.add(ma) - send_repeatable_notification(p.author_id, f"{admin_str(v)} changed the the default sorting of comments on [{p.title}](/post/{p.id}) to `hot`") + send_repeatable_notification(p.author_id, f"@{v.username} (a site admin) has changed the the default sorting of comments on [{p.title}](/post/{p.id}) to `hot`") return {"message": "Changed the the default sorting of comments on this post to 'hot'"} @@ -1135,7 +1135,7 @@ if SITE_NAME == 'WPD': target_post_id = p.id, ) g.db.add(ma) - send_repeatable_notification(p.author_id, f"{admin_str(v)} added a child warning to [{p.title}](/post/{p.id})") + send_repeatable_notification(p.author_id, f"@{v.username} (a site admin) has add a child warning to [{p.title}](/post/{p.id})") return {"message": "A child warning has been added to the post!"} @@ -1161,7 +1161,7 @@ if SITE_NAME == 'WPD': target_post_id = p.id, ) g.db.add(ma) - send_repeatable_notification(p.author_id, f"{admin_str(v)} removed the child warning from [{p.title}](/post/{p.id})") + send_repeatable_notification(p.author_id, f"@{v.username} (a site admin) has removed the child warning from [{p.title}](/post/{p.id})") return {"message": "The child warning has been removed from the post!"} diff --git a/files/routes/reporting.py b/files/routes/reporting.py index d5e429639..15fcd02a7 100644 --- a/files/routes/reporting.py +++ b/files/routes/reporting.py @@ -42,7 +42,7 @@ def report_post(pid, v): _note=f'"{post.flair}"' ) g.db.add(ma) - actor_str = admin_str(v) + position = 'a site admin' else: ma = HoleAction( hole=post.hole, @@ -52,10 +52,10 @@ def report_post(pid, v): _note=f'"{post.flair}"' ) g.db.add(ma) - actor_str = f'@{v.username} (a /h/{hole_from} mod)' + position = f'a /h/{post.hole} mod' if v.id != post.author_id: - message = f'{actor_str} flaired [{post.title}]({post.shortlink}) with the flair: `"{og_flair}"`' + message = f'@{v.username} ({position}) has flaired [{post.title}]({post.shortlink}) with the flair: `"{og_flair}"`' send_repeatable_notification(post.author_id, message) return {"message": "Post flaired successfully!"} diff --git a/files/routes/static.py b/files/routes/static.py index b753df0b0..487f994b3 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -176,7 +176,6 @@ def patrons(v): return render_template("admin/patrons.html", v=v, users=users, benefactor_def=AWARDS['benefactor']) @app.get("/admins") -@feature_required('ADMIN_TRANSPARENCY') @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400) @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID) @auth_required @@ -186,7 +185,6 @@ def admins(v): @app.get("/log") @app.get("/modlog") -@feature_required('ADMIN_TRANSPARENCY') @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400) @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID) @auth_required diff --git a/files/routes/users.py b/files/routes/users.py index 45ece6aa6..d557fcb31 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -326,7 +326,6 @@ def user_voted_comments(v, username): return user_voted(v, username, Comment, CommentVote, "userpage/voted_comments.html", True) @app.get("/banned") -@feature_required('ADMIN_TRANSPARENCY') @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400) @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID) @auth_required diff --git a/files/templates/comments.html b/files/templates/comments.html index dd09b07d3..9b01b873e 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -30,32 +30,8 @@