mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-22 09:09:07 -05:00
improvement: send NOTICE for too-large messages
This commit is contained in:
parent
01d81db617
commit
79a982e3ef
|
@ -34,6 +34,7 @@ use tokio::sync::broadcast::{self, Receiver, Sender};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use tokio::sync::oneshot;
|
use tokio::sync::oneshot;
|
||||||
use tokio_tungstenite::WebSocketStream;
|
use tokio_tungstenite::WebSocketStream;
|
||||||
|
use tungstenite::error::CapacityError::MessageTooLong;
|
||||||
use tungstenite::error::Error as WsError;
|
use tungstenite::error::Error as WsError;
|
||||||
use tungstenite::handshake;
|
use tungstenite::handshake;
|
||||||
use tungstenite::protocol::Message;
|
use tungstenite::protocol::Message;
|
||||||
|
@ -476,6 +477,10 @@ async fn nostr_server(
|
||||||
// send responses automatically.
|
// send responses automatically.
|
||||||
continue;
|
continue;
|
||||||
},
|
},
|
||||||
|
Some(Err(WsError::Capacity(MessageTooLong{size, max_size}))) => {
|
||||||
|
ws_stream.send(make_notice_message(&format!("message too large ({} > {})",size, max_size))).await.ok();
|
||||||
|
continue;
|
||||||
|
},
|
||||||
None |
|
None |
|
||||||
Some(Ok(Message::Close(_))) |
|
Some(Ok(Message::Close(_))) |
|
||||||
Some(Err(WsError::AlreadyClosed)) |
|
Some(Err(WsError::AlreadyClosed)) |
|
||||||
|
|
Loading…
Reference in New Issue
Block a user