Skip to content

Commit

Permalink
core::site > Site, add event field for file_status
Browse files Browse the repository at this point in the history
  • Loading branch information
canewsin committed Jan 11, 2024
1 parent b8a8600 commit 4ce69ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/core/site.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use super::{address::Address as Addr, error::Error, peer::Peer};

pub mod models {
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::{BTreeMap, HashMap};

use crate::utils::is_default;
Expand All @@ -35,6 +36,7 @@ pub mod models {
pub workers: usize,
pub content: serde_json::Value,
pub privatekey: bool,
pub event: Option<Value>
}

#[derive(Serialize, Deserialize, Debug, Default, Clone)]
Expand Down
7 changes: 6 additions & 1 deletion src/plugins/websocket/handlers/sites.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use actix_web_actors::ws::WebsocketContext;
use futures::executor::block_on;
use log::*;
use serde::Serialize;
use serde_json::Value;
use serde_json::{Value, json};

use super::super::{error::Error, request::Command, response::Message, ZeruWebsocket};
use crate::{
Expand Down Expand Up @@ -65,6 +65,11 @@ pub fn handle_site_info(ws: &ZeruWebsocket, command: &Command) -> Result<Message
site_info.privatekey = true;
}
}
if let Value::Object(params) = &command.params {
if let Some(Value::String(path)) = params.get("file_status") {
site_info.event = Some(json!(["file_done", path])); //TODO!: get file status
}
}
command.respond(site_info)
} else {
Err(Error {
Expand Down

0 comments on commit 4ce69ad

Please sign in to comment.