This commit is contained in:
parent
6a450a84c1
commit
41af1a7349
|
@ -1,11 +1,7 @@
|
|||
from resolvers.chats import create_chat, delete_chat, update_chat
|
||||
from resolvers.load import load_chats, load_messages_by
|
||||
from resolvers.messages import (
|
||||
create_message,
|
||||
delete_message,
|
||||
mark_as_read,
|
||||
update_message,
|
||||
)
|
||||
from resolvers.messages import (create_message, delete_message, mark_as_read,
|
||||
update_message)
|
||||
from resolvers.search import search_messages, search_recipients
|
||||
|
||||
__all__ = [
|
||||
|
|
|
@ -88,9 +88,15 @@ async def load_chats(
|
|||
lock = asyncio.Lock()
|
||||
if len(cids) == 0:
|
||||
logger.debug(f"no chats for user with id={author_id}")
|
||||
r = await create_chat(None, info, members=[2]) # member with id = 2 is discours
|
||||
if isinstance(r, dict) and "chat" in r and isinstance(r['chat'], dict):
|
||||
chat_id = r['chat'].get('id')
|
||||
r = await create_chat(
|
||||
None, info, members=[2]
|
||||
) # member with id = 2 is discours
|
||||
if (
|
||||
isinstance(r, dict)
|
||||
and "chat" in r
|
||||
and isinstance(r["chat"], dict)
|
||||
):
|
||||
chat_id = r["chat"].get("id")
|
||||
if chat_id:
|
||||
logger.debug(f"created chat: {chat_id}")
|
||||
cids.append(chat_id)
|
||||
|
|
|
@ -60,7 +60,7 @@ def login_required(f):
|
|||
info = args[1]
|
||||
context = info.context
|
||||
req = context.get("request")
|
||||
user_id, user_roles = await check_auth(req)
|
||||
user_id, user_roles = await check_auth(req)
|
||||
if user_id and isinstance(user_id, str):
|
||||
context["user_id"] = user_id.strip()
|
||||
author = await get_author_by_user(user_id)
|
||||
|
@ -77,7 +77,7 @@ def auth_request(f):
|
|||
@wraps(f)
|
||||
async def decorated_function(*args, **kwargs):
|
||||
req = args[0]
|
||||
user_id, user_roles = await check_auth(req)
|
||||
user_id, user_roles = await check_auth(req)
|
||||
if user_id and isinstance(user_id, str):
|
||||
user_id = user_id.strip()
|
||||
author = await get_author_by_user(user_id)
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
import json
|
||||
|
||||
from services.logger import root_logger as logger
|
||||
from services.rediscache import redis
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import json
|
||||
|
||||
from services.logger import root_logger as logger
|
||||
|
||||
from models.chat import ChatUpdate, Message
|
||||
from services.logger import root_logger as logger
|
||||
from services.rediscache import redis
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user