diff --git a/resolvers/following.py b/resolvers/following.py index 389e8285..aeab696e 100644 --- a/resolvers/following.py +++ b/resolvers/following.py @@ -7,7 +7,7 @@ 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 orm.user import User from services.db import local_session @@ -22,7 +22,7 @@ async def follow(_, info, what, 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() + author_id = session.query(User.id).where(User.slug == slug).one() follower = session.query() notify_follower(follower.dict(), author_id) elif what == "TOPIC": diff --git a/services/presence.py b/services/presence.py index 31c63f7a..9a4df676 100644 --- a/services/presence.py +++ b/services/presence.py @@ -1,11 +1,8 @@ import json -from orm.reaction import Reaction -from orm.shout import Shout -from orm.user import Author from services.redis import redis -async def notify_reaction(reaction: Reaction): +async def notify_reaction(reaction): channel_name = "new_reaction" data = { "payload": reaction, @@ -17,7 +14,7 @@ async def notify_reaction(reaction: Reaction): print(f"Failed to publish to channel {channel_name}: {e}") -async def notify_shout(shout: Shout): +async def notify_shout(shout): channel_name = "new_shout" data = { "payload": shout, @@ -29,7 +26,11 @@ async def notify_shout(shout: Shout): print(f"Failed to publish to channel {channel_name}: {e}") -async def notify_follower(follower: Author, author_id: int): +async def notify_follower(follower: dict, author_id: int): + fields = follower.keys() + for k in fields: + if k not in ["id", "name", "slug", "userpic"]: + del follower[k] channel_name = f"followers:{author_id}" data = { "payload": follower,