diff --git a/src/database/entities/channel.rs b/src/database/entities/channel.rs index 4c8d69e6f037a596c2c0bccbffe64b0e807d8da1..f7906992e17188e7971a93c2e0cf917b55cb45c6 100644 --- a/src/database/entities/channel.rs +++ b/src/database/entities/channel.rs @@ -6,7 +6,7 @@ use rocket_contrib::json::JsonValue; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug, Clone)] -#[serde(tag = "channel_type")] +#[serde(tag = "type")] pub enum Channel { SavedMessages { #[serde(rename = "_id")] @@ -64,12 +64,11 @@ impl Channel { Ok(()) } - pub async fn publish_update(&self, partial: JsonValue) -> Result<()> { + pub async fn publish_update(&self, data: JsonValue) -> Result<()> { let id = self.id().to_string(); - ClientboundNotification::ChannelUpdate(partial) - .publish(id) - .await - .ok(); + ClientboundNotification::ChannelUpdate { + id: id.clone(), data + }.publish(id).await.ok(); Ok(()) } diff --git a/src/database/entities/message.rs b/src/database/entities/message.rs index e48775c773d14691b66cc557f84bce5eb090bdd1..f03e29d5289593eeb72018d28ab4a33dcb32c33d 100644 --- a/src/database/entities/message.rs +++ b/src/database/entities/message.rs @@ -53,12 +53,11 @@ impl Message { Ok(()) } - pub async fn publish_update(&self, partial: JsonValue) -> Result<()> { + pub async fn publish_update(&self, data: JsonValue) -> Result<()> { let channel = self.channel.clone(); - ClientboundNotification::MessageUpdate(partial) - .publish(channel) - .await - .ok(); + ClientboundNotification::MessageUpdate { + id: self.id.clone(), data + }.publish(channel).await.ok(); Ok(()) } diff --git a/src/notifications/events.rs b/src/notifications/events.rs index f370af8062f2674f2f95d0c4b696bba332475a0f..b1df74050d223c41f4dcf20dae7fc6a2e111b077 100644 --- a/src/notifications/events.rs +++ b/src/notifications/events.rs @@ -39,13 +39,19 @@ pub enum ClientboundNotification { }, Message(Message), - MessageUpdate(JsonValue), + MessageUpdate { + id: String, + data: JsonValue + }, MessageDelete { id: String, }, ChannelCreate(Channel), - ChannelUpdate(JsonValue), + ChannelUpdate { + id: String, + data: JsonValue + }, ChannelGroupJoin { id: String, user: String,