noteguard

the nostr relay spam guardian
git clone git://jb55.com/noteguard
Log | Files | Refs | README | LICENSE

content.rs (617B)


      1 use crate::{Action, InputMessage, NoteFilter, OutputMessage};
      2 use serde::Deserialize;
      3 
      4 #[derive(Deserialize, Default)]
      5 pub struct Content {
      6     filters: Vec<String>,
      7 }
      8 
      9 impl NoteFilter for Content {
     10     fn filter_note(&mut self, msg: &InputMessage) -> OutputMessage {
     11         for filter in &self.filters {
     12             if msg.event.content.contains(filter) {
     13                 return OutputMessage::new(msg.event.id.clone(), Action::ShadowReject, None);
     14             }
     15         }
     16 
     17         OutputMessage::new(msg.event.id.clone(), Action::Accept, None)
     18     }
     19 
     20     fn name(&self) -> &'static str {
     21         "content"
     22     }
     23 }