forked from rDrama/rDrama
1
0
Fork 0

dedup effortpost protection and raise the limit from 1k to 3k characters

master
Aevann 2023-10-15 16:54:29 +03:00
parent cf9b4a017e
commit f6f254307f
5 changed files with 17 additions and 10 deletions

View File

@ -510,3 +510,8 @@ class Comment(Base):
@lazy
def emoji_awards_emojis(self, v, kind, OVER_18_EMOJIS):
return get_emoji_awards_emojis(self, v, kind, OVER_18_EMOJIS)
@property
@lazy
def is_effortpost(self):
return False

View File

@ -392,3 +392,8 @@ class Post(Base):
@lazy
def emoji_awards_emojis(self, v, kind, OVER_18_EMOJIS):
return get_emoji_awards_emojis(self, v, kind, OVER_18_EMOJIS)
@property
@lazy
def is_effortpost(self):
return len(self.body) >= 3000

View File

@ -376,7 +376,7 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=False, count_emojis
if blackjack and execute_blackjack(v, None, sanitized, blackjack):
return '<p>g</p>'
if obj and not (isinstance(obj, Post) and len(obj.body) > 1000):
if obj and not obj.is_effortpost:
if author.owoify:
sanitized = owoify(sanitized, author.chud_phrase)
if author.marsify:
@ -676,7 +676,7 @@ def filter_emojis_only(title, golden=True, count_emojis=False, obj=None, author=
title = remove_cuniform(title)
if obj and not (isinstance(obj, Post) and len(obj.body) > 1000):
if obj and not obj.is_effortpost:
if author.owoify:
title = owoify(title, author.chud_phrase)
if author.marsify:

View File

@ -250,7 +250,7 @@ def award_thing(v, thing_type, id):
link = f"[this {thing_type}]({thing.shortlink})"
can_alter_body = not (isinstance(thing, Post) and len(thing.body) > 1000) and (not thing.author.deflector or v == thing.author)
can_alter_body = not thing.is_effortpost and (not thing.author.deflector or v == thing.author)
if kind == "ban":
link = f"/{thing_type}/{thing.id}"

View File

@ -550,10 +550,6 @@ def submit_post(v, hole=None):
if url == '': url = None
flag_chudded = v.chud and hole != 'chudrama' and not (len(body) > 1000 and not v.chudded_by)
flag_queened = v.queen and len(body) <= 1000
flag_sharpened = v.sharpen and len(body) <= 1000
p = Post(
private=flag_private,
notify=flag_notify,
@ -568,12 +564,13 @@ def submit_post(v, hole=None):
title=title,
hole=hole,
ghost=flag_ghost,
chudded=flag_chudded,
rainbowed=bool(v.rainbow),
queened=flag_queened,
sharpened=flag_sharpened,
)
p.chudded = v.chud and hole != 'chudrama' and not (p.is_effortpost and not v.chudded_by)
p.queened = v.queen and not p.is_effortpost
p.sharpened = v.sharpen and not p.is_effortpost
title_html = filter_emojis_only(title, count_emojis=True, obj=p, author=v)
if v.hieroglyphs and not marseyaward_title_regex.fullmatch(title_html):