mirror of
https://github.com/open-webui/open-webui
synced 2025-05-16 19:43:42 +00:00
refac
This commit is contained in:
parent
6862d8fba8
commit
bdef1001ac
@ -63,14 +63,15 @@ class MemoriesTable:
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def update_memory_by_id(
|
def update_memory_by_id_and_user_id(
|
||||||
self,
|
self,
|
||||||
id: str,
|
id: str,
|
||||||
|
user_id: str,
|
||||||
content: str,
|
content: str,
|
||||||
) -> Optional[MemoryModel]:
|
) -> Optional[MemoryModel]:
|
||||||
with get_db() as db:
|
with get_db() as db:
|
||||||
try:
|
try:
|
||||||
db.query(Memory).filter_by(id=id).update(
|
db.query(Memory).filter_by(id=id, user_id=user_id).update(
|
||||||
{"content": content, "updated_at": int(time.time())}
|
{"content": content, "updated_at": int(time.time())}
|
||||||
)
|
)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
@ -153,7 +153,9 @@ async def update_memory_by_id(
|
|||||||
form_data: MemoryUpdateModel,
|
form_data: MemoryUpdateModel,
|
||||||
user=Depends(get_verified_user),
|
user=Depends(get_verified_user),
|
||||||
):
|
):
|
||||||
memory = Memories.update_memory_by_id(memory_id, form_data.content)
|
memory = Memories.update_memory_by_id_and_user_id(
|
||||||
|
memory_id, user.id, form_data.content
|
||||||
|
)
|
||||||
if memory is None:
|
if memory is None:
|
||||||
raise HTTPException(status_code=404, detail="Memory not found")
|
raise HTTPException(status_code=404, detail="Memory not found")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user