diff --git a/src/connection.rs b/src/connection.rs index e3d337ade4b80c1b8f60664c3f0e05c379d9e2c5..17b61a12f2eeaa83b397e1ebcb2fa6c14890ffcb 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -110,7 +110,7 @@ pub async fn handle_user_socket(mut ws: WebSocket, app: Arc<App>, forwarded_for: log::debug!(target: "notify_push::send", "Sending {} to {}", msg, user_id); METRICS.add_message(); last_send = now; - user_ws_tx.send(msg.to_message(&opts)).await.ok(); + user_ws_tx.send(msg.into_message(&opts)).await.ok(); } } Err(_timout) => { @@ -118,7 +118,7 @@ pub async fn handle_user_socket(mut ws: WebSocket, app: Arc<App>, forwarded_for: last_send = now; METRICS.add_message(); log::debug!(target: "notify_push::send", "Sending debounced {} to {}", msg, user_id); - user_ws_tx.feed(msg.to_message(&opts)).await.ok(); + user_ws_tx.feed(msg.into_message(&opts)).await.ok(); } if now.duration_since(last_send) > ping_interval { diff --git a/src/message.rs b/src/message.rs index 3f6479ccbc84c3f4068b37b17462247158eb2ed9..378f3aacf4e9d3f176c33cb36fe1f19ff80ceaa6 100644 --- a/src/message.rs +++ b/src/message.rs @@ -73,7 +73,7 @@ impl PushMessage { } impl PushMessage { - pub fn to_message(self, opts: &ConnectionOptions) -> Message { + pub fn into_message(self, opts: &ConnectionOptions) -> Message { match self { PushMessage::File(ids) => match ids { UpdatedFiles::Known(ids) if opts.listen_file_id.load(Ordering::Relaxed) => { @@ -85,7 +85,7 @@ impl PushMessage { _ => Message::text(String::from("notify_file")), }, PushMessage::Activity => Message::text(String::from("notify_activity")), - PushMessage::Notification => Message::text(String::from("notify_file")), + PushMessage::Notification => Message::text(String::from("notify_notification")), PushMessage::Custom(ty, Value::Null) => Message::text(ty), PushMessage::Custom(ty, body) => Message::text({ let mut str = ty; diff --git a/test_client/src/main.rs b/test_client/src/main.rs index 5c05b6ce0f2af0310b81374f35c087fd0b0af076..e7e2a9f11a1b5bd687bf7c0eaf32c35e00ce056c 100644 --- a/test_client/src/main.rs +++ b/test_client/src/main.rs @@ -34,9 +34,9 @@ fn main() -> Result<()> { socket .write_message(Message::Text(password)) .wrap_err("Failed to send password")?; - // socket - // .write_message(Message::Text("listen notify_file_id".into())) - // .wrap_err("Failed to send username")?; + socket + .write_message(Message::Text("listen notify_file_id".into())) + .wrap_err("Failed to send username")?; loop { if let Message::Text(text) = socket.read_message()? { diff --git a/tests/CoreEventsTest.php b/tests/CoreEventsTest.php index 1f3e6154db13db447fe0588d4c858341c498cd3e..58092102524a2aca9272cfd0059440064b95f473 100644 --- a/tests/CoreEventsTest.php +++ b/tests/CoreEventsTest.php @@ -66,6 +66,11 @@ class CoreEventsTest extends TestCase { $storage->touch('foobar', 100); $storage->getUpdater()->update('foobar'); + // file ids are unstable, so we remove them + foreach ($events as $event) { + unset($event['fileid']); + } + $this->assertEquals([ 'notify_storage_update' => [ ['storage' => $cache->getNumericStorageId(), 'path' => 'foobar'], diff --git a/tests/integration.rs b/tests/integration.rs index ca1cbaaac4cc7b9228861c2466fddc4a7f2450f8..2a5bf07e813339a61cffcd233a1569c9440cb991 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -5,12 +5,14 @@ use futures::{pin_mut, FutureExt}; use futures::{SinkExt, StreamExt}; use http_auth_basic::Credentials; use notify_push::config::{Bind, Config}; +use notify_push::message::DEBOUNCE_ENABLE; use notify_push::{listen_loop, serve, App}; use once_cell::sync::Lazy; use redis::AsyncCommands; use smallvec::alloc::sync::Arc; use sqlx::AnyPool; use std::net::SocketAddr; +use std::sync::atomic::Ordering; use std::sync::Mutex; use tokio::net::{TcpListener, TcpStream}; use tokio::sync::oneshot; @@ -54,6 +56,7 @@ static LOG_HANDLE: Lazy<LoggerHandle> = impl Services { pub async fn new() -> Self { + DEBOUNCE_ENABLE.store(false, Ordering::SeqCst); let redis_tcp = listen_available_port() .await .expect("Can't find open port for redis");