Merge branch 'cudl' of github.com:Discours/discours-backend into cudl

This commit is contained in:
tonyrewin 2022-11-17 09:29:36 +03:00
commit 84b6ae0e61
3 changed files with 24 additions and 3 deletions

View File

@ -4,7 +4,8 @@ from datetime import datetime
from auth.authenticate import login_required
from base.redis import redis
from base.resolvers import mutation
from base.resolvers import mutation, query
from services.auth.users import UserStorage
async def add_user_to_chat(user_slug: str, chat_id: str, chat=None):
@ -121,3 +122,10 @@ async def delete_chat(_, info, chat_id: str):
return {
"error": "chat not exist"
}
@query.field("chatUsersAll")
@login_required
async def get_chat_users_all(_, info):
chat_users = await UserStorage.get_all_chat_users()
return chat_users

View File

@ -243,6 +243,7 @@ type Query {
loadChats( limit: Int, offset: Int): Result! # your chats
loadMessagesBy(by: MessagesBy!, limit: Int, offset: Int): Result!
searchUsers(query: String!, limit: Int, offset: Int): Result!
chatUsersAll: [ChatUser]!
# auth
isEmailUsed(email: String!): Boolean!
@ -348,6 +349,14 @@ type User {
oid: String
}
type ChatUser {
id: Int!
slug: String!
name: String!
userpic: String
lastSeen: DateTime
}
type Collab {
authors: [String]!
invites: [String]

View File

@ -1,7 +1,6 @@
import asyncio
from sqlalchemy.orm import selectinload
from base.orm import local_session
from orm.user import User
@ -34,6 +33,11 @@ class UserStorage:
aaa.sort(key=lambda user: user.createdAt)
return aaa
@staticmethod
async def get_all_chat_users():
with local_session() as session:
return session.query(User).where(User.emailConfirmed).all()
@staticmethod
async def get_top_users():
self = UserStorage