using presence service
This commit is contained in:
parent
823b3c56c1
commit
15ef976538
|
@ -10,6 +10,7 @@ from services.schema import mutation
|
|||
from orm.shout import Shout, ShoutAuthor, ShoutTopic
|
||||
from orm.topic import Topic
|
||||
from resolvers.reactions import reactions_follow, reactions_unfollow
|
||||
from services.presence import notify_shout
|
||||
|
||||
|
||||
@mutation.field("createShout")
|
||||
|
@ -157,6 +158,7 @@ async def update_shout(_, info, shout_id, shout_input=None, publish=False):
|
|||
shout.visibility = "community"
|
||||
shout.publishedAt = datetime.now(tz=timezone.utc)
|
||||
updated = True
|
||||
notify_shout(shout.dict())
|
||||
|
||||
if updated:
|
||||
shout.updatedAt = datetime.now(tz=timezone.utc)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -10,8 +10,7 @@ from services.schema import mutation, query
|
|||
from orm.reaction import Reaction, ReactionKind
|
||||
from orm.shout import Shout, ShoutReactionsFollower
|
||||
from orm.user import User
|
||||
# TODO: use presense interface
|
||||
# from services.notifications.notification_service import notification_service
|
||||
from services.presence import notify_reaction
|
||||
|
||||
|
||||
def add_reaction_stat_columns(q):
|
||||
|
@ -65,7 +64,7 @@ def reactions_follow(user_id, shout_id: int, auto=False):
|
|||
session.add(following)
|
||||
session.commit()
|
||||
return True
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
|
@ -89,7 +88,7 @@ def reactions_unfollow(user_id: int, shout_id: int):
|
|||
session.delete(following)
|
||||
session.commit()
|
||||
return True
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return False
|
||||
|
||||
|
@ -242,8 +241,7 @@ async def create_reaction(_, info, reaction):
|
|||
session.add(r)
|
||||
session.commit()
|
||||
|
||||
# FIXME: use presence service interface here
|
||||
# await notification_service.handle_new_reaction(r.id)
|
||||
notify_reaction(r.dict())
|
||||
|
||||
rdict = r.dict()
|
||||
rdict["shout"] = shout.dict()
|
||||
|
|
Loading…
Reference in New Issue
Block a user