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>,
|
reason: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
struct FullEventResult {
|
||||||
|
event: String,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
reason: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct PubkeyResult {
|
struct PubkeyResult {
|
||||||
pubkey: String,
|
pubkey: String,
|
||||||
@ -128,6 +135,7 @@ pub fn handle_inner(pubkey: Pubkey, command: Value) -> Result<Option<Value>, Err
|
|||||||
|
|
||||||
"listallowedevents",
|
"listallowedevents",
|
||||||
"listbannedevents",
|
"listbannedevents",
|
||||||
|
"listbannedevents2",
|
||||||
"listallowedpubkeys",
|
"listallowedpubkeys",
|
||||||
"listbannedpubkeys",
|
"listbannedpubkeys",
|
||||||
|
|
||||||
@ -283,6 +291,25 @@ pub fn handle_inner(pubkey: Pubkey, command: Value) -> Result<Option<Value>, Err
|
|||||||
"result": ids
|
"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" => {
|
"listallowedpubkeys" => {
|
||||||
let approvals = crate::dump_pubkey_approvals(GLOBALS.store.get().unwrap())?;
|
let approvals = crate::dump_pubkey_approvals(GLOBALS.store.get().unwrap())?;
|
||||||
let pubkeys: Vec<PubkeyResult> = approvals
|
let pubkeys: Vec<PubkeyResult> = approvals
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user