forked from rDrama/rDrama
dedup body altering in award code
parent
cc8553b9a4
commit
cf9b4a017e
|
@ -137,6 +137,11 @@ def buy(v, kind):
|
||||||
|
|
||||||
return {"message": f"{award_title} award bought!"}
|
return {"message": f"{award_title} award bought!"}
|
||||||
|
|
||||||
|
def alter_body(thing):
|
||||||
|
thing.body_html = sanitize(thing.body, limit_pings=5, showmore=True, obj=thing, author=author)
|
||||||
|
if isinstance(thing, Post):
|
||||||
|
thing.title_html = filter_emojis_only(thing.title, golden=False, obj=thing, author=author)
|
||||||
|
|
||||||
@app.post("/award/<thing_type>/<int:id>")
|
@app.post("/award/<thing_type>/<int:id>")
|
||||||
@limiter.limit('1/second', scope=rpath)
|
@limiter.limit('1/second', scope=rpath)
|
||||||
@limiter.limit('1/second', scope=rpath, key_func=get_ID)
|
@limiter.limit('1/second', scope=rpath, key_func=get_ID)
|
||||||
|
@ -245,7 +250,7 @@ def award_thing(v, thing_type, id):
|
||||||
|
|
||||||
link = f"[this {thing_type}]({thing.shortlink})"
|
link = f"[this {thing_type}]({thing.shortlink})"
|
||||||
|
|
||||||
alter_body = not (isinstance(thing, Post) and len(thing.body) > 1000) and (not thing.author.deflector or v == thing.author)
|
can_alter_body = not (isinstance(thing, Post) and len(thing.body) > 1000) and (not thing.author.deflector or v == thing.author)
|
||||||
|
|
||||||
if kind == "ban":
|
if kind == "ban":
|
||||||
link = f"/{thing_type}/{thing.id}"
|
link = f"/{thing_type}/{thing.id}"
|
||||||
|
@ -354,12 +359,9 @@ def award_thing(v, thing_type, id):
|
||||||
|
|
||||||
badge_grant(user=author, badge_id=285)
|
badge_grant(user=author, badge_id=285)
|
||||||
|
|
||||||
if alter_body:
|
if can_alter_body:
|
||||||
thing.queened = True
|
thing.queened = True
|
||||||
thing.body_html = sanitize(thing.body, limit_pings=5, showmore=True, obj=thing, author=author)
|
alter_body(thing)
|
||||||
if isinstance(thing, Post):
|
|
||||||
thing.title_html = filter_emojis_only(thing.title, golden=False, obj=thing, author=author)
|
|
||||||
|
|
||||||
elif kind == "chud":
|
elif kind == "chud":
|
||||||
if thing_type == 'post' and thing.hole == 'chudrama' \
|
if thing_type == 'post' and thing.hole == 'chudrama' \
|
||||||
or thing_type == 'comment' and thing.post and thing.post.hole == 'chudrama':
|
or thing_type == 'comment' and thing.post and thing.post.hole == 'chudrama':
|
||||||
|
@ -380,7 +382,7 @@ def award_thing(v, thing_type, id):
|
||||||
|
|
||||||
badge_grant(user=author, badge_id=58)
|
badge_grant(user=author, badge_id=58)
|
||||||
|
|
||||||
if alter_body:
|
if can_alter_body:
|
||||||
thing.chudded = True
|
thing.chudded = True
|
||||||
complies_with_chud(thing)
|
complies_with_chud(thing)
|
||||||
elif kind == "flairlock":
|
elif kind == "flairlock":
|
||||||
|
@ -482,10 +484,8 @@ def award_thing(v, thing_type, id):
|
||||||
else: author.marsify = int(time.time()) + 86400
|
else: author.marsify = int(time.time()) + 86400
|
||||||
badge_grant(user=author, badge_id=170)
|
badge_grant(user=author, badge_id=170)
|
||||||
|
|
||||||
if alter_body:
|
if can_alter_body:
|
||||||
thing.body_html = sanitize(thing.body, limit_pings=5, showmore=True, obj=thing, author=author)
|
alter_body(thing)
|
||||||
if isinstance(thing, Post):
|
|
||||||
thing.title_html = filter_emojis_only(thing.title, golden=False, obj=thing, author=author)
|
|
||||||
elif "Vampire" in kind and kind == v.house:
|
elif "Vampire" in kind and kind == v.house:
|
||||||
if author.bite: author.bite += 172800
|
if author.bite: author.bite += 172800
|
||||||
else:
|
else:
|
||||||
|
@ -506,20 +506,16 @@ def award_thing(v, thing_type, id):
|
||||||
else: author.owoify = int(time.time()) + 21600
|
else: author.owoify = int(time.time()) + 21600
|
||||||
badge_grant(user=author, badge_id=167)
|
badge_grant(user=author, badge_id=167)
|
||||||
|
|
||||||
if alter_body:
|
if can_alter_body:
|
||||||
thing.body_html = sanitize(thing.body, limit_pings=5, showmore=True, obj=thing, author=author)
|
alter_body(thing)
|
||||||
if isinstance(thing, Post):
|
|
||||||
thing.title_html = filter_emojis_only(thing.title, golden=False, obj=thing, author=author)
|
|
||||||
elif ("Edgy" in kind and kind == v.house) or kind == 'sharpen':
|
elif ("Edgy" in kind and kind == v.house) or kind == 'sharpen':
|
||||||
if author.sharpen: author.sharpen += 86400
|
if author.sharpen: author.sharpen += 86400
|
||||||
else: author.sharpen = int(time.time()) + 86400
|
else: author.sharpen = int(time.time()) + 86400
|
||||||
badge_grant(user=author, badge_id=289)
|
badge_grant(user=author, badge_id=289)
|
||||||
|
|
||||||
if alter_body:
|
if can_alter_body:
|
||||||
thing.sharpened = True
|
thing.sharpened = True
|
||||||
thing.body_html = sanitize(thing.body, limit_pings=5, showmore=True, obj=thing, author=author)
|
alter_body(thing)
|
||||||
if isinstance(thing, Post):
|
|
||||||
thing.title_html = filter_emojis_only(thing.title, golden=False, obj=thing, author=author)
|
|
||||||
elif ("Femboy" in kind and kind == v.house) or kind == 'rainbow':
|
elif ("Femboy" in kind and kind == v.house) or kind == 'rainbow':
|
||||||
if author.rainbow: author.rainbow += 86400
|
if author.rainbow: author.rainbow += 86400
|
||||||
else: author.rainbow = int(time.time()) + 86400
|
else: author.rainbow = int(time.time()) + 86400
|
||||||
|
|
Loading…
Reference in New Issue