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

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

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum PinEventType {
    Added,
    Removed,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum PinEvent {
    #[serde(rename = "pin.added")]
    Added(PinAddedService),
    #[serde(rename = "pin.removed")]
    Removed(PinRemovedService),
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PinAddedService {
    pub room: RoomInfo,
    pub message: Uuid,
    pub pinned_by: UserInfo,
    pub pinned_at: DateTime<Utc>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PinRemovedService {
    pub room: RoomInfo,
    pub message: Uuid,
    pub removed_by: UserInfo,
    pub removed_at: DateTime<Utc>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PinAddClient {
    pub room: RoomInfo,
    pub message: Uuid,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PinRemoveClient {
    pub room: RoomInfo,
    pub message: Uuid,
}
