From 1f0dd044067eaa4fb219c68e5e4ef8bea73941b5 Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 13 Oct 2023 22:04:45 +0300 Subject: [PATCH] rename column and award kind --- files/classes/badges.py | 2 +- files/classes/user.py | 2 +- files/helpers/config/awards.py | 4 ++-- files/helpers/config/const.py | 2 +- files/helpers/cron.py | 2 +- files/helpers/sanitize.py | 2 +- files/routes/awards.py | 6 +++--- files/routes/comments.py | 8 ++++---- files/routes/posts.py | 8 ++++---- migrations/20231013-rename-marsey-to-hieroglyphs.sql | 2 ++ schema.sql | 7 +++---- 11 files changed, 23 insertions(+), 22 deletions(-) create mode 100644 migrations/20231013-rename-marsey-to-hieroglyphs.sql diff --git a/files/classes/badges.py b/files/classes/badges.py index aafe0a1c0..c6230c645 100644 --- a/files/classes/badges.py +++ b/files/classes/badges.py @@ -60,7 +60,7 @@ class Badge(Base): if self.badge_id == 95: return self.user.bird if self.badge_id == 96: return self.user.flairchanged if self.badge_id == 97: return self.user.longpost - if self.badge_id == 98: return self.user.marseyawarded + if self.badge_id == 98: return self.user.hieroglyphs if self.badge_id == 109: return self.user.rehab if self.badge_id == 167: return self.user.owoify if self.badge_id == 168: return self.user.bite diff --git a/files/classes/user.py b/files/classes/user.py index 74d91dcfd..33344730c 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -71,7 +71,7 @@ class User(Base): patron_utc = Column(Integer, default=0) verified = Column(String) verifiedcolor = Column(String) - marseyawarded = Column(Integer, default=0) + hieroglyphs = Column(Integer, default=0) rehab = Column(Integer, default=0) longpost = Column(Integer, default=0) bird = Column(Integer, default=0) diff --git a/files/helpers/config/awards.py b/files/helpers/config/awards.py index 01f51973f..3b08fe47d 100644 --- a/files/helpers/config/awards.py +++ b/files/helpers/config/awards.py @@ -787,8 +787,8 @@ AWARDS = { "positive": False, "included_in_lootbox": False, }, - "marsey": { - "kind": "marsey", + "hieroglyphs": { + "kind": "hieroglyphs", "title": "Hieroglyphs", "description": "Makes the recipient unable to post/comment anything but emojis for 24 hours.", "icon": "fas fa-ankh", diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index bceabf19a..502bfca4b 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -915,7 +915,7 @@ forced_hats = { "progressivestack": ("Attention Whore", "I won the oppression olympics!"), "longpost": ("The Pizzashill", "We need to get rid of the character limit!"), "bird": ("Bluecheck", "Three sentences is too much for me..."), - "marseyawarded": ("Three Lil Marseys", ":marseynotes: :marseynotes: :I prefer to speak in cats:"), + "hieroglyphs": ("Three Lil Marseys", ":marseynotes: :marseynotes: :I prefer to speak in cats:"), "bite": ("Vampire Mask", "When other little girls wanted to be ballet dancers I kind of wanted to be a vampire."), "rainbow": ("Globohomo", "Homosexuality is no longer optional!"), "owoify": ("Cat Ears (wiggly)", "Nuzzles, pounces on you, UwU, you're so warm!.."), diff --git a/files/helpers/cron.py b/files/helpers/cron.py index 83d72b597..1610ee44f 100644 --- a/files/helpers/cron.py +++ b/files/helpers/cron.py @@ -364,7 +364,7 @@ def _award_timers_task(): _process_timer(User.progressivestack, [94], "The progressive stack award you received has expired!") _process_timer(User.bird, [95], "The bird site award you received has expired!") _process_timer(User.longpost, [97], "The pizzashill award you received has expired!") - _process_timer(User.marseyawarded, [98], "The hieroglyphs award you received has expired!") + _process_timer(User.hieroglyphs, [98], "The hieroglyphs award you received has expired!") _process_timer(User.rehab, [109], "The rehab award you received has expired!") _process_timer(User.owoify, [167], "The OwOify award you received has expired!") _process_timer(User.sharpen, [289], "The Sharpen award you received has expired!") diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 8411d0bd7..f64c77ac1 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -831,7 +831,7 @@ def torture_chud(string, username): def complies_with_chud(obj): #check for cases where u should leave if not obj.chudded: return True - if obj.author.marseyawarded: return True + if obj.author.hieroglyphs: return True if isinstance(obj, Post): if obj.id in ADMIGGER_THREADS: return True diff --git a/files/routes/awards.py b/files/routes/awards.py index a94f68b71..a2a97a520 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -414,9 +414,9 @@ def award_thing(v, thing_type, id): badge_grant(badge_id=68, user=author) elif kind == "unpausable": badge_grant(badge_id=67, user=author) - elif kind == "marsey": - if author.marseyawarded: author.marseyawarded += 86400 - else: author.marseyawarded = int(time.time()) + 86400 + elif kind == "hieroglyphs": + if author.hieroglyphs: author.hieroglyphs += 86400 + else: author.hieroglyphs = int(time.time()) + 86400 badge_grant(user=author, badge_id=98) elif kind == "pizzashill": if author.bird: diff --git a/files/routes/comments.py b/files/routes/comments.py index d13f735a7..f2de1cea7 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -275,7 +275,7 @@ def comment(v): c.upvotes = 1 - body_html = sanitize(body, limit_pings=5, showmore=(not v.marseyawarded), count_emojis=not v.marsify, commenters_ping_post_id=commenters_ping_post_id, obj=c, author=v) + body_html = sanitize(body, limit_pings=5, showmore=(not v.hieroglyphs), count_emojis=not v.marsify, commenters_ping_post_id=commenters_ping_post_id, obj=c, author=v) if post_target.id not in ADMIGGER_THREADS and not (v.chud and v.chud_phrase in body.lower()): existing = g.db.query(Comment.id).filter( @@ -291,7 +291,7 @@ def comment(v): execute_antispam_comment_check(body, v) execute_antispam_duplicate_comment_check(v, body_html) - if v.marseyawarded and marseyaward_body_regex.search(body_html) and not (posting_to_post and post_target.id in ADMIGGER_THREADS): + if v.hieroglyphs and marseyaward_body_regex.search(body_html) and not (posting_to_post and post_target.id in ADMIGGER_THREADS): abort(403, "You can only type marseys!") if len(body_html) > COMMENT_BODY_HTML_LENGTH_LIMIT: @@ -675,11 +675,11 @@ def edit_comment(cid, v): body = process_files(request.files, v, body) body = body[:COMMENT_BODY_LENGTH_LIMIT].strip() # process_files potentially adds characters to the post - body_html = sanitize(body, golden=False, limit_pings=5, showmore=(not v.marseyawarded), commenters_ping_post_id=c.parent_post, obj=c, author=c.author) + body_html = sanitize(body, golden=False, limit_pings=5, showmore=(not v.hieroglyphs), commenters_ping_post_id=c.parent_post, obj=c, author=c.author) if len(body_html) > COMMENT_BODY_HTML_LENGTH_LIMIT: abort(400) - if c.author.marseyawarded and marseyaward_body_regex.search(body_html): + if c.author.hieroglyphs and marseyaward_body_regex.search(body_html): abort(403, "You can only type marseys!") oldtext = c.body diff --git a/files/routes/posts.py b/files/routes/posts.py index 4b0fb9523..9a2ed7e23 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -576,14 +576,14 @@ def submit_post(v, hole=None): title_html = filter_emojis_only(title, count_emojis=True, obj=p, author=v) - if v.marseyawarded and not marseyaward_title_regex.fullmatch(title_html): + if v.hieroglyphs and not marseyaward_title_regex.fullmatch(title_html): abort(400, "You can only type marseys!") p.title_html = title_html body_html = sanitize(body, count_emojis=True, limit_pings=100, obj=p, author=v) - if v.marseyawarded and marseyaward_body_regex.search(body_html): + if v.hieroglyphs and marseyaward_body_regex.search(body_html): abort(400, "You can only type marseys!") if len(body_html) > POST_BODY_HTML_LENGTH_LIMIT: @@ -1016,7 +1016,7 @@ def edit_post(pid, v): if title != p.title: title_html = filter_emojis_only(title, golden=False, obj=p, author=p.author) - if p.author.marseyawarded and not marseyaward_title_regex.fullmatch(title_html): + if p.author.hieroglyphs and not marseyaward_title_regex.fullmatch(title_html): abort(403, "You can only type marseys!") if 'megathread' in title.lower() and 'megathread' not in p.title.lower(): @@ -1031,7 +1031,7 @@ def edit_post(pid, v): if body != p.body: body_html = sanitize(body, golden=False, limit_pings=100, obj=p, author=p.author) - if p.author.marseyawarded and marseyaward_body_regex.search(body_html): + if p.author.hieroglyphs and marseyaward_body_regex.search(body_html): abort(403, "You can only type marseys!") diff --git a/migrations/20231013-rename-marsey-to-hieroglyphs.sql b/migrations/20231013-rename-marsey-to-hieroglyphs.sql new file mode 100644 index 000000000..8ed462036 --- /dev/null +++ b/migrations/20231013-rename-marsey-to-hieroglyphs.sql @@ -0,0 +1,2 @@ +alter table users rename column marseyawarded to hieroglyphs; +update award_relationships set kind='hieroglyphs' where kind='marsey'; diff --git a/schema.sql b/schema.sql index 4f054253c..d1d0c092d 100644 --- a/schema.sql +++ b/schema.sql @@ -129,7 +129,7 @@ CREATE TABLE public.users ( coins_spent integer DEFAULT 0 NOT NULL, marseybux integer DEFAULT 0 NOT NULL, verifiedcolor character varying(6), - marseyawarded integer, + hieroglyphs integer, sig character varying(200), sig_html character varying(1000), friends character varying(5000), @@ -2222,10 +2222,10 @@ CREATE INDEX users_longpost_idx ON public.users USING btree (longpost); -- --- Name: users_marseyawarded_idx; Type: INDEX; Schema: public; Owner: - +-- Name: users_hieroglyphs_idx; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX users_marseyawarded_idx ON public.users USING btree (marseyawarded); +CREATE INDEX users_hieroglyphs_idx ON public.users USING btree (hieroglyphs); -- @@ -3047,4 +3047,3 @@ ALTER TABLE ONLY public.comments -- -- PostgreSQL database dump complete -- -