fix reaction kinds

This commit is contained in:
tonyrewin 2022-12-23 19:37:17 +03:00
parent f7839bf2df
commit 9bb8751d03

View File

@ -88,21 +88,21 @@ def check_to_publish(session, user_id, reaction):
def check_to_hide(session, user_id, reaction): def check_to_hide(session, user_id, reaction):
''' hides any shout if 20% of reactions are negative ''' ''' hides any shout if 20% of reactions are negative '''
if not reaction.replyTo and reaction.kind in [ if not reaction.replyTo and reaction.kind in [
ReactionKind.DECLINE, ReactionKind.REJECT,
ReactionKind.UNLIKE, ReactionKind.DISLIKE,
ReactionKind.UNPROOF ReactionKind.DISPROOF
]: ]:
# if is_published_author(user): # if is_published_author(user):
approvers_reactions = session.query(Reaction).where(Reaction.shout == reaction.shout).all() approvers_reactions = session.query(Reaction).where(Reaction.shout == reaction.shout).all()
declines = 0 rejects = 0
for r in approvers_reactions: for r in approvers_reactions:
if r.kind in [ if r.kind in [
ReactionKind.DECLINE, ReactionKind.REJECT,
ReactionKind.UNLIKE, ReactionKind.DISLIKE,
ReactionKind.UNPROOF ReactionKind.DISPROOF
]: ]:
declines += 1 rejects += 1
if len(approvers_reactions) / declines < 5: if len(approvers_reactions) / rejects < 5:
return True return True
return False return False
@ -135,6 +135,8 @@ async def create_reaction(_, info, reaction={}):
session.add(r) session.add(r)
session.commit() session.commit()
print(r)
# self-regulation mechanics # self-regulation mechanics
if check_to_hide(session, auth.user_id, r): if check_to_hide(session, auth.user_id, r):