userlib/dto/
chat_allowed_response.rsuse chrono::NaiveDateTime;
use common::utils::serialize_option_naive_date;
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct ChatAllowedResponse {
pub is_allowed: bool,
#[serde(default)]
#[serde(with = "serialize_option_naive_date")]
#[serde(skip_serializing_if = "Option::is_none")]
pub time_allowed: Option<NaiveDateTime>,
pub teacher_ids: Vec<Uuid>,
}
impl ChatAllowedResponse {
pub fn allowed() -> ChatAllowedResponse {
ChatAllowedResponse {
is_allowed: true,
time_allowed: None,
teacher_ids: vec![],
}
}
pub fn blocked(teacher_ids: Vec<Uuid>) -> ChatAllowedResponse {
ChatAllowedResponse {
is_allowed: false,
time_allowed: None,
teacher_ids,
}
}
}