mirror of
https://github.com/LemmyNet/activitypub-federation-rust.git
synced 2024-05-18 00:52:40 +00:00
clippy
This commit is contained in:
parent
dce3a3f90e
commit
af6fa7accb
|
@ -61,7 +61,7 @@ pub async fn webfinger(
|
|||
data: Data<DatabaseHandle>,
|
||||
) -> Result<Json<Webfinger>, 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(),
|
||||
|
|
|
@ -89,7 +89,7 @@ pub async fn webfinger(
|
|||
data: Data<DatabaseHandle>,
|
||||
) -> Result<HttpResponse, Error> {
|
||||
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(),
|
||||
|
|
|
@ -78,7 +78,7 @@ async fn webfinger(
|
|||
data: Data<DatabaseHandle>,
|
||||
) -> Result<Json<Webfinger>, 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(),
|
||||
|
|
|
@ -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<Regex> =
|
||||
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());
|
||||
|
|
Loading…
Reference in a new issue