parent
c260c0d5ba
commit
6611debd6b
15 changed files with 0 additions and 137 deletions
|
@ -38,14 +38,6 @@ impl ActivityHandler for Accept {
|
||||||
self.actor.inner()
|
self.actor.inner()
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn verify(
|
|
||||||
&self,
|
|
||||||
_data: &Data<Self::DataType>,
|
|
||||||
_request_counter: &mut i32,
|
|
||||||
) -> Result<(), Self::Error> {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn receive(
|
async fn receive(
|
||||||
self,
|
self,
|
||||||
_data: &Data<Self::DataType>,
|
_data: &Data<Self::DataType>,
|
||||||
|
|
|
@ -50,15 +50,6 @@ impl ActivityHandler for CreateNote {
|
||||||
self.actor.inner()
|
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(
|
async fn receive(
|
||||||
self,
|
self,
|
||||||
data: &Data<Self::DataType>,
|
data: &Data<Self::DataType>,
|
||||||
|
|
|
@ -47,14 +47,6 @@ impl ActivityHandler for Follow {
|
||||||
self.actor.inner()
|
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
|
// Ignore clippy false positive: https://github.com/rust-lang/rust-clippy/issues/6446
|
||||||
#[allow(clippy::await_holding_lock)]
|
#[allow(clippy::await_holding_lock)]
|
||||||
async fn receive(
|
async fn receive(
|
||||||
|
|
|
@ -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(
|
async fn from_apub(
|
||||||
apub: Self::ApubType,
|
apub: Self::ApubType,
|
||||||
data: &Self::DataType,
|
data: &Self::DataType,
|
||||||
|
|
|
@ -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(
|
async fn from_apub(
|
||||||
apub: Self::ApubType,
|
apub: Self::ApubType,
|
||||||
_data: &Self::DataType,
|
_data: &Self::DataType,
|
||||||
|
|
|
@ -38,14 +38,6 @@ impl ActivityHandler for Accept {
|
||||||
self.actor.inner()
|
self.actor.inner()
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn verify(
|
|
||||||
&self,
|
|
||||||
_data: &Data<Self::DataType>,
|
|
||||||
_request_counter: &mut i32,
|
|
||||||
) -> Result<(), Self::Error> {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn receive(
|
async fn receive(
|
||||||
self,
|
self,
|
||||||
_data: &Data<Self::DataType>,
|
_data: &Data<Self::DataType>,
|
||||||
|
|
|
@ -50,15 +50,6 @@ impl ActivityHandler for CreateNote {
|
||||||
self.actor.inner()
|
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(
|
async fn receive(
|
||||||
self,
|
self,
|
||||||
data: &Data<Self::DataType>,
|
data: &Data<Self::DataType>,
|
||||||
|
|
|
@ -47,14 +47,6 @@ impl ActivityHandler for Follow {
|
||||||
self.actor.inner()
|
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
|
// Ignore clippy false positive: https://github.com/rust-lang/rust-clippy/issues/6446
|
||||||
#[allow(clippy::await_holding_lock)]
|
#[allow(clippy::await_holding_lock)]
|
||||||
async fn receive(
|
async fn receive(
|
||||||
|
|
|
@ -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(
|
async fn from_apub(
|
||||||
apub: Self::ApubType,
|
apub: Self::ApubType,
|
||||||
data: &Self::DataType,
|
data: &Self::DataType,
|
||||||
|
|
|
@ -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(
|
async fn from_apub(
|
||||||
apub: Self::ApubType,
|
apub: Self::ApubType,
|
||||||
_data: &Self::DataType,
|
_data: &Self::DataType,
|
||||||
|
|
|
@ -42,9 +42,6 @@ where
|
||||||
actor.public_key(),
|
actor.public_key(),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
debug!("Verifying activity {}", activity.id().to_string());
|
|
||||||
activity.verify(data, request_counter).await?;
|
|
||||||
|
|
||||||
debug!("Receiving activity {}", activity.id().to_string());
|
debug!("Receiving activity {}", activity.id().to_string());
|
||||||
activity.receive(data, request_counter).await?;
|
activity.receive(data, request_counter).await?;
|
||||||
Ok(HttpResponse::Ok().finish())
|
Ok(HttpResponse::Ok().finish())
|
||||||
|
|
|
@ -38,9 +38,6 @@ where
|
||||||
|
|
||||||
verify_signature(&headers, &method, &uri, actor.public_key())?;
|
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());
|
debug!("Receiving activity {}", activity.id().to_string());
|
||||||
activity.receive(data, request_counter).await?;
|
activity.receive(data, request_counter).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -118,7 +118,6 @@ where
|
||||||
|
|
||||||
let res2 = res?;
|
let res2 = res?;
|
||||||
|
|
||||||
Kind::verify(&res2, self.inner(), data, request_counter).await?;
|
|
||||||
Kind::from_apub(res2, data, request_counter).await
|
Kind::from_apub(res2, data, request_counter).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,15 +215,6 @@ mod tests {
|
||||||
todo!()
|
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(
|
async fn from_apub(
|
||||||
_apub: Self::ApubType,
|
_apub: Self::ApubType,
|
||||||
_data: &Self::DataType,
|
_data: &Self::DataType,
|
||||||
|
|
|
@ -44,14 +44,6 @@ where
|
||||||
self.inner.actor()
|
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(
|
async fn receive(
|
||||||
self,
|
self,
|
||||||
data: &Data<Self::DataType>,
|
data: &Data<Self::DataType>,
|
||||||
|
|
|
@ -16,15 +16,6 @@ pub trait ActivityHandler {
|
||||||
/// `actor` field of activity
|
/// `actor` field of activity
|
||||||
fn actor(&self) -> &Url;
|
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.
|
/// Receives the activity and stores its action in database.
|
||||||
async fn receive(
|
async fn receive(
|
||||||
self,
|
self,
|
||||||
|
@ -50,14 +41,6 @@ where
|
||||||
self.deref().actor()
|
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(
|
async fn receive(
|
||||||
self,
|
self,
|
||||||
data: &Data<Self::DataType>,
|
data: &Data<Self::DataType>,
|
||||||
|
@ -100,16 +83,6 @@ pub trait ApubObject {
|
||||||
/// Trait for converting an object or actor into the respective ActivityPub type.
|
/// 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>;
|
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.
|
/// Converts an object from ActivityPub type to Lemmy internal type.
|
||||||
///
|
///
|
||||||
/// * `apub` The object to read from
|
/// * `apub` The object to read from
|
||||||
|
|
Loading…
Reference in a new issue