dedup
parent
625ff6b006
commit
9be96bf827
|
@ -293,7 +293,6 @@ def award_thing(v, thing_type, id):
|
||||||
thing.stickied_utc = int(time.time()) + add
|
thing.stickied_utc = int(time.time()) + add
|
||||||
|
|
||||||
thing.stickied = f'{v.username}{PIN_AWARD_TEXT}'
|
thing.stickied = f'{v.username}{PIN_AWARD_TEXT}'
|
||||||
g.db.add(thing)
|
|
||||||
cache.delete_memoized(frontlist)
|
cache.delete_memoized(frontlist)
|
||||||
elif kind == "unpin":
|
elif kind == "unpin":
|
||||||
if not thing.stickied_utc: abort(400)
|
if not thing.stickied_utc: abort(400)
|
||||||
|
@ -310,7 +309,6 @@ def award_thing(v, thing_type, id):
|
||||||
thing.stickied_utc = None
|
thing.stickied_utc = None
|
||||||
cache.delete_memoized(frontlist)
|
cache.delete_memoized(frontlist)
|
||||||
else: thing.stickied_utc = t
|
else: thing.stickied_utc = t
|
||||||
g.db.add(thing)
|
|
||||||
elif kind == "queen":
|
elif kind == "queen":
|
||||||
if author.chud:
|
if author.chud:
|
||||||
abort(409, f"{safe_username} under the effect of a conflicting award: Chud award!")
|
abort(409, f"{safe_username} under the effect of a conflicting award: Chud award!")
|
||||||
|
@ -351,7 +349,6 @@ def award_thing(v, thing_type, id):
|
||||||
thing.body_html = sanitize(thing.body, limit_pings=5, showmore=True, obj=thing, author=author)
|
thing.body_html = sanitize(thing.body, limit_pings=5, showmore=True, obj=thing, author=author)
|
||||||
if isinstance(thing, Post):
|
if isinstance(thing, Post):
|
||||||
thing.title_html = filter_emojis_only(thing.title, golden=False, obj=thing, author=author)
|
thing.title_html = filter_emojis_only(thing.title, golden=False, obj=thing, author=author)
|
||||||
g.db.add(thing)
|
|
||||||
|
|
||||||
elif kind == "chud":
|
elif kind == "chud":
|
||||||
if thing_type == 'post' and thing.sub == 'chudrama' \
|
if thing_type == 'post' and thing.sub == 'chudrama' \
|
||||||
|
@ -490,7 +487,6 @@ def award_thing(v, thing_type, id):
|
||||||
thing.body_html = sanitize(thing.body, limit_pings=5, showmore=True, obj=thing, author=author)
|
thing.body_html = sanitize(thing.body, limit_pings=5, showmore=True, obj=thing, author=author)
|
||||||
if isinstance(thing, Post):
|
if isinstance(thing, Post):
|
||||||
thing.title_html = filter_emojis_only(thing.title, golden=False, obj=thing, author=author)
|
thing.title_html = filter_emojis_only(thing.title, golden=False, obj=thing, author=author)
|
||||||
g.db.add(thing)
|
|
||||||
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:
|
||||||
|
@ -518,7 +514,6 @@ def award_thing(v, thing_type, id):
|
||||||
thing.body_html = sanitize(thing.body, limit_pings=5, showmore=True, obj=thing, author=author)
|
thing.body_html = sanitize(thing.body, limit_pings=5, showmore=True, obj=thing, author=author)
|
||||||
if isinstance(thing, Post):
|
if isinstance(thing, Post):
|
||||||
thing.title_html = filter_emojis_only(thing.title, golden=False, obj=thing, author=author)
|
thing.title_html = filter_emojis_only(thing.title, golden=False, obj=thing, author=author)
|
||||||
g.db.add(thing)
|
|
||||||
elif ("Edgy" in kind and kind == v.house) or kind == 'sharpen':
|
elif ("Edgy" in kind and kind == v.house) or kind == 'sharpen':
|
||||||
if author.chud:
|
if author.chud:
|
||||||
abort(409, f"{safe_username} under the effect of a conflicting award: Chud award!")
|
abort(409, f"{safe_username} under the effect of a conflicting award: Chud award!")
|
||||||
|
@ -532,13 +527,11 @@ def award_thing(v, thing_type, id):
|
||||||
thing.body_html = sanitize(thing.body, limit_pings=5, showmore=True, obj=thing, author=author)
|
thing.body_html = sanitize(thing.body, limit_pings=5, showmore=True, obj=thing, author=author)
|
||||||
if isinstance(thing, Post):
|
if isinstance(thing, Post):
|
||||||
thing.title_html = filter_emojis_only(thing.title, golden=False, obj=thing, author=author)
|
thing.title_html = filter_emojis_only(thing.title, golden=False, obj=thing, author=author)
|
||||||
g.db.add(thing)
|
|
||||||
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
|
||||||
badge_grant(user=author, badge_id=171)
|
badge_grant(user=author, badge_id=171)
|
||||||
thing.rainbowed = True
|
thing.rainbowed = True
|
||||||
g.db.add(thing)
|
|
||||||
elif kind == "emoji":
|
elif kind == "emoji":
|
||||||
award.note = award.note.strip(":").lower()
|
award.note = award.note.strip(":").lower()
|
||||||
emoji = g.db.query(Emoji).filter_by(name=award.note).one_or_none()
|
emoji = g.db.query(Emoji).filter_by(name=award.note).one_or_none()
|
||||||
|
@ -618,6 +611,8 @@ def award_thing(v, thing_type, id):
|
||||||
else: author.received_award_count = 1
|
else: author.received_award_count = 1
|
||||||
g.db.add(author)
|
g.db.add(author)
|
||||||
|
|
||||||
|
g.db.add(thing)
|
||||||
|
|
||||||
return {"message": f"{AWARDS[kind]['title']} award given to {thing_type} successfully!"}
|
return {"message": f"{AWARDS[kind]['title']} award given to {thing_type} successfully!"}
|
||||||
|
|
||||||
@app.post("/trick-or-treat")
|
@app.post("/trick-or-treat")
|
||||||
|
|
Loading…
Reference in New Issue