Skip to content

Commit

Permalink
Command 'delete_relay' to get rid of mistaken (but technically valid)…
Browse files Browse the repository at this point in the history
… URLs like "wss://pleb.cloud,wss//nostr.mom"
  • Loading branch information
mikedilger committed Dec 22, 2023
1 parent 42ebc6a commit ad6f406
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion gossip-bin/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Command {
}
}

const COMMANDS: [Command; 26] = [
const COMMANDS: [Command; 27] = [
Command {
cmd: "oneshot",
usage_params: "{depends}",
Expand Down Expand Up @@ -59,6 +59,11 @@ const COMMANDS: [Command; 26] = [
usage_params: "<pubkeyhex> <ciphertext>",
desc: "decrypt the ciphertext from the pubkeyhex.",
},
Command {
cmd: "delete_relay",
usage_params: "<relayurl>",
desc: "delete a relay record from storage.",
},
Command {
cmd: "events_of_kind",
usage_params: "<kind>",
Expand Down Expand Up @@ -184,6 +189,7 @@ pub fn handle_command(mut args: env::Args, runtime: &Runtime) -> Result<bool, Er
"bech32_decode" => bech32_decode(command, args)?,
"bech32_encode_event_addr" => bech32_encode_event_addr(command, args)?,
"decrypt" => decrypt(command, args)?,
"delete_relay" => delete_relay(command, args)?,
"events_of_kind" => events_of_kind(command, args)?,
"events_of_pubkey_and_kind" => events_of_pubkey_and_kind(command, args)?,
"giftwrap_ids" => giftwrap_ids(command)?,
Expand Down Expand Up @@ -412,6 +418,17 @@ pub fn decrypt(cmd: Command, mut args: env::Args) -> Result<(), Error> {
Ok(())
}

pub fn delete_relay(cmd: Command, mut args: env::Args) -> Result<(), Error> {
let rurl = match args.next() {
Some(urlstr) => RelayUrl::try_from_str(&urlstr)?,
None => return cmd.usage("Missing relay url parameter".to_string()),
};

GLOBALS.storage.delete_relay(&rurl, None)?;

Ok(())
}

pub fn import_event(cmd: Command, mut args: env::Args, runtime: &Runtime) -> Result<(), Error> {
let event = match args.next() {
Some(json) => {
Expand Down

0 comments on commit ad6f406

Please sign in to comment.