This commit is contained in:
parent
12c5d2677d
commit
c96e8afc45
|
@ -66,8 +66,11 @@ async def create_chat(_, info, title="", members=None):
|
||||||
if len(members) == 2 and title == "":
|
if len(members) == 2 and title == "":
|
||||||
chatset1 = await redis.execute("SMEMBERS", f"chats_by_author/{members[0]}")
|
chatset1 = await redis.execute("SMEMBERS", f"chats_by_author/{members[0]}")
|
||||||
chatset2 = await redis.execute("SMEMBERS", f"chats_by_author/{members[1]}")
|
chatset2 = await redis.execute("SMEMBERS", f"chats_by_author/{members[1]}")
|
||||||
|
if isinstance(chatset1, set) and isinstance(chatset2, set):
|
||||||
for c in chatset1.intersection(chatset2):
|
for c in chatset1.intersection(chatset2):
|
||||||
chat = await redis.execute("GET", f"chats/{c}")
|
chat_result = await redis.execute("GET", f"chats/{c}")
|
||||||
|
if chat_result:
|
||||||
|
chat = json.loads(chat_result)
|
||||||
if chat["title"] == "":
|
if chat["title"] == "":
|
||||||
logger.info("[inbox] createChat found old chat")
|
logger.info("[inbox] createChat found old chat")
|
||||||
return {"chat": chat, "error": "existed"}
|
return {"chat": chat, "error": "existed"}
|
||||||
|
|
|
@ -88,10 +88,9 @@ async def load_chats(
|
||||||
lock = asyncio.Lock()
|
lock = asyncio.Lock()
|
||||||
if len(cids) == 0:
|
if len(cids) == 0:
|
||||||
logger.debug(f"no chats for user with id={author_id}")
|
logger.debug(f"no chats for user with id={author_id}")
|
||||||
r = await create_chat(
|
r = await create_chat(None, info, members=[2]) # member with id = 2 is discours
|
||||||
None, info, members=[2]
|
if isinstance(r, dict) and "chat" in r:
|
||||||
) # member with id = 2 is discours
|
logger.debug(f"created chat: {r['chat']['id']}")
|
||||||
logger.debug(f"created chat: {r['chat_id']}")
|
|
||||||
cids.append(r["chat"]["id"])
|
cids.append(r["chat"]["id"])
|
||||||
|
|
||||||
logger.debug(f"getting data for {len(cids)} user's chats")
|
logger.debug(f"getting data for {len(cids)} user's chats")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user