mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 19:46:50 +00:00
URL trimming and one missed URL validation
This commit is contained in:
parent
19c0d353c2
commit
2fbf450368
@ -89,8 +89,9 @@ pub async fn process_new_event(
|
|||||||
recommended_relay_url: Some(should_be_url),
|
recommended_relay_url: Some(should_be_url),
|
||||||
marker: _,
|
marker: _,
|
||||||
} => {
|
} => {
|
||||||
let url = Url::new(should_be_url);
|
let mut url = Url::new(should_be_url);
|
||||||
if url.is_valid_relay_url() {
|
if url.is_valid_relay_url() {
|
||||||
|
url.trim();
|
||||||
// Insert (or ignore) into relays table
|
// Insert (or ignore) into relays table
|
||||||
let dbrelay = DbRelay::new(url.inner().to_owned())?;
|
let dbrelay = DbRelay::new(url.inner().to_owned())?;
|
||||||
DbRelay::insert(dbrelay).await?;
|
DbRelay::insert(dbrelay).await?;
|
||||||
@ -101,8 +102,9 @@ pub async fn process_new_event(
|
|||||||
recommended_relay_url: Some(should_be_url),
|
recommended_relay_url: Some(should_be_url),
|
||||||
petname: _,
|
petname: _,
|
||||||
} => {
|
} => {
|
||||||
let url = Url::new(should_be_url);
|
let mut url = Url::new(should_be_url);
|
||||||
if url.is_valid_relay_url() {
|
if url.is_valid_relay_url() {
|
||||||
|
url.trim();
|
||||||
// Insert (or ignore) into relays table
|
// Insert (or ignore) into relays table
|
||||||
let dbrelay = DbRelay::new(url.inner().to_owned())?;
|
let dbrelay = DbRelay::new(url.inner().to_owned())?;
|
||||||
DbRelay::insert(dbrelay).await?;
|
DbRelay::insert(dbrelay).await?;
|
||||||
@ -222,7 +224,10 @@ pub async fn process_new_event(
|
|||||||
pubkeys.push(pubkey.to_owned());
|
pubkeys.push(pubkey.to_owned());
|
||||||
|
|
||||||
// If there is a URL, create or update person_relay last_suggested_kind3
|
// If there is a URL, create or update person_relay last_suggested_kind3
|
||||||
if let Some(url) = recommended_relay_url {
|
if let Some(ref url) = recommended_relay_url {
|
||||||
|
let mut url = url.to_owned();
|
||||||
|
if url.is_valid_relay_url() {
|
||||||
|
url.trim();
|
||||||
DbPersonRelay::upsert_last_suggested_bytag(
|
DbPersonRelay::upsert_last_suggested_bytag(
|
||||||
pubkey.0.to_owned(),
|
pubkey.0.to_owned(),
|
||||||
url.inner().to_owned(),
|
url.inner().to_owned(),
|
||||||
@ -230,6 +235,7 @@ pub async fn process_new_event(
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TBD: do something with the petname
|
// TBD: do something with the petname
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user