Revert tag change, update partials to include ids.

This commit is contained in:
Paul Makles
2021-01-19 20:18:29 +00:00
parent 5ab329dfdd
commit 984017eb61
3 changed files with 17 additions and 13 deletions

View File

@@ -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(())
}

View File

@@ -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(())
}