fix(library): dir=all = union de made+received (page partagée nominale visible dans Tous)
This commit is contained in:
@@ -224,12 +224,12 @@ async def library_shared(
|
|||||||
params: list = []
|
params: list = []
|
||||||
if dir in ("all", "made"):
|
if dir in ("all", "made"):
|
||||||
conds.append("p.share_mode != 'private'")
|
conds.append("p.share_mode != 'private'")
|
||||||
|
if dir in ("all", "made") and made_ids:
|
||||||
|
conds.append(f"p.id IN ({','.join('?' for _ in made_ids)})")
|
||||||
|
params.extend(made_ids)
|
||||||
if dir in ("all", "received") and recv_ids:
|
if dir in ("all", "received") and recv_ids:
|
||||||
conds.append(f"p.id IN ({','.join('?' for _ in recv_ids)})")
|
conds.append(f"p.id IN ({','.join('?' for _ in recv_ids)})")
|
||||||
params.extend(recv_ids)
|
params.extend(recv_ids)
|
||||||
if dir == "made" and made_ids:
|
|
||||||
conds.append(f"p.id IN ({','.join('?' for _ in made_ids)})")
|
|
||||||
params.extend(made_ids)
|
|
||||||
if dir == "received" and not recv_ids:
|
if dir == "received" and not recv_ids:
|
||||||
return {"items": []}
|
return {"items": []}
|
||||||
|
|
||||||
|
|||||||
@@ -259,6 +259,17 @@ def test_library_shared_dir_all_is_union(client):
|
|||||||
assert a in ids
|
assert a in ids
|
||||||
|
|
||||||
|
|
||||||
|
def test_library_shared_dir_all_includes_private_shared_made(client):
|
||||||
|
_auth(client, user_id=1, login="owner")
|
||||||
|
with get_conn_ctx() as conn:
|
||||||
|
a = _make_page_with(conn, "Private Shared A")
|
||||||
|
client.post(f"/api/pages/{a}/share", json={"user_id": 2, "permission": "comment"})
|
||||||
|
|
||||||
|
all_items = client.get("/api/library/shared").json()["items"]
|
||||||
|
ids = [it["id"] for it in all_items]
|
||||||
|
assert a in ids, "privately-shared page must appear in 'all' (union made+received)"
|
||||||
|
|
||||||
|
|
||||||
def test_library_shared_invalid_dir_falls_back_to_all(client):
|
def test_library_shared_invalid_dir_falls_back_to_all(client):
|
||||||
_auth(client, user_id=1, login="owner")
|
_auth(client, user_id=1, login="owner")
|
||||||
with get_conn_ctx() as conn:
|
with get_conn_ctx() as conn:
|
||||||
|
|||||||
Reference in New Issue
Block a user