Keep context implementations with their document models
This commit is contained in:
@@ -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()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user