fix NIP-86 listeventsneedingmoderation output

This commit is contained in:
Mike Dilger 2025-02-18 11:06:16 +13:00
parent 53cca34104
commit 1e2ca3f8c8
No known key found for this signature in database
GPG Key ID: 47581A78D4329BA4

View File

@ -6,9 +6,16 @@ use http_body_util::{BodyExt, Full};
use hyper::body::{Bytes, Incoming};
use hyper::{Request, Response, StatusCode};
use pocket_types::{Event, Filter, Id, Kind, Pubkey};
use serde::Serialize;
use serde_json::{json, Map, Value};
mod auth;
#[derive(Serialize)]
struct EventNeedingModeration {
id: String,
reason: String,
}
fn respond(
json: serde_json::Value,
status: StatusCode,
@ -339,7 +346,7 @@ pub fn handle_inner(pubkey: Pubkey, command: Value) -> Result<Option<Value>, Err
&& !crate::is_authorized_user(e.pubkey())
};
let mut need_moderation: Vec<String> = Vec::new();
let mut need_moderation: Vec<EventNeedingModeration> = Vec::new();
let mut events = GLOBALS
.store
@ -373,7 +380,10 @@ pub fn handle_inner(pubkey: Pubkey, command: Value) -> Result<Option<Value>, Err
continue;
}
need_moderation.push(String::from_utf8_lossy(&event.as_json()?).to_string());
need_moderation.push(EventNeedingModeration {
id: event.id().as_hex_string(),
reason: "unmoderated".to_string(),
});
}
Ok(Some(json!({