using presence service

This commit is contained in:
2023-10-16 18:18:29 +03:00
parent 823b3c56c1
commit 15ef976538
5 changed files with 13 additions and 6 deletions

View File

@@ -6,6 +6,9 @@ from resolvers.reactions import reactions_follow, reactions_unfollow
from resolvers.topics import topic_follow, topic_unfollow
from services.following import FollowingManager, FollowingResult
from resolvers.community import community_follow, community_unfollow
from services.presence import notify_follower
from orm.user import Author
from services.db import local_session
@mutation.field("follow")
@@ -18,6 +21,10 @@ async def follow(_, info, what, slug):
if author_follow(auth.user_id, slug):
result = FollowingResult("NEW", "author", slug)
await FollowingManager.push("author", result)
with local_session() as session:
author_id = session.query(Author.id).where(Author.slug == slug).one()
follower = session.query()
notify_follower(follower.dict(), author_id)
elif what == "TOPIC":
if topic_follow(auth.user_id, slug):
result = FollowingResult("NEW", "topic", slug)