get all chat users
This commit is contained in:
parent
5704b08d12
commit
3a8f630c6d
|
@ -4,7 +4,8 @@ from datetime import datetime
|
||||||
|
|
||||||
from auth.authenticate import login_required
|
from auth.authenticate import login_required
|
||||||
from base.redis import redis
|
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):
|
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 {
|
return {
|
||||||
"error": "chat not exist"
|
"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
|
||||||
|
|
|
@ -243,6 +243,7 @@ type Query {
|
||||||
loadChats( limit: Int, offset: Int): Result! # your chats
|
loadChats( limit: Int, offset: Int): Result! # your chats
|
||||||
loadMessagesBy(by: MessagesBy!, limit: Int, offset: Int): Result!
|
loadMessagesBy(by: MessagesBy!, limit: Int, offset: Int): Result!
|
||||||
searchUsers(query: String!, limit: Int, offset: Int): Result!
|
searchUsers(query: String!, limit: Int, offset: Int): Result!
|
||||||
|
chatUsersAll: [ChatUser]!
|
||||||
|
|
||||||
# auth
|
# auth
|
||||||
isEmailUsed(email: String!): Boolean!
|
isEmailUsed(email: String!): Boolean!
|
||||||
|
@ -348,6 +349,14 @@ type User {
|
||||||
oid: String
|
oid: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ChatUser {
|
||||||
|
id: Int!
|
||||||
|
slug: String!
|
||||||
|
name: String!
|
||||||
|
userpic: String
|
||||||
|
lastSeen: DateTime
|
||||||
|
}
|
||||||
|
|
||||||
type Collab {
|
type Collab {
|
||||||
authors: [String]!
|
authors: [String]!
|
||||||
invites: [String]
|
invites: [String]
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from sqlalchemy.orm import selectinload
|
from sqlalchemy.orm import selectinload
|
||||||
|
from base.orm import local_session
|
||||||
from orm.user import User
|
from orm.user import User
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,6 +33,11 @@ class UserStorage:
|
||||||
aaa.sort(key=lambda user: user.createdAt)
|
aaa.sort(key=lambda user: user.createdAt)
|
||||||
return aaa
|
return aaa
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
async def get_all_chat_users():
|
||||||
|
with local_session() as session:
|
||||||
|
return session.query(User).where(User.emailConfirmed).all()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def get_top_users():
|
async def get_top_users():
|
||||||
self = UserStorage
|
self = UserStorage
|
||||||
|
|
Loading…
Reference in New Issue
Block a user