1use chrono::NaiveDateTime;
2use serde::{Deserialize, Serialize};
3
4use crate::groupchat::GroupChat;
5
6pub enum MessageTarget {
7 Player(String),
8 Group(GroupChat),
9}
10
11#[derive(Debug, Clone, Serialize, Deserialize)]
12pub struct Messages {
13 id: String,
14 player_id: String,
15 target_id: String,
16 content: String,
17 date: NaiveDateTime,
18}
19
20impl Messages {
21 pub async fn new(
34 player_id: String,
35 target_id: String,
36 content: String,
37 date: NaiveDateTime,
38 ) -> Self {
39 Self {
40 id: uuid::Uuid::new_v4().to_string(),
41 player_id,
42 target_id,
43 content,
44 date,
45 }
46 }
47
48 pub async fn content(&self) -> &str {
49 &self.content
50 }
51}