fix: delivery passes error up

This commit is contained in:
əlemi 2024-07-06 06:08:58 +02:00
parent 11b4ae8678
commit b086fe969f
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 5 additions and 11 deletions

View file

@ -1,4 +1,3 @@
use sea_orm::EntityTrait;
use reqwest::Method; use reqwest::Method;
use apb::{LD, ActivityMut}; use apb::{LD, ActivityMut};
@ -59,16 +58,11 @@ pub async fn process(ctx: Context, job: &model::job::Model) -> crate::JobResult<
return Ok(()); return Ok(());
}; };
if let Err(e) = Context::request( Context::request(
Method::POST, job.target.as_deref().unwrap_or(""), Method::POST, job.target.as_deref().unwrap_or(""),
Some(&serde_json::to_string(&payload.ld_context()).unwrap()), Some(&serde_json::to_string(&payload.ld_context()).unwrap()),
&job.actor, &key, ctx.domain() &job.actor, &key, ctx.domain()
).await { ).await?;
tracing::warn!("failed delivery of {} to {:?} : {e}", job.activity, job.target);
model::job::Entity::insert(job.clone().repeat(Some(e.to_string())))
.exec(ctx.db())
.await?;
}
Ok(()) Ok(())
} }

View file

@ -17,11 +17,11 @@ pub enum JobError {
#[error("malformed job: missing payload")] #[error("malformed job: missing payload")]
MissingPayload, MissingPayload,
#[error("no available implementation to process job")]
Unprocessable,
#[error("error processing activity: {0:?}")] #[error("error processing activity: {0:?}")]
ProcessorError(#[from] upub::traits::process::ProcessorError), ProcessorError(#[from] upub::traits::process::ProcessorError),
#[error("error delivering activity: {0}")]
DeliveryError(#[from] upub::traits::fetch::RequestError),
} }
pub type JobResult<T> = Result<T, JobError>; pub type JobResult<T> = Result<T, JobError>;