mirror of
https://github.com/mikedilger/chorus.git
synced 2026-06-02 07:02:09 +00:00
Handle nostr messages in separate module
This commit is contained in:
parent
dddc05928c
commit
f8c2f54005
@ -3,6 +3,7 @@ include!("macros.rs");
|
||||
pub mod config;
|
||||
pub mod error;
|
||||
pub mod globals;
|
||||
pub mod nostr;
|
||||
pub mod reply;
|
||||
pub mod store;
|
||||
pub mod tls;
|
||||
@ -223,8 +224,12 @@ impl WebSocketService {
|
||||
match message {
|
||||
Message::Text(msg) => {
|
||||
log::debug!("{}: <= {}", self.peer, msg);
|
||||
let reply = NostrReply::Notice("error: Not Yet Implemented".to_string());
|
||||
self.websocket.send(Message::text(reply.as_json())).await?;
|
||||
// This is defined in nostr.rs
|
||||
if let Err(e) = self.handle_nostr_message(msg).await {
|
||||
log::error!("{e}");
|
||||
let reply = NostrReply::Notice(format!("error: {}", e));
|
||||
self.websocket.send(Message::text(reply.as_json())).await?;
|
||||
}
|
||||
}
|
||||
Message::Binary(msg) => {
|
||||
let reply = NostrReply::Notice(
|
||||
|
||||
14
src/nostr.rs
Normal file
14
src/nostr.rs
Normal file
@ -0,0 +1,14 @@
|
||||
use crate::error::Error;
|
||||
use crate::reply::NostrReply;
|
||||
use crate::WebSocketService;
|
||||
use futures::SinkExt;
|
||||
use hyper_tungstenite::tungstenite::Message;
|
||||
|
||||
impl WebSocketService {
|
||||
pub async fn handle_nostr_message(&mut self, msg: String) -> Result<(), Error> {
|
||||
log::warn!("Received unhandled text message: {}", msg);
|
||||
let reply = NostrReply::Notice("NIP-01 is not yet fully supported".to_owned());
|
||||
self.websocket.send(Message::text(reply.as_json())).await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user