use uuid::Uuid; use crate::errors::ChatError; use crate::services::service::ChatService; impl ChatService { /// 房间订阅/投递鉴权:读权限走 `is_room_member`(dir 覆盖项 + DM 回退), /// 管理动作走 space 能力内核,规则仍只有一份。 pub async fn authorize_internal_room( &self, user_id: i64, room_id: Uuid, action: &str, ) -> Result { match action { "MANAGE" => { let context = crate::share::lookup::lookup_room_context(self, room_id).await?; match context.space.as_ref() { Some(space) => { crate::share::authz::can_manage_space(self, space, user_id).await } None => Ok(false), } } _ => match crate::share::lookup::is_room_member(self, room_id, user_id).await { Ok(visible) => Ok(visible), Err(ChatError::NotFound) => Ok(false), Err(error) => Err(error), }, } } }