diff --git a/files/classes/comment.py b/files/classes/comment.py index 87d178579..aa0dee75f 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -143,6 +143,9 @@ class Comment(Base): blackjack_result = Column(String) casino_game_id = Column(Integer, ForeignKey("casino_games.id")) chudded = Column(Boolean, default=False) + rainbowed = Column(Boolean, default=False) + queened = Column(Boolean, default=False) + sharpened = Column(Boolean, default=False) oauth_app = relationship("OauthApp") post = relationship("Post", back_populates="comments") diff --git a/files/classes/post.py b/files/classes/post.py index c63ddad88..5717d8f34 100644 --- a/files/classes/post.py +++ b/files/classes/post.py @@ -60,6 +60,9 @@ class Post(Base): new = Column(Boolean) notify = Column(Boolean) chudded = Column(Boolean, default=False) + rainbowed = Column(Boolean, default=False) + queened = Column(Boolean, default=False) + sharpened = Column(Boolean, default=False) ping_cost = Column(Integer, default=0) bump_utc = Column(Integer) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index f12b382ff..39d1429df 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -860,8 +860,9 @@ def torture_object(obj, torture_method): def complies_with_chud(obj): #check for cases where u should leave - if not (obj.author.chud or obj.author.queen): return True + if not (obj.chudded or obj.queened): return True if obj.author.marseyawarded: return True + if isinstance(obj, Post): if obj.id in ADMIGGER_THREADS: return True if obj.sub == "chudrama": return True @@ -869,9 +870,7 @@ def complies_with_chud(obj): if obj.parent_post in ADMIGGER_THREADS: return True if obj.post.sub == "chudrama": return True - if obj.author.chud: - if not obj.chudded: return True - + if obj.chudded: #perserve old body_html to be used in checking for chud phrase old_body_html = obj.body_html @@ -887,7 +886,7 @@ def complies_with_chud(obj): #torture title_html and check for chud_phrase in plain title and leave if it's there if isinstance(obj, Post): obj.title_html = torture_chud(obj.title_html, obj.author.username) - if obj.author.chud_phrase in obj.title.lower(): + if not obj.author.chud or obj.author.chud_phrase in obj.title.lower(): return True #check for chud_phrase in body_html @@ -897,10 +896,10 @@ def complies_with_chud(obj): tags = soup.html.body.find_all(lambda tag: tag.name not in excluded_tags and not tag.attrs, recursive=False) for tag in tags: for text in tag.find_all(text=True, recursive=False): - if obj.author.chud_phrase in text.lower(): + if not obj.author.chud or obj.author.chud_phrase in text.lower(): return True return False - elif obj.author.queen: + elif obj.queened: torture_object(obj, torture_queen) return True diff --git a/files/routes/awards.py b/files/routes/awards.py index a5dc76ca9..360b13994 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -350,6 +350,10 @@ def award_thing(v, thing_type, id): badge_grant(user=author, badge_id=285) + if thing_type == 'comment' and not thing.author.deflector: + thing.queened = True + g.db.add(thing) + elif kind == "chud": if thing_type == 'post' and thing.sub == 'chudrama' \ or thing_type == 'comment' and thing.post and thing.post.sub == 'chudrama': @@ -528,11 +532,15 @@ def award_thing(v, thing_type, id): body = thing.body body = sharpen(body) thing.body_html = sanitize(body, limit_pings=5, showmore=True) + thing.sharpened = True g.db.add(thing) elif ("Femboy" in kind and kind == v.house) or kind == 'rainbow': if author.rainbow: author.rainbow += 86400 else: author.rainbow = int(time.time()) + 86400 badge_grant(user=author, badge_id=171) + if thing_type == 'comment' and not thing.author.deflector: + thing.rainbowed = True + g.db.add(thing) elif kind == "spider": if author.spider: author.spider += 86400 else: author.spider = int(time.time()) + 86400 diff --git a/files/routes/comments.py b/files/routes/comments.py index 381d4acc6..ccfba99d6 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -286,7 +286,10 @@ def comment(v): body=body, ghost=ghost, chudded=chudded, - ) + rainbowed=bool(v.rainbow), + queened=bool(v.queen), + sharpened=bool(v.sharpen), + ) c.upvotes = 1 g.db.add(c) @@ -637,7 +640,7 @@ def edit_comment(cid, v): body_for_sanitize = owoify(body_for_sanitize) if v.marsify and not v.chud: body_for_sanitize = marsify(body_for_sanitize) - if v.sharpen: + if c.sharpened: body_for_sanitize = sharpen(body_for_sanitize) body_html = sanitize(body_for_sanitize, golden=False, limit_pings=5, showmore=(not v.marseyawarded)) diff --git a/files/routes/posts.py b/files/routes/posts.py index d7e4eb2e1..113ba6ff7 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -17,6 +17,7 @@ from files.helpers.actions import * from files.helpers.alerts import * from files.helpers.config.const import * from files.helpers.get import * +from files.helpers.sharpen import * from files.helpers.regex import * from files.helpers.sanitize import * from files.helpers.settings import get_setting @@ -513,7 +514,10 @@ def submit_post(v, sub=None): body = process_files(request.files, v, body) body = body[:POST_BODY_LENGTH_LIMIT(v)].strip() # process_files() adds content to the body, so we need to re-strip - body_html = sanitize(body, count_emojis=True, limit_pings=100) + body_for_sanitize = body + if v.sharpen: body_for_sanitize = sharpen(body_for_sanitize) + + body_html = sanitize(body_for_sanitize, count_emojis=True, limit_pings=100) if v.marseyawarded and marseyaward_body_regex.search(body_html): abort(400, "You can only type marseys!") @@ -556,6 +560,9 @@ def submit_post(v, sub=None): sub=sub, ghost=flag_ghost, chudded=flag_chudded, + rainbowed=bool(v.rainbow), + queened=bool(v.queen), + sharpened=bool(v.sharpen), ) g.db.add(p) @@ -1007,7 +1014,10 @@ def edit_post(pid, v): body = body[:POST_BODY_LENGTH_LIMIT(v)].strip() # process_files() may be adding stuff to the body if body != p.body: - body_html = sanitize(body, golden=False, limit_pings=100) + body_for_sanitize = body + if p.sharpened: body_for_sanitize = sharpen(body_for_sanitize) + + body_html = sanitize(body_for_sanitize, golden=False, limit_pings=100) if v.id == p.author_id and v.marseyawarded and marseyaward_body_regex.search(body_html): abort(403, "You can only type marseys!") diff --git a/files/templates/comments.html b/files/templates/comments.html index 492216cc9..f1b32c12d 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -247,7 +247,7 @@ {% endif %} {% set realbody = c.realbody(v) %} -
+
{{realbody | safe}}
diff --git a/files/templates/post.html b/files/templates/post.html index f2fbc5ef1..a9c731d60 100644 --- a/files/templates/post.html +++ b/files/templates/post.html @@ -79,7 +79,7 @@ {{macros.reports(p, 'post')}} -

+

{% if p.flair %}{{p.flair | safe}}{% endif %} {{p.realtitle(v) | safe}}

@@ -108,7 +108,7 @@ {% endif %} -
+
{% if p.is_image %}
diff --git a/files/templates/post_listing.html b/files/templates/post_listing.html index ebf861bbf..c305605ca 100644 --- a/files/templates/post_listing.html +++ b/files/templates/post_listing.html @@ -208,7 +208,7 @@ {% if not v_forbid_deleted %} {% if p.realbody(v) %} -
+
{{p.realbody(v) | safe}}
{% endif %} diff --git a/migrations/20230814-make-rainbow-queen-sharpen-not-retroactive.sql b/migrations/20230814-make-rainbow-queen-sharpen-not-retroactive.sql new file mode 100644 index 000000000..10ff64e6a --- /dev/null +++ b/migrations/20230814-make-rainbow-queen-sharpen-not-retroactive.sql @@ -0,0 +1,14 @@ +alter table posts add column rainbowed bool default false not null; +alter table comments add column rainbowed bool default false not null; +alter table posts alter column rainbowed drop default; +alter table comments alter column rainbowed drop default; + +alter table posts add column queened bool default false not null; +alter table comments add column queened bool default false not null; +alter table posts alter column queened drop default; +alter table comments alter column queened drop default; + +alter table posts add column sharpened bool default false not null; +alter table comments add column sharpened bool default false not null; +alter table posts alter column sharpened drop default; +alter table comments alter column sharpened drop default;