Spaces:
Runtime error
Runtime error
Commit
·
4e001e2
1
Parent(s):
05debeb
fix
Browse files- routers/chat.py +2 -2
- utils/utils.py +1 -1
routers/chat.py
CHANGED
@@ -125,7 +125,7 @@ async def delete_chat(chat_id: str, request: Request, user: UserOut = Depends(ge
|
|
125 |
|
126 |
meta_key = f"conversation_meta:{chat_id}"
|
127 |
# Kiểm tra quyền trước khi xóa
|
128 |
-
user_in_chat =
|
129 |
if user_in_chat is None:
|
130 |
raise HTTPException(status_code=404, detail="Chat not found")
|
131 |
|
@@ -133,7 +133,7 @@ async def delete_chat(chat_id: str, request: Request, user: UserOut = Depends(ge
|
|
133 |
raise HTTPException(status_code=403, detail="Unauthorized")
|
134 |
|
135 |
# Xóa chat
|
136 |
-
delete_chat_from_redis(redis, chat_id)
|
137 |
# Xóa hội thoại trong MongoDB
|
138 |
result =await mongo_db.conversations.delete_one({"conversation_id": chat_id, "user_id": user.email})
|
139 |
if result.deleted_count == 0:
|
|
|
125 |
|
126 |
meta_key = f"conversation_meta:{chat_id}"
|
127 |
# Kiểm tra quyền trước khi xóa
|
128 |
+
user_in_chat = await redis.hget(meta_key, "user_id")
|
129 |
if user_in_chat is None:
|
130 |
raise HTTPException(status_code=404, detail="Chat not found")
|
131 |
|
|
|
133 |
raise HTTPException(status_code=403, detail="Unauthorized")
|
134 |
|
135 |
# Xóa chat
|
136 |
+
await delete_chat_from_redis(redis, chat_id)
|
137 |
# Xóa hội thoại trong MongoDB
|
138 |
result =await mongo_db.conversations.delete_one({"conversation_id": chat_id, "user_id": user.email})
|
139 |
if result.deleted_count == 0:
|
utils/utils.py
CHANGED
@@ -176,7 +176,7 @@ async def delete_chat_from_redis(r: Redis, chat_id: str) -> bool:
|
|
176 |
|
177 |
try:
|
178 |
# Kiểm tra kết nối Redis
|
179 |
-
r.ping()
|
180 |
|
181 |
# Kiểm tra sự tồn tại của các key
|
182 |
keys_to_delete = []
|
|
|
176 |
|
177 |
try:
|
178 |
# Kiểm tra kết nối Redis
|
179 |
+
await r.ping()
|
180 |
|
181 |
# Kiểm tra sự tồn tại của các key
|
182 |
keys_to_delete = []
|