Impl default for chatmessage object line
This commit is contained in:
parent
875b60a608
commit
1ee28e57d4
|
@ -9,13 +9,13 @@ use sqlx::{
|
||||||
/// The reasoning for this is that a chatroom can have many users
|
/// The reasoning for this is that a chatroom can have many users
|
||||||
/// and the backend needs to be able to tell when each of them
|
/// and the backend needs to be able to tell when each of them
|
||||||
/// has seen this message.
|
/// has seen this message.
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Default)]
|
||||||
pub struct TimeSensitiveAction {
|
pub struct TimeSensitiveAction {
|
||||||
pub time: DateTime<Utc>,
|
pub time: DateTime<Utc>,
|
||||||
pub by: u32,
|
pub by: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Default)]
|
||||||
pub struct TimeSensitiveActionVec {
|
pub struct TimeSensitiveActionVec {
|
||||||
pub list: Vec<TimeSensitiveAction>,
|
pub list: Vec<TimeSensitiveAction>,
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ impl TimeSensitiveAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Base message for chat rooms.
|
/// Base message for chat rooms.
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, FromRow)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, FromRow, Default)]
|
||||||
pub struct ChatMessage {
|
pub struct ChatMessage {
|
||||||
pub id: u32,
|
pub id: u32,
|
||||||
/// User id
|
/// User id
|
||||||
|
@ -142,7 +142,7 @@ impl ChatSendable for ChatMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is what clients use to send messages (DTO)
|
/// This is what clients use to send messages (DTO)
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Default)]
|
||||||
pub struct ChatMessageSender {
|
pub struct ChatMessageSender {
|
||||||
pub message: ChatMessageContent,
|
pub message: ChatMessageContent,
|
||||||
pub to: u32,
|
pub to: u32,
|
||||||
|
@ -158,3 +158,14 @@ pub enum BroadcastMessage {
|
||||||
DeliveredUpdate(ChatMessage),
|
DeliveredUpdate(ChatMessage),
|
||||||
SeenUpdate(ChatMessage),
|
SeenUpdate(ChatMessage),
|
||||||
}
|
}
|
||||||
|
impl Default for BroadcastMessage {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::NewMessage(Default::default())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for ChatMessageContent {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::Text(Default::default())
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue