Files
Oxicloud/src/domain/repositories/calendar_repository.rs
T

103 lines
3.1 KiB
Rust
Raw Normal View History

2025-04-13 01:04:04 +02:00
use crate::common::errors::DomainError;
use crate::domain::entities::calendar::Calendar;
2026-02-14 01:29:34 +01:00
use uuid::Uuid;
2025-04-13 01:04:04 +02:00
pub type CalendarRepositoryResult<T> = Result<T, DomainError>;
/// Repository interface for Calendar entity operations
pub trait CalendarRepository: Send + Sync + 'static {
/// Creates a new calendar
async fn create_calendar(&self, calendar: Calendar) -> CalendarRepositoryResult<Calendar>;
2026-02-14 01:29:34 +01:00
2025-04-13 01:04:04 +02:00
/// Updates an existing calendar
async fn update_calendar(&self, calendar: Calendar) -> CalendarRepositoryResult<Calendar>;
2026-02-14 01:29:34 +01:00
2025-04-13 01:04:04 +02:00
/// Deletes a calendar by ID
async fn delete_calendar(&self, id: &Uuid) -> CalendarRepositoryResult<()>;
2026-02-14 01:29:34 +01:00
2025-04-13 01:04:04 +02:00
/// Finds a calendar by its ID
async fn find_calendar_by_id(&self, id: &Uuid) -> CalendarRepositoryResult<Calendar>;
2026-02-14 01:29:34 +01:00
2025-04-13 01:04:04 +02:00
/// Lists all calendars for a specific user
2026-02-14 01:29:34 +01:00
async fn list_calendars_by_owner(
&self,
owner_id: Uuid,
2026-02-14 01:29:34 +01:00
) -> CalendarRepositoryResult<Vec<Calendar>>;
2025-04-13 01:04:04 +02:00
/// Finds a calendar by name and owner
2026-02-14 01:29:34 +01:00
async fn find_calendar_by_name_and_owner(
&self,
name: &str,
owner_id: Uuid,
2026-02-14 01:29:34 +01:00
) -> CalendarRepositoryResult<Calendar>;
2025-04-13 01:04:04 +02:00
/// Lists calendars shared with a specific user
2026-02-14 01:29:34 +01:00
async fn list_calendars_shared_with_user(
&self,
user_id: Uuid,
2026-02-14 01:29:34 +01:00
) -> CalendarRepositoryResult<Vec<Calendar>>;
2025-04-13 01:04:04 +02:00
/// List public calendars
2026-02-14 01:29:34 +01:00
async fn list_public_calendars(
&self,
limit: i64,
offset: i64,
) -> CalendarRepositoryResult<Vec<Calendar>>;
2025-04-13 01:04:04 +02:00
/// Checks if a user has access to a calendar
2026-02-14 01:29:34 +01:00
async fn user_has_calendar_access(
&self,
calendar_id: &Uuid,
user_id: Uuid,
2026-02-14 01:29:34 +01:00
) -> CalendarRepositoryResult<bool>;
2025-04-13 01:04:04 +02:00
/// Gets a custom property for a calendar
2026-02-14 01:29:34 +01:00
async fn get_calendar_property(
&self,
calendar_id: &Uuid,
property_name: &str,
) -> CalendarRepositoryResult<Option<String>>;
2025-04-13 01:04:04 +02:00
/// Sets a custom property for a calendar
2026-02-14 01:29:34 +01:00
async fn set_calendar_property(
&self,
calendar_id: &Uuid,
property_name: &str,
property_value: &str,
) -> CalendarRepositoryResult<()>;
2025-04-13 01:04:04 +02:00
/// Removes a custom property from a calendar
2026-02-14 01:29:34 +01:00
async fn remove_calendar_property(
&self,
calendar_id: &Uuid,
property_name: &str,
) -> CalendarRepositoryResult<()>;
2025-04-13 01:04:04 +02:00
/// Gets all custom properties for a calendar
2026-02-14 01:29:34 +01:00
async fn get_calendar_properties(
&self,
calendar_id: &Uuid,
) -> CalendarRepositoryResult<std::collections::HashMap<String, String>>;
2025-04-13 01:04:04 +02:00
/// Share calendar with another user
2026-02-14 01:29:34 +01:00
async fn share_calendar(
&self,
calendar_id: &Uuid,
user_id: Uuid,
2026-02-14 01:29:34 +01:00
access_level: &str,
) -> CalendarRepositoryResult<()>;
2025-04-13 01:04:04 +02:00
/// Remove calendar sharing for a user
2026-02-14 01:29:34 +01:00
async fn remove_calendar_sharing(
&self,
calendar_id: &Uuid,
user_id: Uuid,
2026-02-14 01:29:34 +01:00
) -> CalendarRepositoryResult<()>;
2025-04-13 01:04:04 +02:00
/// Get calendar sharing information (who has access to this calendar)
2026-02-14 01:29:34 +01:00
async fn get_calendar_shares(
&self,
calendar_id: &Uuid,
) -> CalendarRepositoryResult<Vec<(String, String)>>;
}