Model workspace invitation policies and document ownership

This commit is contained in:
2026-12-02 15:39:26 +08:00
parent 83a30fad4a
commit 0a74ef159b
4 changed files with 377 additions and 4 deletions
+15
View File
@@ -2,6 +2,7 @@ use super::contextualize::Contextualize;
use super::{
id::{IdError, validate_id},
user::UserId,
workspace::{Workspace, WorkspaceAccess, WorkspaceAccessError, WorkspaceId},
};
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
@@ -42,6 +43,20 @@ pub struct OrganizationMembership {
pub role: OrganizationRole,
}
impl Organization {
pub fn create_workspace(&self, id: WorkspaceId, name: impl Into<String>) -> Workspace {
Workspace::owned_by(id, name, self.id.clone())
}
pub fn set_workspace_access(
&self,
workspace: &mut Workspace,
access: WorkspaceAccess,
) -> Result<(), WorkspaceAccessError> {
workspace.set_organization_access(&self.id, access)
}
}
impl Contextualize for Organization {
fn render_context(&self) -> String {
format!("Organization: {}", self.name)