koprogo_api/application/dto/
ag_session_dto.rs

1use crate::domain::entities::ag_session::AgSession;
2use chrono::{DateTime, Utc};
3use serde::{Deserialize, Serialize};
4use uuid::Uuid;
5
6/// DTO de création d'une session AG visioconférence
7#[derive(Debug, Clone, Deserialize)]
8pub struct CreateAgSessionDto {
9    pub meeting_id: Uuid,
10    pub platform: String, // "zoom" | "microsoft_teams" | "google_meet" | "jitsi" | "whereby" | "other"
11    pub video_url: String,
12    pub host_url: Option<String>,
13    pub scheduled_start: DateTime<Utc>,
14    pub access_password: Option<String>,
15    pub waiting_room_enabled: Option<bool>,
16    pub recording_enabled: Option<bool>,
17}
18
19/// DTO pour terminer une session
20#[derive(Debug, Clone, Deserialize)]
21pub struct EndAgSessionDto {
22    pub recording_url: Option<String>,
23}
24
25/// DTO pour enregistrer un participant distant
26#[derive(Debug, Clone, Deserialize)]
27pub struct RecordRemoteJoinDto {
28    pub voting_power: f64,
29    pub total_building_quotas: f64,
30}
31
32/// Réponse API pour une session AG
33#[derive(Debug, Clone, Serialize)]
34pub struct AgSessionResponse {
35    pub id: Uuid,
36    pub organization_id: Uuid,
37    pub meeting_id: Uuid,
38    pub platform: String,
39    pub video_url: String,
40    pub host_url: Option<String>,
41    pub status: String,
42    pub scheduled_start: DateTime<Utc>,
43    pub actual_start: Option<DateTime<Utc>>,
44    pub actual_end: Option<DateTime<Utc>>,
45    pub remote_attendees_count: i32,
46    pub remote_voting_power: f64,
47    pub quorum_remote_contribution: f64,
48    pub waiting_room_enabled: bool,
49    pub recording_enabled: bool,
50    pub recording_url: Option<String>,
51    pub duration_minutes: Option<i64>,
52    pub created_at: DateTime<Utc>,
53    pub updated_at: DateTime<Utc>,
54    pub created_by: Uuid,
55}
56
57/// Réponse pour le calcul du quorum combiné
58#[derive(Debug, Clone, Serialize)]
59pub struct CombinedQuorumResponse {
60    pub session_id: Uuid,
61    pub meeting_id: Uuid,
62    pub physical_quotas: f64,
63    pub remote_quotas: f64,
64    pub total_building_quotas: f64,
65    pub combined_percentage: f64,
66    pub quorum_reached: bool, // true si combined_percentage > 50.0
67}
68
69impl From<&AgSession> for AgSessionResponse {
70    fn from(s: &AgSession) -> Self {
71        Self {
72            id: s.id,
73            organization_id: s.organization_id,
74            meeting_id: s.meeting_id,
75            platform: s.platform.to_db_str().to_string(),
76            video_url: s.video_url.clone(),
77            host_url: s.host_url.clone(),
78            status: s.status.to_db_str().to_string(),
79            scheduled_start: s.scheduled_start,
80            actual_start: s.actual_start,
81            actual_end: s.actual_end,
82            remote_attendees_count: s.remote_attendees_count,
83            remote_voting_power: s.remote_voting_power,
84            quorum_remote_contribution: s.quorum_remote_contribution,
85            waiting_room_enabled: s.waiting_room_enabled,
86            recording_enabled: s.recording_enabled,
87            recording_url: s.recording_url.clone(),
88            duration_minutes: s.duration_minutes(),
89            created_at: s.created_at,
90            updated_at: s.updated_at,
91            created_by: s.created_by,
92        }
93    }
94}