schema-inbox-fix

This commit is contained in:
tonyrewin 2022-11-09 14:46:00 +03:00
parent 5bf3621724
commit b62211e05f
4 changed files with 15 additions and 15 deletions

View File

@ -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()

View File

@ -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

View File

@ -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):

View File

@ -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
}