Skip to main content

media_tools/models/
media_profile.rs

1//! A personal or family-managed person profile used for media preferences and activity.
2use agent_storage::{FamilyId, UserId};
3use serde::{Deserialize, Serialize};
4
5use super::MediaProfileId;
6
7/// A media profile belongs either to an EME user or to a family.
8///
9/// Personal profiles have an owner and no family. Family profiles retain the
10/// existing optional EME-user assignment for family-managed households.
11#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
12pub struct MediaProfile {
13    pub id: MediaProfileId,
14    #[serde(default)]
15    pub family_id: Option<FamilyId>,
16    #[serde(default)]
17    pub owner_id: Option<UserId>,
18    pub name: String,
19    pub user_id: Option<UserId>,
20    pub active: bool,
21}
22
23impl MediaProfile {
24    pub fn new(family_id: FamilyId, name: impl Into<String>) -> Self {
25        Self {
26            id: MediaProfileId::new(),
27            family_id: Some(family_id),
28            owner_id: None,
29            name: name.into(),
30            user_id: None,
31            active: true,
32        }
33    }
34
35    /// Create a private profile owned directly by an EME user, without a family.
36    pub fn new_personal(owner_id: UserId, name: impl Into<String>) -> Self {
37        Self {
38            id: MediaProfileId::new(),
39            family_id: None,
40            owner_id: Some(owner_id),
41            name: name.into(),
42            user_id: None,
43            active: true,
44        }
45    }
46}