diff --git a/examples/live_federation/http.rs b/examples/live_federation/http.rs index d626396..e0d2869 100644 --- a/examples/live_federation/http.rs +++ b/examples/live_federation/http.rs @@ -61,7 +61,7 @@ pub async fn webfinger( data: Data, ) -> Result, Error> { let name = extract_webfinger_name(&query.resource, &data)?; - let db_user = data.read_user(&name)?; + let db_user = data.read_user(name)?; Ok(Json(build_webfinger_response( query.resource, db_user.ap_id.into_inner(), diff --git a/examples/local_federation/actix_web/http.rs b/examples/local_federation/actix_web/http.rs index 12a750f..6298014 100644 --- a/examples/local_federation/actix_web/http.rs +++ b/examples/local_federation/actix_web/http.rs @@ -89,7 +89,7 @@ pub async fn webfinger( data: Data, ) -> Result { let name = extract_webfinger_name(&query.resource, &data)?; - let db_user = data.read_user(&name)?; + let db_user = data.read_user(name)?; Ok(HttpResponse::Ok().json(build_webfinger_response( query.resource.clone(), db_user.ap_id.into_inner(), diff --git a/examples/local_federation/axum/http.rs b/examples/local_federation/axum/http.rs index 3202117..f17ea4a 100644 --- a/examples/local_federation/axum/http.rs +++ b/examples/local_federation/axum/http.rs @@ -78,7 +78,7 @@ async fn webfinger( data: Data, ) -> Result, Error> { let name = extract_webfinger_name(&query.resource, &data)?; - let db_user = data.read_user(&name)?; + let db_user = data.read_user(name)?; Ok(Json(build_webfinger_response( query.resource, db_user.ap_id.into_inner(), diff --git a/src/fetch/webfinger.rs b/src/fetch/webfinger.rs index 5b0f78b..5abad23 100644 --- a/src/fetch/webfinger.rs +++ b/src/fetch/webfinger.rs @@ -28,7 +28,7 @@ pub enum WebFingerError { } impl WebFingerError { - fn to_crate_error(self) -> Error { + fn into_crate_error(self) -> Error { self.into() } } @@ -49,7 +49,7 @@ where let (_, domain) = identifier .splitn(2, '@') .collect_tuple() - .ok_or(WebFingerError::WrongFormat.to_crate_error())?; + .ok_or(WebFingerError::WrongFormat.into_crate_error())?; let protocol = if data.config.debug { "http" } else { "https" }; let fetch_url = format!("{protocol}://{domain}/.well-known/webfinger?resource=acct:{identifier}"); @@ -84,7 +84,7 @@ where Err(error) => debug!(%error, "Failed to dereference link"), } } - Err(WebFingerError::NoValidLink.to_crate_error().into()) + Err(WebFingerError::NoValidLink.into_crate_error().into()) } /// Extracts username from a webfinger resource parameter. @@ -117,14 +117,14 @@ where T: Clone, { static WEBFINGER_REGEX: Lazy = - Lazy::new(|| Regex::new(&format!(r"^acct:([\p{{L}}0-9_]+)@\(.*)$")).unwrap()); + Lazy::new(|| Regex::new(r"^acct:([\p{L}0-9_]+)@(.*)$").unwrap()); // Regex to extract usernames from webfinger query. Supports different alphabets using `\p{L}`. // TODO: This should use a URL parser let captures = WEBFINGER_REGEX .captures(query) - .ok_or_else(|| WebFingerError::WrongFormat)?; + .ok_or(WebFingerError::WrongFormat)?; - let account_name = captures.get(1).ok_or_else(|| WebFingerError::WrongFormat)?; + let account_name = captures.get(1).ok_or(WebFingerError::WrongFormat)?; if captures.get(2).map(|m| m.as_str()) != Some(data.domain()) { return Err(WebFingerError::WrongDomain.into());