Keep context implementations with their document models

This commit is contained in:
2026-11-30 18:56:28 +08:00
parent 455a3580d6
commit 66b6910eb1
9 changed files with 110 additions and 106 deletions
+22
View File
@@ -1,3 +1,4 @@
use super::contextualize::Contextualize;
use super::{
id::{IdError, validate_id},
user::UserId,
@@ -40,3 +41,24 @@ pub struct OrganizationMembership {
pub user_id: UserId,
pub role: OrganizationRole,
}
impl Contextualize for Organization {
fn render_context(&self) -> String {
format!("Organization: {}", self.name)
}
}
impl Contextualize for OrganizationMembership {
fn render_context(&self) -> String {
let role = match self.role {
OrganizationRole::Owner => "owner",
OrganizationRole::Admin => "admin",
OrganizationRole::Member => "member",
};
format!(
"User {} is a {role} of organization {}",
self.user_id.as_str(),
self.organization_id.as_str()
)
}
}