Return deleted object on resolve (#149)

This commit is contained in:
Nutomic 2025-10-02 09:30:12 +00:00 committed by GitHub
parent 6c97312f25
commit 1df24ab781
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 18 additions and 17 deletions

View file

@ -22,7 +22,7 @@ pub async fn receive_activity<A, ActorT, Datatype>(
) -> Result<HttpResponse, <A as Activity>::Error> ) -> Result<HttpResponse, <A as Activity>::Error>
where where
A: Activity<DataType = Datatype> + DeserializeOwned + Send + 'static, A: Activity<DataType = Datatype> + DeserializeOwned + Send + 'static,
ActorT: Object<DataType = Datatype> + Actor + Send + 'static, ActorT: Object<DataType = Datatype> + Actor + Send + Sync + 'static,
for<'de2> <ActorT as Object>::Kind: serde::Deserialize<'de2>, for<'de2> <ActorT as Object>::Kind: serde::Deserialize<'de2>,
<A as Activity>::Error: From<Error> + From<<ActorT as Object>::Error>, <A as Activity>::Error: From<Error> + From<<ActorT as Object>::Error>,
<ActorT as Object>::Error: From<Error>, <ActorT as Object>::Error: From<Error>,
@ -62,7 +62,7 @@ pub async fn receive_activity_with_hook<A, ActorT, Datatype>(
) -> Result<HttpResponse, <A as Activity>::Error> ) -> Result<HttpResponse, <A as Activity>::Error>
where where
A: Activity<DataType = Datatype> + DeserializeOwned + Send + Clone + 'static, A: Activity<DataType = Datatype> + DeserializeOwned + Send + Clone + 'static,
ActorT: Object<DataType = Datatype> + Actor + Send + Clone + 'static, ActorT: Object<DataType = Datatype> + Actor + Send + Sync + Clone + 'static,
for<'de2> <ActorT as Object>::Kind: serde::Deserialize<'de2>, for<'de2> <ActorT as Object>::Kind: serde::Deserialize<'de2>,
<A as Activity>::Error: From<Error> + From<<ActorT as Object>::Error>, <A as Activity>::Error: From<Error> + From<<ActorT as Object>::Error>,
<ActorT as Object>::Error: From<Error>, <ActorT as Object>::Error: From<Error>,
@ -82,7 +82,7 @@ async fn do_stuff<A, ActorT, Datatype>(
) -> Result<(A, ActorT), <A as Activity>::Error> ) -> Result<(A, ActorT), <A as Activity>::Error>
where where
A: Activity<DataType = Datatype> + DeserializeOwned + Send + 'static, A: Activity<DataType = Datatype> + DeserializeOwned + Send + 'static,
ActorT: Object<DataType = Datatype> + Actor + Send + 'static, ActorT: Object<DataType = Datatype> + Actor + Send + Sync + 'static,
for<'de2> <ActorT as Object>::Kind: serde::Deserialize<'de2>, for<'de2> <ActorT as Object>::Kind: serde::Deserialize<'de2>,
<A as Activity>::Error: From<Error> + From<<ActorT as Object>::Error>, <A as Activity>::Error: From<Error> + From<<ActorT as Object>::Error>,
<ActorT as Object>::Error: From<Error>, <ActorT as Object>::Error: From<Error>,

View file

@ -23,7 +23,7 @@ pub async fn signing_actor<A>(
data: &Data<<A as Object>::DataType>, data: &Data<<A as Object>::DataType>,
) -> Result<A, <A as Object>::Error> ) -> Result<A, <A as Object>::Error>
where where
A: Object + Actor, A: Object + Actor + Send + Sync,
<A as Object>::Error: From<Error>, <A as Object>::Error: From<Error>,
for<'de2> <A as Object>::Kind: Deserialize<'de2>, for<'de2> <A as Object>::Kind: Deserialize<'de2>,
{ {

View file

@ -26,7 +26,7 @@ pub async fn receive_activity<A, ActorT, Datatype>(
) -> Result<(), <A as Activity>::Error> ) -> Result<(), <A as Activity>::Error>
where where
A: Activity<DataType = Datatype> + DeserializeOwned + Send + 'static, A: Activity<DataType = Datatype> + DeserializeOwned + Send + 'static,
ActorT: Object<DataType = Datatype> + Actor + Send + 'static, ActorT: Object<DataType = Datatype> + Actor + Send + Sync + 'static,
for<'de2> <ActorT as Object>::Kind: serde::Deserialize<'de2>, for<'de2> <ActorT as Object>::Kind: serde::Deserialize<'de2>,
<A as Activity>::Error: From<Error> + From<<ActorT as Object>::Error>, <A as Activity>::Error: From<Error> + From<<ActorT as Object>::Error>,
<ActorT as Object>::Error: From<Error>, <ActorT as Object>::Error: From<Error>,

View file

@ -10,7 +10,7 @@ use url::Url;
impl<T> FromStr for ObjectId<T> impl<T> FromStr for ObjectId<T>
where where
T: Object + Send + Debug + 'static, T: Object + Send + Sync + Debug + 'static,
for<'de2> <T as Object>::Kind: Deserialize<'de2>, for<'de2> <T as Object>::Kind: Deserialize<'de2>,
{ {
type Err = url::ParseError; type Err = url::ParseError;
@ -61,7 +61,7 @@ where
impl<Kind> ObjectId<Kind> impl<Kind> ObjectId<Kind>
where where
Kind: Object + Send + Debug + 'static, Kind: Object + Send + Sync + Debug + 'static,
for<'de2> <Kind as Object>::Kind: Deserialize<'de2>, for<'de2> <Kind as Object>::Kind: Deserialize<'de2>,
{ {
/// Construct a new objectid instance /// Construct a new objectid instance
@ -164,6 +164,7 @@ where
if let Err(Error::ObjectDeleted(url)) = res { if let Err(Error::ObjectDeleted(url)) = res {
if let Some(db_object) = db_object { if let Some(db_object) = db_object {
db_object.delete(data).await?; db_object.delete(data).await?;
return Ok(db_object);
} }
return Err(Error::ObjectDeleted(url).into()); return Err(Error::ObjectDeleted(url).into());
} }

View file

@ -45,7 +45,7 @@ pub async fn webfinger_resolve_actor<T: Clone, Kind>(
data: &Data<T>, data: &Data<T>,
) -> Result<Kind, <Kind as Object>::Error> ) -> Result<Kind, <Kind as Object>::Error>
where where
Kind: Object + Actor + Send + 'static + Object<DataType = T>, Kind: Object + Actor + Send + Sync + 'static + Object<DataType = T>,
for<'de2> <Kind as Object>::Kind: serde::Deserialize<'de2>, for<'de2> <Kind as Object>::Kind: serde::Deserialize<'de2>,
<Kind as Object>::Error: From<crate::error::Error> + Send + Sync + Display, <Kind as Object>::Error: From<crate::error::Error> + Send + Sync + Display,
{ {

View file

@ -149,7 +149,7 @@ pub(crate) async fn signing_actor<'a, A, H>(
data: &Data<<A as Object>::DataType>, data: &Data<<A as Object>::DataType>,
) -> Result<A, <A as Object>::Error> ) -> Result<A, <A as Object>::Error>
where where
A: Object + Actor, A: Object + Actor + Send + Sync,
<A as Object>::Error: From<Error>, <A as Object>::Error: From<Error>,
for<'de2> <A as Object>::Kind: Deserialize<'de2>, for<'de2> <A as Object>::Kind: Deserialize<'de2>,
H: IntoIterator<Item = (&'a HeaderName, &'a HeaderValue)>, H: IntoIterator<Item = (&'a HeaderName, &'a HeaderValue)>,

View file

@ -46,7 +46,7 @@ async fn parse_received_activity<A, ActorT, Datatype>(
) -> Result<(A, ActorT), <A as Activity>::Error> ) -> Result<(A, ActorT), <A as Activity>::Error>
where where
A: Activity<DataType = Datatype> + DeserializeOwned + Send + 'static, A: Activity<DataType = Datatype> + DeserializeOwned + Send + 'static,
ActorT: Object<DataType = Datatype> + Actor + Send + 'static, ActorT: Object<DataType = Datatype> + Actor + Send + Sync + 'static,
for<'de2> <ActorT as Object>::Kind: serde::Deserialize<'de2>, for<'de2> <ActorT as Object>::Kind: serde::Deserialize<'de2>,
<A as Activity>::Error: From<Error> + From<<ActorT as Object>::Error>, <A as Activity>::Error: From<Error> + From<<ActorT as Object>::Error>,
<ActorT as Object>::Error: From<Error>, <ActorT as Object>::Error: From<Error>,

View file

@ -63,7 +63,7 @@ pub fn verify_is_remote_object<Kind, R: Clone>(
data: &Data<<Kind as Object>::DataType>, data: &Data<<Kind as Object>::DataType>,
) -> Result<(), Error> ) -> Result<(), Error>
where where
Kind: Object<DataType = R> + Send + 'static, Kind: Object<DataType = R> + Send + Sync + 'static,
for<'de2> <Kind as Object>::Kind: Deserialize<'de2>, for<'de2> <Kind as Object>::Kind: Deserialize<'de2>,
{ {
if id.is_local(data) { if id.is_local(data) {

View file

@ -18,8 +18,8 @@ pub enum UntaggedEither<L, R> {
#[async_trait] #[async_trait]
impl<T, R, E, D> Object for Either<T, R> impl<T, R, E, D> Object for Either<T, R>
where where
T: Object + Object<Error = E, DataType = D> + Send, T: Object + Object<Error = E, DataType = D> + Send + Sync,
R: Object + Object<Error = E, DataType = D> + Send, R: Object + Object<Error = E, DataType = D> + Send + Sync,
<T as Object>::Kind: Send + Sync, <T as Object>::Kind: Send + Sync,
<R as Object>::Kind: Send + Sync, <R as Object>::Kind: Send + Sync,
D: Sync + Send + Clone, D: Sync + Send + Clone,
@ -59,7 +59,7 @@ where
Ok(None) Ok(None)
} }
async fn delete(self, data: &Data<Self::DataType>) -> Result<(), Self::Error> { async fn delete(&self, data: &Data<Self::DataType>) -> Result<(), Self::Error> {
match self { match self {
Either::Left(l) => l.delete(data).await, Either::Left(l) => l.delete(data).await,
Either::Right(r) => r.delete(data).await, Either::Right(r) => r.delete(data).await,
@ -103,8 +103,8 @@ where
#[async_trait] #[async_trait]
impl<T, R, E, D> Actor for Either<T, R> impl<T, R, E, D> Actor for Either<T, R>
where where
T: Actor + Object + Object<Error = E, DataType = D> + Send + 'static, T: Actor + Object + Object<Error = E, DataType = D> + Send + Sync + 'static,
R: Actor + Object + Object<Error = E, DataType = D> + Send + 'static, R: Actor + Object + Object<Error = E, DataType = D> + Send + Sync + 'static,
<T as Object>::Kind: Send + Sync, <T as Object>::Kind: Send + Sync,
<R as Object>::Kind: Send + Sync, <R as Object>::Kind: Send + Sync,
D: Sync + Send + Clone, D: Sync + Send + Clone,

View file

@ -136,7 +136,7 @@ pub trait Object: Sized + Debug {
/// Mark remote object as deleted in local database. /// Mark remote object as deleted in local database.
/// ///
/// Called when a `Delete` activity is received, or if fetch returns a `Tombstone` object. /// Called when a `Delete` activity is received, or if fetch returns a `Tombstone` object.
async fn delete(self, _data: &Data<Self::DataType>) -> Result<(), Self::Error> { async fn delete(&self, _data: &Data<Self::DataType>) -> Result<(), Self::Error> {
Ok(()) Ok(())
} }