Update for upstream nostr-types Url::is_valid_relay_url()

This commit is contained in:
Mike Dilger 2022-12-31 20:50:00 +13:00
parent 503e9080ca
commit 12b0014485
6 changed files with 13 additions and 13 deletions

View File

@ -18,7 +18,7 @@ pub struct DbRelay {
impl DbRelay {
pub fn new(url: String) -> Result<DbRelay, Error> {
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<Url> = 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

View File

@ -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);
}
}

View File

@ -35,7 +35,7 @@ pub struct Minion {
impl Minion {
pub async fn new(url: Url) -> Result<Minion, Error> {
if !url.is_valid() {
if !url.is_valid_relay_url() {
return Err(Error::InvalidUrl(url.inner().to_owned()));
}

View File

@ -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<Url> = 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())?;

View File

@ -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?;

View File

@ -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()
{