reactions-follow-fix
All checks were successful
Deploy on push / deploy (push) Successful in 1m10s

This commit is contained in:
Untone 2024-06-05 18:29:15 +03:00
parent 67636e6d17
commit 6e80942beb
2 changed files with 9 additions and 7 deletions

View File

@ -9,7 +9,7 @@ from orm.rating import is_negative, is_positive
from orm.reaction import Reaction, ReactionKind from orm.reaction import Reaction, ReactionKind
from orm.shout import Shout, ShoutAuthor, ShoutTopic from orm.shout import Shout, ShoutAuthor, ShoutTopic
from orm.topic import Topic from orm.topic import Topic
from resolvers.follower import reactions_follow, reactions_unfollow from resolvers.follower import follow, unfollow
from resolvers.stat import get_with_stat from resolvers.stat import get_with_stat
from services.auth import login_required from services.auth import login_required
from services.cache import cache_author, cache_topic from services.cache import cache_author, cache_topic
@ -146,7 +146,7 @@ async def create_shout(_, info, inp):
session.commit() session.commit()
reactions_follow(author_id, shout.id, True) follow(None, info, "shout", shout.slug)
# notifier # notifier
# await notify_shout(shout_dict, 'create') # await notify_shout(shout_dict, 'create')
@ -314,8 +314,10 @@ async def delete_shout(_, info, shout_id: int):
session.commit() session.commit()
for author in shout.authors: for author in shout.authors:
reactions_unfollow(author.id, shout_id)
await cache_by_id(Author, author.id) await cache_by_id(Author, author.id)
info.context["author"] = author.dict()
info.context["user_id"] = author.user
unfollow(None, info, "shout", shout.slug)
for topic in shout.topics: for topic in shout.topics:
await cache_by_id(Topic, topic.id) await cache_by_id(Topic, topic.id)

View File

@ -10,7 +10,7 @@ from orm.rating import PROPOSAL_REACTIONS, RATING_REACTIONS, is_negative, is_pos
from orm.reaction import Reaction, ReactionKind from orm.reaction import Reaction, ReactionKind
from orm.shout import Shout from orm.shout import Shout
from resolvers.editor import handle_proposing from resolvers.editor import handle_proposing
from resolvers.follower import reactions_follow from resolvers.follower import follow
from resolvers.stat import update_author_stat from resolvers.stat import update_author_stat
from services.auth import add_user_role, login_required from services.auth import add_user_role, login_required
from services.db import local_session from services.db import local_session
@ -106,7 +106,7 @@ def set_unfeatured(session, shout_id):
session.commit() session.commit()
async def _create_reaction(session, shout, author_id: int, reaction): async def _create_reaction(session, info, shout, author_id: int, reaction):
r = Reaction(**reaction) r = Reaction(**reaction)
session.add(r) session.add(r)
session.commit() session.commit()
@ -132,7 +132,7 @@ async def _create_reaction(session, shout, author_id: int, reaction):
if r.kind == ReactionKind.LIKE.value: if r.kind == ReactionKind.LIKE.value:
try: try:
# reactions auto-following # reactions auto-following
reactions_follow(author_id, reaction["shout"], True) follow(None, info, "shout", shout.slug)
except Exception: except Exception:
pass pass
@ -214,7 +214,7 @@ async def create_reaction(_, info, reaction):
if error_result: if error_result:
return error_result return error_result
rdict = await _create_reaction(session, shout, author_id, reaction) rdict = await _create_reaction(session, info, shout, author_id, reaction)
# TODO: call recount ratings periodically # TODO: call recount ratings periodically
rdict["created_by"] = author_dict rdict["created_by"] = author_dict