GdprRepository

Trait GdprRepository 

Source
pub trait GdprRepository: Send + Sync {
    // Required methods
    fn aggregate_user_data<'life0, 'async_trait>(
        &'life0 self,
        user_id: Uuid,
        organization_id: Option<Uuid>,
    ) -> Pin<Box<dyn Future<Output = Result<GdprExport, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn anonymize_user<'life0, 'async_trait>(
        &'life0 self,
        user_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn anonymize_owner<'life0, 'async_trait>(
        &'life0 self,
        owner_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn find_owner_ids_by_user<'life0, 'async_trait>(
        &'life0 self,
        user_id: Uuid,
        organization_id: Option<Uuid>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Uuid>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn check_legal_holds<'life0, 'async_trait>(
        &'life0 self,
        user_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn is_user_anonymized<'life0, 'async_trait>(
        &'life0 self,
        user_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<bool, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

GDPR Repository port for data export and anonymization operations Implements GDPR Article 15 (Right to Access) and Article 17 (Right to Erasure)

Required Methods§

Source

fn aggregate_user_data<'life0, 'async_trait>( &'life0 self, user_id: Uuid, organization_id: Option<Uuid>, ) -> Pin<Box<dyn Future<Output = Result<GdprExport, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Aggregate all personal data for a user (GDPR Article 15)

Collects data from:

  • Users table
  • Owners table
  • Unit ownership relationships
  • Expenses
  • Documents
  • Meetings attendance
§Arguments
  • user_id - UUID of the user requesting data export
  • organization_id - Optional organization scope (None for SuperAdmin)
§Returns
  • Ok(GdprExport) - Complete data export
  • Err(String) - If user not found or database error
Source

fn anonymize_user<'life0, 'async_trait>( &'life0 self, user_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Anonymize user account (GDPR Article 17)

Replaces personal identifiable information with anonymized placeholders:

  • email → anonymized-{uuid}@deleted.local
  • first_name → “Anonymized”
  • last_name → “User”
  • Sets is_anonymized = true
  • Sets anonymized_at = NOW()
§Arguments
  • user_id - UUID of the user to anonymize
§Returns
  • Ok(()) - Anonymization successful
  • Err(String) - If user not found, already anonymized, or database error
Source

fn anonymize_owner<'life0, 'async_trait>( &'life0 self, owner_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Anonymize owner profile (GDPR Article 17)

Replaces personal identifiable information:

  • email → None
  • phone → None
  • address, city, postal_code, country → None
  • first_name → “Anonymized”
  • last_name → “User”
  • Sets is_anonymized = true
  • Sets anonymized_at = NOW()
§Arguments
  • owner_id - UUID of the owner to anonymize
§Returns
  • Ok(()) - Anonymization successful
  • Err(String) - If owner not found, already anonymized, or database error
Source

fn find_owner_ids_by_user<'life0, 'async_trait>( &'life0 self, user_id: Uuid, organization_id: Option<Uuid>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Uuid>, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Find all owner IDs linked to a user

Used to identify which owner profiles need anonymization when a user requests erasure.

§Arguments
  • user_id - UUID of the user
  • organization_id - Optional organization scope
§Returns
  • Ok(Vec<Uuid>) - List of owner UUIDs
  • Err(String) - Database error

Check if user has legal holds preventing deletion

Verifies if user has outstanding financial obligations or legal requirements that prevent complete anonymization (e.g., unpaid expenses, ongoing legal proceedings).

§Arguments
  • user_id - UUID of the user
§Returns
  • Ok(Vec<String>) - List of hold reasons (empty if no holds)
  • Err(String) - Database error
Source

fn is_user_anonymized<'life0, 'async_trait>( &'life0 self, user_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<bool, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if user is already anonymized

§Arguments
  • user_id - UUID of the user
§Returns
  • Ok(true) - User is anonymized
  • Ok(false) - User is not anonymized
  • Err(String) - User not found or database error

Implementors§