Skip to content
Clone

feat(space,repo,issues): unify membership error messages and finalize stage 6 (assembly cleanup)

zhenyi committed
parent e07f696 commit 64fca87 Browse files

6 files changed

+25 −13

File tree 6
Modified lib/issues/features/authz.rs View lib/issues/features/authz.rs
@@ -3,6 +3,7 @@
33use db::channel::channels as channel_entity;
44use db::conn::sea_orm::*;
55use db::space::space_members as member_entity;
6use db::space::spaces as space_entity;
67use db::user::users as user_entity;
78use uuid::Uuid;
89
@@ -68,8 +69,13 @@
6869 if is_active_member(&db, space_id, actor).await? {
6970 return Ok(());
7071 }
72 let space_name = space_entity::Entity::find_by_id(space_id)
73 .one(&db)
74 .await?
75 .map(|s| s.lower_name)
76 .unwrap_or_else(|| space_id.to_string());
7177 return Err(IssueError::Forbidden(format!(
72 "caller is not an active member of space {space_id}"
78 "not a member of space {space_name}"
7379 )));
7480 }
7581
Modified lib/repo/features/authz.rs View lib/repo/features/authz.rs
@@ -113,9 +113,10 @@
113113 .ok_or_else(|| RepoError::NotFound(format!("space {space_id}")))?;
114114 match permission::space_role_for(&db, &space, actor_id).await? {
115115 Some(_) => Ok(()),
116 None => Err(RepoError::Forbidden(
117 "not a member of the channel's space".into(),
118 )),
116 None => Err(RepoError::Forbidden(format!(
117 "not a member of space {}",
118 space.lower_name
119 ))),
119120 }
120121}
121122
Modified lib/space/features/channels/usecase.rs View lib/space/features/channels/usecase.rs
@@ -28,9 +28,10 @@
2828 .map(|m| m.status == member_entity::MemberStatus::Active)
2929 .unwrap_or(false);
3030 if !active {
31 return Err(SpaceError::Forbidden(
32 "caller is not an active member of this space".to_string(),
33 ));
31 return Err(SpaceError::Forbidden(format!(
32 "not a member of space {}",
33 space.lower_name
34 )));
3435 }
3536 Ok(space)
3637}
Modified lib/space/features/overwrites/usecase.rs View lib/space/features/overwrites/usecase.rs
@@ -32,9 +32,10 @@
3232 .map(|m| m.status == space_member_entity::MemberStatus::Active)
3333 .unwrap_or(false);
3434 if !active {
35 return Err(SpaceError::Forbidden(
36 "caller is not an active member of this space".to_string(),
37 ));
35 return Err(SpaceError::Forbidden(format!(
36 "not a member of space {}",
37 space.lower_name
38 )));
3839 }
3940 Ok(space)
4041}
Modified lib/space/features/authz.rs View lib/space/features/authz.rs
@@ -88,9 +88,10 @@
8888 .map(|m| m.status == member_entity::MemberStatus::Active)
8989 .unwrap_or(false);
9090 if !active {
91 return Err(SpaceError::Forbidden(
92 "caller is not an active member of this space".to_string(),
93 ));
91 return Err(SpaceError::Forbidden(format!(
92 "not a member of space {}",
93 space.lower_name
94 )));
9495 }
9596
9697 let role_rows = member_role_entity::Entity::find()
Modified wiki/refactor-channel-to-space.md View wiki/refactor-channel-to-space.md
@@ -433,6 +433,8 @@
433433- 全局 grep `openapi.json`:不出现 `channel_id`(除 schema 字段)
434434- 更新 README / wiki
435435
436- [x] 阶段 6 完成(2026-08-09):顶层装配无 channel_id 引用无需改动;错误消息统一为 "forbidden: not a member of space {name}"(lib/space authz+channels+overwrites、lib/repo authz、lib/issues authz 共 5 处,均保持 Forbidden 变体);openapi.json 60 处 channel_id 全部为 schema 字段(无 path 参数、无 operationId);仓库无 README,本 wiki 加完成标注
437
436438### 阶段 7:(可选,远期)schema 双键 migration
437439
438440> 不在本路线图强制执行。**注意**:迁移目标**不是删除 channel_id**,而是**加上 space_id 形成双键**——channel_id 是资源在 space 内的物理位置,必须保留。