Remove verify methods (fixes #15) (#21)

This commit is contained in:
Nutomic 2023-01-16 22:54:23 +01:00 committed by GitHub
parent c260c0d5ba
commit 6611debd6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 0 additions and 137 deletions

View file

@ -38,14 +38,6 @@ impl ActivityHandler for Accept {
self.actor.inner()
}
async fn verify(
&self,
_data: &Data<Self::DataType>,
_request_counter: &mut i32,
) -> Result<(), Self::Error> {
Ok(())
}
async fn receive(
self,
_data: &Data<Self::DataType>,

View file

@ -50,15 +50,6 @@ impl ActivityHandler for CreateNote {
self.actor.inner()
}
async fn verify(
&self,
data: &Data<Self::DataType>,
request_counter: &mut i32,
) -> Result<(), Self::Error> {
MyPost::verify(&self.object, self.id(), data, request_counter).await?;
Ok(())
}
async fn receive(
self,
data: &Data<Self::DataType>,

View file

@ -47,14 +47,6 @@ impl ActivityHandler for Follow {
self.actor.inner()
}
async fn verify(
&self,
_data: &Data<Self::DataType>,
_request_counter: &mut i32,
) -> Result<(), Self::Error> {
Ok(())
}
// Ignore clippy false positive: https://github.com/rust-lang/rust-clippy/issues/6446
#[allow(clippy::await_holding_lock)]
async fn receive(

View file

@ -64,15 +64,6 @@ impl ApubObject for MyPost {
})
}
async fn verify(
_apub: &Self::ApubType,
_expected_domain: &Url,
_data: &Self::DataType,
_request_counter: &mut i32,
) -> Result<(), Self::Error> {
Ok(())
}
async fn from_apub(
apub: Self::ApubType,
data: &Self::DataType,

View file

@ -159,15 +159,6 @@ impl ApubObject for MyUser {
})
}
async fn verify(
_apub: &Self::ApubType,
_expected_domain: &Url,
_data: &Self::DataType,
_request_counter: &mut i32,
) -> Result<(), Self::Error> {
Ok(())
}
async fn from_apub(
apub: Self::ApubType,
_data: &Self::DataType,

View file

@ -38,14 +38,6 @@ impl ActivityHandler for Accept {
self.actor.inner()
}
async fn verify(
&self,
_data: &Data<Self::DataType>,
_request_counter: &mut i32,
) -> Result<(), Self::Error> {
Ok(())
}
async fn receive(
self,
_data: &Data<Self::DataType>,

View file

@ -50,15 +50,6 @@ impl ActivityHandler for CreateNote {
self.actor.inner()
}
async fn verify(
&self,
data: &Data<Self::DataType>,
request_counter: &mut i32,
) -> Result<(), Self::Error> {
MyPost::verify(&self.object, self.id(), data, request_counter).await?;
Ok(())
}
async fn receive(
self,
data: &Data<Self::DataType>,

View file

@ -47,14 +47,6 @@ impl ActivityHandler for Follow {
self.actor.inner()
}
async fn verify(
&self,
_data: &Data<Self::DataType>,
_request_counter: &mut i32,
) -> Result<(), Self::Error> {
Ok(())
}
// Ignore clippy false positive: https://github.com/rust-lang/rust-clippy/issues/6446
#[allow(clippy::await_holding_lock)]
async fn receive(

View file

@ -64,15 +64,6 @@ impl ApubObject for MyPost {
})
}
async fn verify(
_apub: &Self::ApubType,
_expected_domain: &Url,
_data: &Self::DataType,
_request_counter: &mut i32,
) -> Result<(), Self::Error> {
Ok(())
}
async fn from_apub(
apub: Self::ApubType,
data: &Self::DataType,

View file

@ -159,15 +159,6 @@ impl ApubObject for MyUser {
})
}
async fn verify(
_apub: &Self::ApubType,
_expected_domain: &Url,
_data: &Self::DataType,
_request_counter: &mut i32,
) -> Result<(), Self::Error> {
Ok(())
}
async fn from_apub(
apub: Self::ApubType,
_data: &Self::DataType,

View file

@ -42,9 +42,6 @@ where
actor.public_key(),
)?;
debug!("Verifying activity {}", activity.id().to_string());
activity.verify(data, request_counter).await?;
debug!("Receiving activity {}", activity.id().to_string());
activity.receive(data, request_counter).await?;
Ok(HttpResponse::Ok().finish())

View file

@ -38,9 +38,6 @@ where
verify_signature(&headers, &method, &uri, actor.public_key())?;
debug!("Verifying activity {}", activity.id().to_string());
activity.verify(data, request_counter).await?;
debug!("Receiving activity {}", activity.id().to_string());
activity.receive(data, request_counter).await?;
Ok(())

View file

@ -118,7 +118,6 @@ where
let res2 = res?;
Kind::verify(&res2, self.inner(), data, request_counter).await?;
Kind::from_apub(res2, data, request_counter).await
}
}
@ -216,15 +215,6 @@ mod tests {
todo!()
}
async fn verify(
_apub: &Self::ApubType,
_expected_domain: &Url,
_data: &Self::DataType,
_request_counter: &mut i32,
) -> Result<(), Self::Error> {
todo!()
}
async fn from_apub(
_apub: Self::ApubType,
_data: &Self::DataType,

View file

@ -44,14 +44,6 @@ where
self.inner.actor()
}
async fn verify(
&self,
data: &Data<Self::DataType>,
request_counter: &mut i32,
) -> Result<(), Self::Error> {
self.inner.verify(data, request_counter).await
}
async fn receive(
self,
data: &Data<Self::DataType>,

View file

@ -16,15 +16,6 @@ pub trait ActivityHandler {
/// `actor` field of activity
fn actor(&self) -> &Url;
/// Verify that the activity is valid. If this method returns an error, the activity will be
/// discarded. This is separate from receive(), so that it can be called recursively on nested
/// objects, without storing something in the database by accident.
async fn verify(
&self,
data: &Data<Self::DataType>,
request_counter: &mut i32,
) -> Result<(), Self::Error>;
/// Receives the activity and stores its action in database.
async fn receive(
self,
@ -50,14 +41,6 @@ where
self.deref().actor()
}
async fn verify(
&self,
data: &Data<Self::DataType>,
request_counter: &mut i32,
) -> Result<(), Self::Error> {
self.deref().verify(data, request_counter).await
}
async fn receive(
self,
data: &Data<Self::DataType>,
@ -100,16 +83,6 @@ pub trait ApubObject {
/// Trait for converting an object or actor into the respective ActivityPub type.
async fn into_apub(self, data: &Self::DataType) -> Result<Self::ApubType, Self::Error>;
/// Verify that the object is valid. If this method returns an error, it will be
/// discarded. This is separate from from_apub(), so that it can be called recursively on nested
/// objects, without storing something in the database by accident.
async fn verify(
apub: &Self::ApubType,
expected_domain: &Url,
data: &Self::DataType,
request_counter: &mut i32,
) -> Result<(), Self::Error>;
/// Converts an object from ActivityPub type to Lemmy internal type.
///
/// * `apub` The object to read from