forked from MarseyWorld/MarseyWorld
actions: move pizzashill autovotes to actions
parent
ae1e6b01a4
commit
b9f2a7123e
|
@ -449,3 +449,22 @@ def execute_lawlz_actions(v:User, p:Submission):
|
||||||
g.db.add(ma_1)
|
g.db.add(ma_1)
|
||||||
g.db.add(ma_2)
|
g.db.add(ma_2)
|
||||||
g.db.add(ma_3)
|
g.db.add(ma_3)
|
||||||
|
|
||||||
|
def execute_pizza_autovote(v:User, target:Union[Submission, Comment]):
|
||||||
|
if v.id != PIZZASHILL_ID: return
|
||||||
|
if SITE_NAME != 'rDrama': return
|
||||||
|
votes = len(PIZZA_VOTERS)
|
||||||
|
for uid in PIZZA_VOTERS:
|
||||||
|
if isinstance(target, Submission):
|
||||||
|
autovote = Vote(user_id=uid, submission_id=target.id, vote_type=1)
|
||||||
|
elif isinstance(target, Comment):
|
||||||
|
autovote = CommentVote(user_id=uid, comment_id=target.id, vote_type=1)
|
||||||
|
else:
|
||||||
|
raise TypeError("Expected Submission or Comment")
|
||||||
|
autovote.created_utc += 1
|
||||||
|
g.db.add(autovote)
|
||||||
|
v.coins += votes
|
||||||
|
v.truecoins += votes
|
||||||
|
g.db.add(v)
|
||||||
|
target.upvotes += votes
|
||||||
|
g.db.add(target)
|
||||||
|
|
|
@ -344,16 +344,7 @@ def comment(v):
|
||||||
|
|
||||||
c.voted = 1
|
c.voted = 1
|
||||||
|
|
||||||
if v.id == PIZZASHILL_ID:
|
execute_pizza_autovote(v, c)
|
||||||
for uid in PIZZA_VOTERS:
|
|
||||||
autovote = CommentVote(user_id=uid, comment_id=c.id, vote_type=1)
|
|
||||||
autovote.created_utc += 1
|
|
||||||
g.db.add(autovote)
|
|
||||||
v.coins += 3
|
|
||||||
v.truecoins += 3
|
|
||||||
g.db.add(v)
|
|
||||||
c.upvotes += 3
|
|
||||||
g.db.add(c)
|
|
||||||
|
|
||||||
if v.marseyawarded and parent_post.id not in ADMIGGERS and marseyaward_body_regex.search(body_html):
|
if v.marseyawarded and parent_post.id not in ADMIGGERS and marseyaward_body_regex.search(body_html):
|
||||||
abort(403, "You can only type marseys!")
|
abort(403, "You can only type marseys!")
|
||||||
|
|
|
@ -916,17 +916,7 @@ def submit_post(v, sub=None):
|
||||||
v.post_count = g.db.query(Submission).filter_by(author_id=v.id, deleted_utc=0).count()
|
v.post_count = g.db.query(Submission).filter_by(author_id=v.id, deleted_utc=0).count()
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
|
|
||||||
if v.id == PIZZASHILL_ID:
|
execute_pizza_autovote(v, post)
|
||||||
for uid in PIZZA_VOTERS:
|
|
||||||
autovote = Vote(user_id=uid, submission_id=post.id, vote_type=1)
|
|
||||||
autovote.created_utc += 1
|
|
||||||
g.db.add(autovote)
|
|
||||||
v.coins += 3
|
|
||||||
v.truecoins += 3
|
|
||||||
g.db.add(v)
|
|
||||||
post.upvotes += 3
|
|
||||||
g.db.add(post)
|
|
||||||
|
|
||||||
execute_lawlz_actions(v, post)
|
execute_lawlz_actions(v, post)
|
||||||
|
|
||||||
cache.delete_memoized(frontlist)
|
cache.delete_memoized(frontlist)
|
||||||
|
|
Loading…
Reference in New Issue