protected_events.rs (827B)
1 use crate::{Action, InputMessage, NoteFilter, OutputMessage}; 2 use serde::Deserialize; 3 4 #[derive(Deserialize, Default)] 5 pub struct ProtectedEvents {} 6 7 impl NoteFilter for ProtectedEvents { 8 fn filter_note(&mut self, input: &InputMessage) -> OutputMessage { 9 if let Some(tag) = input.event.tags.first() { 10 if let Some(entry) = tag.first() { 11 if entry == "-" { 12 return OutputMessage::new( 13 input.event.id.clone(), 14 Action::Reject, 15 Some("blocked: event marked as protected".to_string()), 16 ); 17 } 18 } 19 } 20 21 OutputMessage::new(input.event.id.clone(), Action::Accept, None) 22 } 23 24 fn name(&self) -> &'static str { 25 "protected_events" 26 } 27 }