From 21126269107c8336d066d87bc87310cc9385af8b Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 3 Mar 2023 06:19:52 +0200 Subject: [PATCH] increase charlimit for bio, friends, and enemies to 5k --- files/helpers/config/const.py | 3 +++ files/routes/jinja2.py | 4 +++- files/routes/settings.py | 19 +++++++++---------- files/templates/settings/personal.html | 6 +++--- ...increase-charlimit-bio-friends-enemies.sql | 7 +++++++ schema.sql | 13 ++++++------- 6 files changed, 31 insertions(+), 21 deletions(-) create mode 100644 migrations/20230303-increase-charlimit-bio-friends-enemies.sql diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index 9ca174189..0cf3cc90d 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -610,6 +610,9 @@ MIN_REPOST_CHECK_URL_LENGTH = 9 # also change the constant in checkRepost() of s CHAT_LENGTH_LIMIT = 1000 SUB_BANNER_LIMIT = 10 +BIO_FRIENDS_ENEMIES_LENGTH_LIMIT = 5000 # do not make larger than 5000 characters without altering the table +BIO_FRIENDS_ENEMIES_HTML_LENGTH_LIMIT = 20000 # do not make larger than 20000 characters without altering the table + COSMETIC_AWARD_COIN_AWARD_PCT = 0.10 TRUESCORE_CHAT_MINIMUM = 0 diff --git a/files/routes/jinja2.py b/files/routes/jinja2.py index 0ede24cec..609dc1656 100644 --- a/files/routes/jinja2.py +++ b/files/routes/jinja2.py @@ -118,5 +118,7 @@ def inject_constants(): "HOUSE_JOIN_COST":HOUSE_JOIN_COST, "HOUSE_SWITCH_COST":HOUSE_SWITCH_COST, "IMAGE_FORMATS":','.join(IMAGE_FORMATS), "PAGE_SIZES":PAGE_SIZES, "THEMES":THEMES, "COMMENT_SORTS":COMMENT_SORTS, "SORTS":SORTS, "TIME_FILTERS":TIME_FILTERS, "HOUSES":HOUSES, "TIERS_ID_TO_NAME":TIERS_ID_TO_NAME, - "DEFAULT_CONFIG_VALUE":DEFAULT_CONFIG_VALUE, "IS_LOCALHOST":IS_LOCALHOST, "BACKGROUND_CATEGORIES":BACKGROUND_CATEGORIES, "PAGE_SIZE":PAGE_SIZE, "TAGLINES":TAGLINES, "IS_FISTMAS":IS_FISTMAS, "get_alt_graph":get_alt_graph, "current_registered_users":current_registered_users, "gitref":git_head(), "SHOW_MORE": SHOW_MORE, + "DEFAULT_CONFIG_VALUE":DEFAULT_CONFIG_VALUE, "IS_LOCALHOST":IS_LOCALHOST, "BACKGROUND_CATEGORIES":BACKGROUND_CATEGORIES, "PAGE_SIZE":PAGE_SIZE, "TAGLINES":TAGLINES, "IS_FISTMAS":IS_FISTMAS, "get_alt_graph":get_alt_graph, "current_registered_users":current_registered_users, + "gitref":git_head(), "SHOW_MORE": SHOW_MORE, + "BIO_FRIENDS_ENEMIES_LENGTH_LIMIT":BIO_FRIENDS_ENEMIES_LENGTH_LIMIT, } diff --git a/files/routes/settings.py b/files/routes/settings.py index bb50ab13a..39529a2ed 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -245,16 +245,16 @@ def settings_personal_post(v): msg="Your sig has been updated.") elif not updated and FEATURES['USERS_PROFILE_BODYTEXT'] and request.values.get("friends"): - friends = request.values.get("friends")[:1000] + friends = request.values.get("friends")[:BIO_FRIENDS_ENEMIES_LENGTH_LIMIT] friends_html = sanitize(friends, blackjack="friends") - if len(friends_html) > 5000: + if len(friends_html) > BIO_FRIENDS_ENEMIES_HTML_LENGTH_LIMIT: return render_template("settings/personal.html", v=v, error="Your friends list is too long") - friends = friends[:1000] + friends = friends[:BIO_FRIENDS_ENEMIES_LENGTH_LIMIT] notify_users = NOTIFY_USERS(friends, v, v.friends) @@ -276,16 +276,16 @@ def settings_personal_post(v): elif not updated and FEATURES['USERS_PROFILE_BODYTEXT'] and request.values.get("enemies"): - enemies = request.values.get("enemies")[:1000] + enemies = request.values.get("enemies")[:BIO_FRIENDS_ENEMIES_LENGTH_LIMIT] enemies_html = sanitize(enemies, blackjack="enemies") - if len(enemies_html) > 5000: + if len(enemies_html) > BIO_FRIENDS_ENEMIES_HTML_LENGTH_LIMIT: return render_template("settings/personal.html", v=v, error="Your enemies list is too long") - enemies = enemies[:1000] + enemies = enemies[:BIO_FRIENDS_ENEMIES_LENGTH_LIMIT] notify_users = NOTIFY_USERS(enemies, v, v.enemies) if notify_users: @@ -307,19 +307,18 @@ def settings_personal_post(v): elif not updated and FEATURES['USERS_PROFILE_BODYTEXT'] and \ (request.values.get("bio") or request.files.get('file')): - bio = request.values.get("bio")[:1500] + bio = request.values.get("bio")[:BIO_FRIENDS_ENEMIES_LENGTH_LIMIT] bio = process_files(request.files, v, bio) bio = bio.strip() bio_html = sanitize(bio, blackjack="bio") - if len(bio_html) > 10000: + if len(bio_html) > BIO_FRIENDS_ENEMIES_HTML_LENGTH_LIMIT: return render_template("settings/personal.html", v=v, error="Your bio is too long") - if len(bio_html) > 10000: abort(400) - v.bio = bio[:1500] + v.bio = bio[:BIO_FRIENDS_ENEMIES_LENGTH_LIMIT] v.bio_html=bio_html g.db.add(v) return render_template("settings/personal.html", diff --git a/files/templates/settings/personal.html b/files/templates/settings/personal.html index 4ffd73607..68684c11c 100644 --- a/files/templates/settings/personal.html +++ b/files/templates/settings/personal.html @@ -210,9 +210,9 @@ {%- endif %} {# common.text_area_section(id, form_action, form_name, section_title, contents, below_text, placeholder_text, show_extras, show_file_upload, maxlength, show_if) #} - {{common.text_area_section('profile-bio', '/settings/personal', 'bio', 'Bio', v.bio, 'Limit of 1500 characters', 'Tell the community a bit about yourself.', true, true, 1500, FEATURES['USERS_PROFILE_BODYTEXT'])}} - {{common.text_area_section('profile-friends', '/settings/personal', 'friends', 'Friends', v.friends, 'Limit of 500 characters', 'Enter your friends on the site...', false, false, 500, true)}} - {{common.text_area_section('profile-enemies', '/settings/personal', 'enemies', 'Enemies', v.enemies, 'Limit of 500 characters', 'Enter your enemies on the site...', false, false, 500, true)}} + {{common.text_area_section('profile-bio', '/settings/personal', 'bio', 'Bio', v.bio, 'Limit of ' ~ BIO_FRIENDS_ENEMIES_LENGTH_LIMIT ~ ' characters', 'Tell the community a bit about yourself.', true, true, BIO_FRIENDS_ENEMIES_LENGTH_LIMIT, FEATURES['USERS_PROFILE_BODYTEXT'])}} + {{common.text_area_section('profile-friends', '/settings/personal', 'friends', 'Friends', v.friends, 'Limit of ' ~ BIO_FRIENDS_ENEMIES_LENGTH_LIMIT ~ ' characters', 'Enter your friends on the site...', false, false, BIO_FRIENDS_ENEMIES_LENGTH_LIMIT, true)}} + {{common.text_area_section('profile-enemies', '/settings/personal', 'enemies', 'Enemies', v.enemies, 'Limit of ' ~ BIO_FRIENDS_ENEMIES_LENGTH_LIMIT ~ ' characters', 'Enter your enemies on the site...', false, false, BIO_FRIENDS_ENEMIES_LENGTH_LIMIT, true)}} {{common.text_area_section('profile-signature', '/settings/personal', 'sig', 'Signature', v.sig, 'Limit of 200 characters', 'Enter a signature...', true, false, 200, v.patron or v.sig)}} {# toggle_section(title, id, name, flag, below_text, disabled) #} {{common.toggle_section('Private Mode', 'privateswitch', 'private', v.is_private, 'This will hide your post and comment history from others. We will also ask search engines to not index your profile page. (Your content will still be accessible via direct link.)', false)}} diff --git a/migrations/20230303-increase-charlimit-bio-friends-enemies.sql b/migrations/20230303-increase-charlimit-bio-friends-enemies.sql new file mode 100644 index 000000000..ec128ac4c --- /dev/null +++ b/migrations/20230303-increase-charlimit-bio-friends-enemies.sql @@ -0,0 +1,7 @@ +alter table users alter column bio type varchar(5000); +alter table users alter column friends type varchar(5000); +alter table users alter column enemies type varchar(5000); + +alter table users alter column bio_html type varchar(20000); +alter table users alter column friends_html type varchar(20000); +alter table users alter column enemies_html type varchar(20000); diff --git a/schema.sql b/schema.sql index 9acb2796c..ffb267a30 100644 --- a/schema.sql +++ b/schema.sql @@ -963,8 +963,8 @@ CREATE TABLE public.users ( admin_level integer DEFAULT 0 NOT NULL, over_18 boolean DEFAULT false NOT NULL, is_activated boolean DEFAULT false NOT NULL, - bio character varying(1500), - bio_html character varying(10000), + bio character varying(5000), + bio_html character varying(20000), referred_by integer, is_banned integer, ban_reason character varying(256), @@ -1015,11 +1015,11 @@ CREATE TABLE public.users ( marseyawarded integer, sig character varying(200), sig_html character varying(1000), - friends character varying(1000), - friends_html character varying(5000), + friends character varying(5000), + friends_html character varying(20000), sigs_disabled boolean, - enemies character varying(1000), - enemies_html character varying(5000), + enemies character varying(5000), + enemies_html character varying(20000), fp character varying(21), longpost integer, bird integer, @@ -2879,4 +2879,3 @@ ALTER TABLE ONLY public.comments -- -- PostgreSQL database dump complete -- -