noteguard

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

messages.rs (857B)


      1 use crate::Note;
      2 use serde::{Deserialize, Serialize};
      3 
      4 #[derive(Deserialize)]
      5 pub struct InputMessage {
      6     #[serde(rename = "type")]
      7     pub message_type: String,
      8     pub event: Note,
      9     #[serde(rename = "receivedAt")]
     10     pub received_at: u64,
     11     #[serde(rename = "sourceType")]
     12     pub source_type: String,
     13     #[serde(rename = "sourceInfo")]
     14     pub source_info: String,
     15 }
     16 
     17 #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
     18 #[serde(rename_all = "camelCase")]
     19 pub enum Action {
     20     Accept,
     21     Reject,
     22     ShadowReject,
     23 }
     24 
     25 #[derive(Serialize)]
     26 pub struct OutputMessage {
     27     pub id: String,
     28     pub action: Action,
     29     #[serde(skip_serializing_if = "Option::is_none")]
     30     pub msg: Option<String>,
     31 }
     32 
     33 impl OutputMessage {
     34     pub fn new(id: String, action: Action, msg: Option<String>) -> Self {
     35         OutputMessage { id, action, msg }
     36     }
     37 }