redis-multi-exec-fix

This commit is contained in:
2023-10-13 11:31:14 +03:00
parent 3b3dfd0f20
commit dbf3d1c745
2 changed files with 14 additions and 11 deletions

View File

@@ -51,6 +51,9 @@ async def create_chat(_, info, title="", members=None):
print("create_chat members: %r" % members)
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 == "":
@@ -86,7 +89,10 @@ async def create_chat(_, info, title="", members=None):
await redis.execute("SADD", f"chats_by_author/{m}", chat_id)
await redis.execute("SET", f"chats/{chat_id}", json.dumps(chat))
await redis.execute("SET", f"chats/{chat_id}/next_message_id", str(0))
await redis.execute("COMMIT")
response = await redis.execute('EXEC')
print(f"EXEC response: {response}")
return {"error": None, "chat": chat}