new_name->new_flair, title->flair

master
Aevann 2023-10-04 15:29:41 +03:00
parent a44ffb8f4a
commit b24be481d7
5 changed files with 15 additions and 15 deletions

View File

@ -342,7 +342,7 @@ PERMS = { # Minimum admin_level to perform action.
'IS_PERMA_PROGSTACKED': 2,
'USER_BADGES': 2,
'USER_LINK': 2,
'USER_TITLE_CHANGE': 2,
'USER_CHANGE_FLAIR': 2,
'LOTTERY_VIEW_PARTICIPANTS': 2,
'POST_COMMENT_INFINITE_PINGS': 2,
'IGNORE_1WEEk_EDITING_LIMIT': 2,

View File

@ -897,24 +897,24 @@ def unshadowban(user_id, v):
return {"message": f"@{user.username} has been unshadowbanned!"}
@app.post("/admin/title_change/<int:user_id>")
@app.post("/admin/change_flair/<int:user_id>")
@limiter.limit('1/second', scope=rpath)
@limiter.limit('1/second', scope=rpath, key_func=get_ID)
@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)
@admin_level_required(PERMS['USER_TITLE_CHANGE'])
def admin_title_change(user_id, v):
@admin_level_required(PERMS['USER_CHANGE_FLAIR'])
def admin_change_flair(user_id, v):
user = get_account(user_id)
new_name = request.values.get("title")[:256].strip()
new_flair = request.values.get("title")[:256].strip()
user.customtitleplain = new_name
new_name = filter_emojis_only(new_name)
new_name = censor_slurs_profanities(new_name, None)
user.customtitleplain = new_flair
new_flair = filter_emojis_only(new_flair)
new_flair = censor_slurs_profanities(new_flair, None)
user = get_account(user.id)
user.customtitle=new_name
user.customtitle = new_flair
if request.values.get("locked"):
user.flairchanged = int(time.time()) + 2629746
badge_grant(user=user, badge_id=96)
@ -932,7 +932,7 @@ def admin_title_change(user_id, v):
kind=kind,
user_id=v.id,
target_user_id=user.id,
_note=f'"{new_name}"'
_note=f'"{new_flair}"'
)
g.db.add(ma)

View File

@ -891,13 +891,13 @@ def process_settings_plaintext(value, current, length, default_value):
return value
@app.post("/settings/title_change")
@app.post("/settings/change_flair")
@limiter.limit('1/second', scope=rpath)
@limiter.limit('1/second', scope=rpath, key_func=get_ID)
@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
def settings_title_change(v):
def settings_change_flair(v):
if v.flairchanged: abort(403)
customtitleplain = process_settings_plaintext("title", v.customtitleplain, 100, None)

View File

@ -202,7 +202,7 @@
{{common.line_text_section('pronouns', '/settings/pronouns_change', 'pronouns', 'Pronouns', v.pronouns, 'Limit of 15 characters', 'Enter pronouns here', 'Change Pronouns', false, 3, 15, '([a-zA-Z]{1,7})/[a-zA-Z]{1,7}(/[a-zA-Z]{1,7})?', false)}}
{% endif %}
{{common.line_text_section('flair', '/settings/title_change', 'title', 'Flair', v.customtitleplain, 'Limit of 100 characters', 'Enter a flair here', 'Change Flair', true, 0, 100, '.*', v.flairchanged)}}
{{common.line_text_section('flair', '/settings/change_flair', 'title', 'Flair', v.customtitleplain, 'Limit of 100 characters', 'Enter a flair here', 'Change Flair', true, 0, 100, '.*', v.flairchanged)}}
{{common.color_section('flaircolor', '/settings/titlecolor', 'titlecolor', 'Flair Color', v.titlecolor)}}

View File

@ -33,10 +33,10 @@
{% macro userAdminTools(deviceType) %}
{% if v and v.id != u.id and v.admin_level >= PERMS['USER_MODERATION_TOOLS_VISIBLE'] %}
<div class="admintools-user-lower-{{deviceType}}">
{% if v.admin_level >= PERMS['USER_TITLE_CHANGE'] %}
{% if v.admin_level >= PERMS['USER_CHANGE_FLAIR'] %}
<div class="body d-lg-flex border-bottom mt-4 mb-2">
<div class="w-lg-100">
<form action="/admin/title_change/{{u.id}}" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHR(this)">
<form action="/admin/change_flair/{{u.id}}" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHR(this)">
<input hidden name="formkey" value="{{v|formkey}}">
<input maxlength=100 autocomplete="off" id="customtitlebody-{{deviceType}}" type="text" name="title" class="form-control" placeholder='Enter a flair here' value="{% if u.customtitleplain %}{{u.customtitleplain}}{% endif %}">
<div class="d-flex">