From b62211e05fc9c61ba81d0dfa2c111f1fce72f266 Mon Sep 17 00:00:00 2001 From: tonyrewin Date: Wed, 9 Nov 2022 14:46:00 +0300 Subject: [PATCH] schema-inbox-fix --- migration/tables/comments.py | 7 ++++--- orm/reaction.py | 5 ++--- resolvers/inbox.py | 14 +++++++------- schema.graphql | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/migration/tables/comments.py b/migration/tables/comments.py index b7c79bc0..567259b3 100644 --- a/migration/tables/comments.py +++ b/migration/tables/comments.py @@ -4,11 +4,12 @@ from dateutil.parser import parse as date_parse from base.orm import local_session from migration.html2text import html2text -from orm.user import User -from orm.topic import TopicFollower from orm.reaction import Reaction, ReactionKind -from services.stat.reacted import ReactedStorage from orm.shout import ShoutReactionsFollower +from orm.topic import TopicFollower +from orm.user import User +from services.stat.reacted import ReactedStorage + ts = datetime.now() diff --git a/orm/reaction.py b/orm/reaction.py index 2fdf900a..123cfb22 100644 --- a/orm/reaction.py +++ b/orm/reaction.py @@ -1,9 +1,8 @@ from datetime import datetime - -from sqlalchemy import Column, String, ForeignKey, DateTime -from sqlalchemy import Enum from enum import Enum as Enumeration +from sqlalchemy import Column, DateTime, Enum, ForeignKey, String + from base.orm import Base diff --git a/resolvers/inbox.py b/resolvers/inbox.py index 64063d54..21c874be 100644 --- a/resolvers/inbox.py +++ b/resolvers/inbox.py @@ -1,12 +1,12 @@ +import asyncio import json import uuid -import asyncio from datetime import datetime from auth.authenticate import login_required from base.redis import redis from base.resolvers import mutation, query, subscription -from services.inbox import MessageResult, MessagesStorage, ChatFollowing +from services.inbox import ChatFollowing, MessageResult, MessagesStorage async def get_unread_counter(chat_id: str, user_slug: str): @@ -46,6 +46,11 @@ async def add_user_to_chat(user_slug: str, chat): return chat +async def get_chats_by_user(slug: str): + chats = await redis.execute("GET", f"chats_by_user/{slug}") + return chats or [] + + @mutation.field("inviteChat") async def invite_to_chat(_, info, invited: str, chat_id: str): user = info.context["request"].user @@ -124,11 +129,6 @@ async def load_messages(chatId: str, offset: int, amount: int): } -async def get_chats_by_user(slug: str): - chats = await redis.execute("GET", f"chats_by_user/{slug}") - return chats or [] - - @query.field("myChats") @login_required async def user_chats(_, info): diff --git a/schema.graphql b/schema.graphql index a4a42f2b..5dbee921 100644 --- a/schema.graphql +++ b/schema.graphql @@ -138,7 +138,7 @@ type Mutation { updateChat(chat: ChatInput!): Result! inviteChat(chatId: String!, userslug: String!): Result! enterChat(chatId: String!): Result! - createMessage(chatId: String!, body: String!, replyTo: Int): Result! + createMessage(chatId: String!, body: String!, replyTo: String): Result! updateMessage(chatId: String!, id: Int!, body: String!): Result! deleteMessage(chatId: String!, id: Int!): Result! markAsRead(chatId: String!, ids: [Int]!): Result! @@ -482,7 +482,7 @@ type Message { body: String! createdAt: Int! id: Int! - replyTo: Int + replyTo: String updatedAt: Int }