fix(collections): moving a place out of a list needs the same role as deleting it

Moving a saved place to another list takes it out of the source list, but
updatePlace only asked for edit rights there, so an editor could empty a
shared list they may not delete from. The source now takes owner or admin,
like a delete, and the target still takes edit rights. REST and the
update_collection_place tool share the service path. The Move to list
action on desktop and phone follows the delete permission.
This commit is contained in:
Maurice
2026-10-12 09:17:02 +02:00
parent 6c8321cd63
commit aa1bb41cf5
11 changed files with 172 additions and 7 deletions
@@ -477,6 +477,24 @@ describe('Tool: update_collection_place / set_collection_place_status / rate_col
expect(cleared.place.rating_count).toBe(0);
});
});
it('update_collection_place refuses an editor moving a place out of a shared list', async () => {
const { user: owner } = createUser(testDb);
const { user: editor } = createUser(testDb);
const shared = await seedCollection(owner.id, 'Shared');
await addMember(shared, editor.id, 'editor');
const own = await seedCollection(editor.id, 'Mine');
const pid = await seedPlace(shared, owner.id, 'Gate');
await withHarness(editor.id, async (h) => {
const res = await h.client.callTool({
name: 'update_collection_place',
arguments: { placeId: pid, collection_id: own },
});
expect(res.isError).toBe(true);
expect(errorText(res)).toBe('Only an admin can move places out of this list');
});
expect((await findRow(orm, CollectionPlaces, { id: pid }))?.collection_id).toBe(shared);
});
});
// ---------------------------------------------------------------------------