- make rainbow, sharpen, queen not retroactive

- make sharpen fully affect all future posts
- make old posts and comments affected by these awards unfixable after they expire
pull/195/head
Aevann 2023-08-14 14:00:29 +03:00
parent 8df49c50da
commit bd1ea70a1a
10 changed files with 55 additions and 15 deletions

View File

@ -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")

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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))

View File

@ -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!")

View File

@ -247,7 +247,7 @@
{% endif %}
{% set realbody = c.realbody(v) %}
<div id="comment-text-{{c.id}}" class="comment-text mb-0 {% if c.chudded %}text-uppercase chud-img chud-{{c.id_last_num}}{% endif %} {% if c.author.rainbow %}rainbow-text{% endif %} {%if c.author.queen%}queen{%endif%} {%if c.author.sharpen%}sharpen chud-img sharpen-{{c.id_last_num}}{%endif%}">
<div id="comment-text-{{c.id}}" class="comment-text mb-0 {% if c.chudded %}text-uppercase chud-img chud-{{c.id_last_num}}{% endif %} {% if c.rainbowed %}rainbow-text{% endif %} {%if c.queened%}queen{%endif%} {%if c.sharpened%}sharpen chud-img sharpen-{{c.id_last_num}}{%endif%}">
{{realbody | safe}}
</div>

View File

@ -79,7 +79,7 @@
{{macros.reports(p, 'post')}}
<h1 id="post-title" class="card-title post-title text-left mb-md-3 {% if p.chudded %}text-uppercase{% endif %} {% if p.author.rainbow %}rainbow-text{% endif %} {% if p.author.queen %}queen{% endif %} {%if p.author.sharpen %}sharpen{% endif %}">
<h1 id="post-title" class="card-title post-title text-left mb-md-3 {% if p.chudded %}text-uppercase{% endif %} {% if p.rainbowed %}rainbow-text{% endif %} {% if p.queened %}queen{% endif %} {%if p.sharpened %}sharpen{% endif %}">
{% if p.flair %}<span class="patron font-weight-bolder mr-1" style="background-color:var(--primary); font-size:12px; line-height:2;">{{p.flair | safe}}</span>{% endif %}
{{p.realtitle(v) | safe}}
</h1>
@ -108,7 +108,7 @@
{% endif %}
<div id="post-text" class="{% if p.chudded %}text-uppercase chud-img chud-{{p.id_last_num}}{% endif %} {% if p.author.rainbow %}rainbow-text{% endif %} {%if p.author.queen%}queen{%endif%} {%if p.author.sharpen%}sharpen chud-img sharpen-{{p.id_last_num}}{%endif%}">
<div id="post-text" class="{% if p.chudded %}text-uppercase chud-img chud-{{p.id_last_num}}{% endif %} {% if p.rainbowed %}rainbow-text{% endif %} {%if p.queened%}queen{%endif%} {%if p.sharpened%}sharpen chud-img sharpen-{{p.id_last_num}}{%endif%}">
{% if p.is_image %}
<div class="row no-gutters mb-4">
<div class="col">

View File

@ -208,7 +208,7 @@
{% if not v_forbid_deleted %}
{% if p.realbody(v) %}
<div class="d-none card rounded border {% if p.chudded %}text-uppercase chud-img chud-{{p.id_last_num}}{% endif %} {% if p.author.rainbow %}rainbow-text{% endif %} {%if p.author.queen%}queen{%endif%} {%if p.author.sharpen%}sharpen{%endif%} post-preview" id="post-text-{{p.id}}">
<div class="d-none card rounded border {% if p.chudded %}text-uppercase chud-img chud-{{p.id_last_num}}{% endif %} {% if p.rainbowed %}rainbow-text{% endif %} {%if p.queened%}queen{%endif%} {%if p.sharpened%}sharpen{%endif%} post-preview" id="post-text-{{p.id}}">
{{p.realbody(v) | safe}}
</div>
{% endif %}

View File

@ -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;