use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use uuid::Uuid;

use crate::event::{RoomInfo, UserInfo, message::MessageNewService};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchResultService {
    pub q: String,
    pub room: Option<RoomInfo>,
    pub messages: Vec<SearchMessageHitService>,
    pub total: i64,
    pub took_ms: i64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchMessageHitService {
    #[serde(flatten)]
    pub message: MessageNewService,
    pub highlighted_content: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchClient {
    pub q: String,
    pub room: Option<Uuid>,
    pub start_time: Option<DateTime<Utc>>,
    pub end_time: Option<DateTime<Utc>>,
    pub sender: Option<UserInfo>,
    pub content_type: Option<String>,
    pub limit: Option<u64>,
    pub offset: Option<u64>,
}
