mirror of
https://github.com/LemmyNet/activitypub-federation-rust.git
synced 2025-03-13 18:52:39 +00:00
more fix
This commit is contained in:
parent
451d388833
commit
47bfde132c
5 changed files with 10 additions and 4 deletions
|
@ -29,7 +29,7 @@ pub async fn new_instance(
|
|||
.signed_fetch_actor(&system_user)
|
||||
.app_data(database)
|
||||
.url_verifier(Box::new(MyUrlVerifier()))
|
||||
.debug(false)
|
||||
.debug(true)
|
||||
.build()
|
||||
.await?;
|
||||
Ok(config)
|
||||
|
|
|
@ -136,8 +136,8 @@ impl SendActivityTask {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn build_tasks<'a, Activity, Datatype, ActorType>(
|
||||
activity: &'a Activity,
|
||||
pub(crate) async fn build_tasks<Activity, Datatype, ActorType>(
|
||||
activity: &Activity,
|
||||
actor: &ActorType,
|
||||
inboxes: Vec<Url>,
|
||||
data: &Data<Datatype>,
|
||||
|
|
|
@ -360,6 +360,7 @@ const _IMPL_DIESEL_NEW_TYPE_FOR_OBJECT_ID: () = {
|
|||
}
|
||||
};
|
||||
|
||||
/// Shared test code
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::unwrap_used)]
|
||||
pub mod tests {
|
||||
|
|
|
@ -57,9 +57,12 @@ where
|
|||
.splitn(2, '@')
|
||||
.collect_tuple()
|
||||
.ok_or(WebFingerError::WrongFormat.into_crate_error())?;
|
||||
if !DOMAIN_REGEX.is_match(domain) {
|
||||
|
||||
// For production mode make sure that domain doesnt contain any port or path.
|
||||
if !data.config.debug && !DOMAIN_REGEX.is_match(domain) {
|
||||
return Err(Error::UrlVerificationError("Invalid characters in domain").into());
|
||||
}
|
||||
|
||||
let protocol = if data.config.debug { "http" } else { "https" };
|
||||
let fetch_url =
|
||||
format!("{protocol}://{domain}/.well-known/webfinger?resource=acct:{identifier}");
|
||||
|
|
|
@ -277,6 +277,7 @@ pub(crate) fn verify_body_hash(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Shared test code
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::unwrap_used)]
|
||||
pub mod test {
|
||||
|
@ -378,6 +379,7 @@ pub mod test {
|
|||
assert_eq!(invalid, Err(Error::ActivityBodyDigestInvalid));
|
||||
}
|
||||
|
||||
/// Return hardcoded keypair
|
||||
pub fn test_keypair() -> Keypair {
|
||||
let rsa = RsaPrivateKey::from_pkcs1_pem(PRIVATE_KEY).unwrap();
|
||||
let pkey = RsaPublicKey::from(&rsa);
|
||||
|
|
Loading…
Reference in a new issue