diff --git a/src/db/relay.rs b/src/db/relay.rs index c156001a..22fb58b6 100644 --- a/src/db/relay.rs +++ b/src/db/relay.rs @@ -18,7 +18,7 @@ pub struct DbRelay { impl DbRelay { pub fn new(url: String) -> Result { let u = Url::new(&url); - if !u.is_valid() { + if !u.is_valid_relay_url() { return Err(Error::InvalidUrl(u.inner().to_owned())); } @@ -83,7 +83,7 @@ impl DbRelay { pub async fn insert(relay: DbRelay) -> Result<(), Error> { let url = Url::new(&relay.url); - if !url.is_valid() { + if !url.is_valid_relay_url() { return Err(Error::InvalidUrl(relay.url.clone())); } @@ -218,7 +218,7 @@ impl DbRelay { let urls: Vec = maybe_urls .iter() .map(|s| Url::new(s)) - .filter(|r| r.is_valid()) + .filter(|r| r.is_valid_relay_url()) .collect(); // FIXME this is a lot of separate sql calls diff --git a/src/globals.rs b/src/globals.rs index a50789b7..660c50f4 100644 --- a/src/globals.rs +++ b/src/globals.rs @@ -131,7 +131,7 @@ impl Globals { .and_modify(|urls| { if let Some(ref u) = url { let n = Url::new(u); - if n.is_valid() { + if n.is_valid_relay_url() { urls.push(n); } } diff --git a/src/overlord/minion/mod.rs b/src/overlord/minion/mod.rs index 8c2b09eb..308f4909 100644 --- a/src/overlord/minion/mod.rs +++ b/src/overlord/minion/mod.rs @@ -35,7 +35,7 @@ pub struct Minion { impl Minion { pub async fn new(url: Url) -> Result { - if !url.is_valid() { + if !url.is_valid_relay_url() { return Err(Error::InvalidUrl(url.inner().to_owned())); } diff --git a/src/overlord/mod.rs b/src/overlord/mod.rs index 989524ba..eb0da1c2 100644 --- a/src/overlord/mod.rs +++ b/src/overlord/mod.rs @@ -263,7 +263,7 @@ impl Overlord { async fn start_minion(&mut self, url: String) -> Result<(), Error> { let url = Url::new(&url); - if !url.is_valid() { + if !url.is_valid_relay_url() { return Err(Error::InvalidUrl(url.inner().to_owned())); } let mut minion = Minion::new(url.clone()).await?; @@ -521,7 +521,7 @@ impl Overlord { let urls: Vec = desired_events_map .keys() .map(|u| u.to_owned()) - .filter(|u| u.is_valid()) + .filter(|u| u.is_valid_relay_url()) .collect(); for url in urls.iter() { @@ -614,7 +614,7 @@ impl Overlord { for relay in relays.iter() { // Save relay let relay_url = Url::new(relay); - if relay_url.is_valid() { + if relay_url.is_valid_relay_url() { let db_relay = DbRelay::new(relay_url.inner().to_owned())?; DbRelay::insert(db_relay).await?; @@ -642,7 +642,7 @@ impl Overlord { // Save relay let relay_url = Url::new(&relay); - if !relay_url.is_valid() { + if !relay_url.is_valid_relay_url() { return Err(Error::InvalidUrl(relay)); } let db_relay = DbRelay::new(relay.to_string())?; @@ -670,7 +670,7 @@ impl Overlord { // Save relay let relay_url = Url::new(&relay); - if !relay_url.is_valid() { + if !relay_url.is_valid_relay_url() { return Err(Error::InvalidUrl(relay)); } let db_relay = DbRelay::new(relay.to_string())?; diff --git a/src/process.rs b/src/process.rs index fbdd3b7f..f54fe362 100644 --- a/src/process.rs +++ b/src/process.rs @@ -93,7 +93,7 @@ pub async fn process_new_event( marker: _, } => { let url = Url::new(should_be_url); - if url.is_valid() { + if url.is_valid_relay_url() { // Insert (or ignore) into relays table let dbrelay = DbRelay::new(url.inner().to_owned())?; DbRelay::insert(dbrelay).await?; @@ -105,7 +105,7 @@ pub async fn process_new_event( petname: _, } => { let url = Url::new(should_be_url); - if url.is_valid() { + if url.is_valid_relay_url() { // Insert (or ignore) into relays table let dbrelay = DbRelay::new(url.inner().to_owned())?; DbRelay::insert(dbrelay).await?; diff --git a/src/ui/relays.rs b/src/ui/relays.rs index 706d9f96..0d15fd89 100644 --- a/src/ui/relays.rs +++ b/src/ui/relays.rs @@ -78,7 +78,7 @@ fn render_relay(ui: &mut Ui, relay: &DbRelay, bold: bool) { let mut post = relay.post; // checkbox needs a mutable state variable. let url = Url::new(&relay.url); - if url.is_valid() && ui.checkbox(&mut post, "Post Here") + if url.is_valid_relay_url() && ui.checkbox(&mut post, "Post Here") .on_hover_text("If selected, posts you create will be sent to this relay. But you have to press [SAVE CHANGES] at the bottom of this page.") .clicked() {