fix: add preview to delete response for MCP server compatibility
This commit is contained in:
parent
3207ecf3e9
commit
58ea218044
2 changed files with 6 additions and 4 deletions
|
|
@ -200,7 +200,7 @@ async def delete_memory(memory_id: int, user: AuthUser = Depends(get_current_use
|
||||||
|
|
||||||
async with pool.acquire() as conn:
|
async with pool.acquire() as conn:
|
||||||
row = await conn.fetchrow(
|
row = await conn.fetchrow(
|
||||||
"SELECT id, vault_path FROM memories WHERE id = $1 AND user_id = $2",
|
"SELECT id, vault_path, substr(content, 1, 50) AS preview FROM memories WHERE id = $1 AND user_id = $2",
|
||||||
memory_id,
|
memory_id,
|
||||||
user.user_id,
|
user.user_id,
|
||||||
)
|
)
|
||||||
|
|
@ -216,7 +216,7 @@ async def delete_memory(memory_id: int, user: AuthUser = Depends(get_current_use
|
||||||
user.user_id,
|
user.user_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
return {"deleted": memory_id}
|
return {"deleted": memory_id, "preview": row["preview"]}
|
||||||
|
|
||||||
|
|
||||||
@app.post("/api/memories/{memory_id}/secret", response_model=SecretResponse)
|
@app.post("/api/memories/{memory_id}/secret", response_model=SecretResponse)
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,7 @@ async def test_list_returns_only_user_memories(client):
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_delete_only_user_memories(client):
|
async def test_delete_only_user_memories(client):
|
||||||
ac, conn, app_mod = client
|
ac, conn, app_mod = client
|
||||||
conn.fetchrow.return_value = _make_memory_row(id=10, vault_path=None)
|
conn.fetchrow.return_value = _make_memory_row(id=10, vault_path=None, preview="test content")
|
||||||
conn.execute.return_value = None
|
conn.execute.return_value = None
|
||||||
|
|
||||||
async with ac:
|
async with ac:
|
||||||
|
|
@ -204,7 +204,9 @@ async def test_delete_only_user_memories(client):
|
||||||
)
|
)
|
||||||
|
|
||||||
assert resp.status_code == 200
|
assert resp.status_code == 200
|
||||||
assert resp.json() == {"deleted": 10}
|
data = resp.json()
|
||||||
|
assert data["deleted"] == 10
|
||||||
|
assert "preview" in data
|
||||||
|
|
||||||
# Verify both SELECT and DELETE include user_id
|
# Verify both SELECT and DELETE include user_id
|
||||||
fetchrow_args = conn.fetchrow.call_args
|
fetchrow_args = conn.fetchrow.call_args
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue