Repository navigation
feat(cases): add role-filtered case place listing - #140
Conversation
- expose GET /api/cases/{case_id}/places for case members
- filter places by viewer role, review status, visibility, and ownership
- return 404 for users who are not case members
- document the endpoint in API and OpenAPI specifications
- add authentication, visibility, and OpenAPI contract coverage
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough新增案件地点列表 GET 接口,按案件角色、地点可见性和审核状态裁剪返回数据,并补充路由、OpenAPI 文档、认证测试及集成测试。 Changes案件地点列表
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant list_places
participant case_service
participant case_resource_service
Client->>list_places: GET /api/cases/{case_id}/places
list_places->>case_service: 校验案件角色
case_service-->>list_places: 返回授权结果
list_places->>case_resource_service: 查询可见地点
case_resource_service-->>list_places: 返回角色裁剪后的地点
list_places-->>Client: 200 JSON CasePlace[]
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/application/services/case_resource_service.rs (1)
227-229: 🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift按任务分配收窄志愿者地点查询。
当前查询只限制为
public和confirmed,没有任何任务分配条件;因此任意案件志愿者都能读取案件全部已确认公开地点,违反“志愿者仅见其已分配任务所需地点”的服务端访问控制目标。
src/application/services/case_resource_service.rs#L227-L229: 为志愿者查询加入与当前用户任务分配关联的服务端过滤条件。docs/openapi.yaml#L789-L789: 将志愿者可见范围改为仅限其已分配任务所需地点。docs/API.md#L195-L195: 同步修正志愿者可见性说明。tests/api/case_resources_post.rs#L194-L199: 创建已分配与未分配的地点夹具,并断言志愿者只能读取前者。As per path instructions,
src/**必须审查认证、授权和隐私风险。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/application/services/case_resource_service.rs` around lines 227 - 229, 收窄 CaseRole::Volunteer 的查询:在现有 public 和 confirmed 条件之外,加入基于当前认证用户任务分配关联的服务端授权过滤,仅返回其已分配任务所需的地点。同步更新 docs/openapi.yaml:789-789 和 docs/API.md:195-195 的志愿者可见范围说明;在 tests/api/case_resources_post.rs:194-199 创建已分配及未分配地点夹具,并断言志愿者只能读取已分配地点。Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/api/case_resources_post.rs`:
- Around line 110-159: 在现有夹具初始化和家属查询断言中,新增一个 visibility 为 confirmed、已审核且非内部的
place,并通过 mark_place_confirmed 标记;补充断言家属可见该记录,同时保留 public、unreviewed 和 internal
记录的正向/负向断言,确保覆盖 confirmed 与 public 的可见性边界。
---
Outside diff comments:
In `@src/application/services/case_resource_service.rs`:
- Around line 227-229: 收窄 CaseRole::Volunteer 的查询:在现有 public 和 confirmed
条件之外,加入基于当前认证用户任务分配关联的服务端授权过滤,仅返回其已分配任务所需的地点。同步更新 docs/openapi.yaml:789-789 和
docs/API.md:195-195 的志愿者可见范围说明;在 tests/api/case_resources_post.rs:194-199
创建已分配及未分配地点夹具,并断言志愿者只能读取已分配地点。
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: bbfe3054-b26f-4a41-a796-83bb59180d89
📒 Files selected for processing (7)
docs/API.mddocs/openapi.yamlsrc/api/routes/cases.rssrc/application/services/case_resource_service.rstests/api/authentication_guards.rstests/api/case_resources_post.rstests/api/openapi_intake_contract.rs
- add a confirmed non-public place fixture - verify family members can view confirmed places - update commander place count assertion
Close #27
Summary by CodeRabbit
/api/cases/{case_id}/places)。