From e5aa568933201f0a71e9ed5b2a88e870a9b210e0 Mon Sep 17 00:00:00 2001 From: knst-kotov Date: Thu, 4 Nov 2021 19:37:41 +0300 Subject: [PATCH] initial topicUpdated --- create_crt.sh | 24 ++++++++++++------------ requirements.txt | 1 + resolvers/topics.py | 15 +++++++++++++++ schema.graphql | 2 +- 4 files changed, 29 insertions(+), 13 deletions(-) mode change 100755 => 100644 create_crt.sh diff --git a/create_crt.sh b/create_crt.sh old mode 100755 new mode 100644 index 6d0f4a28..0bd7c54e --- a/create_crt.sh +++ b/create_crt.sh @@ -1,12 +1,12 @@ -#!/bin/bash - -openssl req -newkey rsa:4096 \ - -x509 \ - -sha256 \ - -days 3650 \ - -nodes \ - -out discours.crt \ - -keyout discours.key \ - -subj "/C=RU/ST=Moscow/L=Moscow/O=Discours/OU=Site/CN=build.discours.io" - -openssl x509 -in discours.crt -out discours.pem -outform PEM +#!/bin/bash + +openssl req -newkey rsa:4096 \ + -x509 \ + -sha256 \ + -days 3650 \ + -nodes \ + -out discours.crt \ + -keyout discours.key \ + -subj "/C=RU/ST=Moscow/L=Moscow/O=Discours/OU=Site/CN=build.discours.io" + +openssl x509 -in discours.crt -out discours.pem -outform PEM diff --git a/requirements.txt b/requirements.txt index 474844e6..1a97e2d9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,3 +16,4 @@ transliterate requests bcrypt bs4 +websockets diff --git a/resolvers/topics.py b/resolvers/topics.py index 6b1aaea6..3bef55f7 100644 --- a/resolvers/topics.py +++ b/resolvers/topics.py @@ -45,3 +45,18 @@ async def topic_unsubscribe(_, info, slug): session.delete(sub) return {} # type Result return { "error": "session error" } + +@subscription.source("topicUpdated") +async def new_shout_generator(obj, info, user_id): + with local_session() as session: + topics = session.query(TopicSubscription.topic).filter(TopicSubscription.user == user_id).all() + #TODO filter new shouts + while True: + new_shout = {"slug": "slug", "body" : "body"} + yield new_shout + await asyncio.sleep(30) + print("end") + +@subscription.field("topicUpdated") +def shout_resolver(shout, info, user_id): + return shout diff --git a/schema.graphql b/schema.graphql index 7b1e3aae..26dec28b 100644 --- a/schema.graphql +++ b/schema.graphql @@ -129,7 +129,7 @@ type Subscription { onlineUpdated: [User!]! shoutUpdated: Shout! userUpdated: User! - topicUpdated: Shout! + topicUpdated(user_id: Int!): Shout! } ############################################ Entities