redis-set-result-fix-2
This commit is contained in:
parent
723a0a2818
commit
e75b37e177
|
@ -52,8 +52,6 @@ async def create_chat(_, info, title="", members=None):
|
|||
if author_id not in members:
|
||||
members.append(int(author_id))
|
||||
|
||||
await redis.execute('MULTI')
|
||||
|
||||
# NOTE: private chats has no title
|
||||
# reuse private chat created before if exists
|
||||
if len(members) == 2 and title == "":
|
||||
|
@ -90,9 +88,6 @@ async def create_chat(_, info, title="", members=None):
|
|||
await redis.execute("SET", f"chats/{chat_id}", json.dumps(chat))
|
||||
await redis.execute("SET", f"chats/{chat_id}/next_message_id", str(0))
|
||||
|
||||
response = await redis.execute('EXEC')
|
||||
print(f"EXEC response: {response}")
|
||||
|
||||
return {"error": None, "chat": chat}
|
||||
|
||||
|
||||
|
|
|
@ -45,16 +45,15 @@ async def load_chats(_, info, limit: int = 50, offset: int = 0):
|
|||
"""load :limit chats of current user with :offset"""
|
||||
author_id = info.context["author_id"]
|
||||
print(f"Loading chats for user with id={author_id}")
|
||||
await redis.execute('MULTI')
|
||||
cids = (await redis.execute("SMEMBERS", f"chats_by_author/{author_id}")) or []
|
||||
members_online = (await redis.execute("SMEMBERS", "authors-online")) or []
|
||||
await redis.execute('EXEC')
|
||||
cids = list(cids)[offset:(offset + limit)]
|
||||
chats = []
|
||||
lock = asyncio.Lock()
|
||||
if len(cids) == 0:
|
||||
print(f"[resolvers.load] no chats for user with id={author_id}, create one with Discours (id=2)")
|
||||
r = await create_chat(None, info, members=[2]) # member with id = 2 is discours
|
||||
print(f"{r}")
|
||||
cids.append(r["chat"]["id"])
|
||||
for cid in cids:
|
||||
print(f"Processing chat ID: {cid}")
|
||||
|
|
Loading…
Reference in New Issue
Block a user