user User for awhile, filter follower fields
Some checks failed
deploy / deploy (push) Failing after 23s
Some checks failed
deploy / deploy (push) Failing after 23s
This commit is contained in:
parent
562a919fca
commit
bc08ece4c3
|
@ -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":
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue
Block a user