This commit is contained in:
parent
67636e6d17
commit
6e80942beb
|
@ -9,7 +9,7 @@ from orm.rating import is_negative, is_positive
|
|||
from orm.reaction import Reaction, ReactionKind
|
||||
from orm.shout import Shout, ShoutAuthor, ShoutTopic
|
||||
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 services.auth import login_required
|
||||
from services.cache import cache_author, cache_topic
|
||||
|
@ -146,7 +146,7 @@ async def create_shout(_, info, inp):
|
|||
|
||||
session.commit()
|
||||
|
||||
reactions_follow(author_id, shout.id, True)
|
||||
follow(None, info, "shout", shout.slug)
|
||||
|
||||
# notifier
|
||||
# await notify_shout(shout_dict, 'create')
|
||||
|
@ -314,8 +314,10 @@ async def delete_shout(_, info, shout_id: int):
|
|||
session.commit()
|
||||
|
||||
for author in shout.authors:
|
||||
reactions_unfollow(author.id, shout_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:
|
||||
await cache_by_id(Topic, topic.id)
|
||||
|
|
|
@ -10,7 +10,7 @@ from orm.rating import PROPOSAL_REACTIONS, RATING_REACTIONS, is_negative, is_pos
|
|||
from orm.reaction import Reaction, ReactionKind
|
||||
from orm.shout import Shout
|
||||
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 services.auth import add_user_role, login_required
|
||||
from services.db import local_session
|
||||
|
@ -106,7 +106,7 @@ def set_unfeatured(session, shout_id):
|
|||
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)
|
||||
session.add(r)
|
||||
session.commit()
|
||||
|
@ -132,7 +132,7 @@ async def _create_reaction(session, shout, author_id: int, reaction):
|
|||
if r.kind == ReactionKind.LIKE.value:
|
||||
try:
|
||||
# reactions auto-following
|
||||
reactions_follow(author_id, reaction["shout"], True)
|
||||
follow(None, info, "shout", shout.slug)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
@ -214,7 +214,7 @@ async def create_reaction(_, info, reaction):
|
|||
if 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
|
||||
rdict["created_by"] = author_dict
|
||||
|
|
Loading…
Reference in New Issue
Block a user