mirror of
https://github.com/aljazceru/notedeck.git
synced 2026-01-14 13:54:19 +01:00
Fix parsing of subscription id for RelayMessage::Event
This commit is contained in:
@@ -90,7 +90,17 @@ impl<'a> RelayMessage<'a> {
|
||||
// Event
|
||||
// Relay response format: ["EVENT", <subscription id>, <event JSON>]
|
||||
if &msg[0..=7] == "[\"EVENT\"" {
|
||||
return Ok(Self::event(msg, "fixme"));
|
||||
let mut start = 9;
|
||||
while let Some(&b' ') = msg.as_bytes().get(start) {
|
||||
start += 1; // Move past optional spaces
|
||||
}
|
||||
if let Some(comma_index) = msg[start..].find(',') {
|
||||
let subid_end = start + comma_index;
|
||||
let subid = &msg[start..subid_end].trim().trim_matches('"');
|
||||
return Ok(Self::event(msg, subid));
|
||||
} else {
|
||||
return Ok(Self::event(msg, "fixme"));
|
||||
}
|
||||
}
|
||||
|
||||
// EOSE (NIP-15)
|
||||
|
||||
Reference in New Issue
Block a user