mirror of
https://github.com/mikedilger/chorus.git
synced 2026-05-03 06:51:42 +00:00
management: listbannedevents2
This commit is contained in:
parent
ad687598a0
commit
4e5d7ef9fe
@ -18,6 +18,13 @@ struct EventResult {
|
||||
reason: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct FullEventResult {
|
||||
event: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
reason: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct PubkeyResult {
|
||||
pubkey: String,
|
||||
@ -128,6 +135,7 @@ pub fn handle_inner(pubkey: Pubkey, command: Value) -> Result<Option<Value>, Err
|
||||
|
||||
"listallowedevents",
|
||||
"listbannedevents",
|
||||
"listbannedevents2",
|
||||
"listallowedpubkeys",
|
||||
"listbannedpubkeys",
|
||||
|
||||
@ -283,6 +291,25 @@ pub fn handle_inner(pubkey: Pubkey, command: Value) -> Result<Option<Value>, Err
|
||||
"result": ids
|
||||
})))
|
||||
}
|
||||
"listbannedevents2" => {
|
||||
let approvals = crate::dump_event_approvals(GLOBALS.store.get().unwrap())?;
|
||||
let mut results: Vec<FullEventResult> = Vec::new();
|
||||
for (id, appr) in approvals.iter() {
|
||||
if ! *appr {
|
||||
if let Some(event) = GLOBALS.store.get().unwrap().get_event_by_id(*id)? {
|
||||
results.push(
|
||||
FullEventResult {
|
||||
event: format!("{event}"),
|
||||
reason: None,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(Some(json!({
|
||||
"result": results
|
||||
})))
|
||||
}
|
||||
"listallowedpubkeys" => {
|
||||
let approvals = crate::dump_pubkey_approvals(GLOBALS.store.get().unwrap())?;
|
||||
let pubkeys: Vec<PubkeyResult> = approvals
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user