1
0
Fork 0
forked from alemi/upub

fix: set updated in outgoing notes

This commit is contained in:
əlemi 2024-06-23 17:06:48 +02:00
parent 4a3a2e2647
commit fc744e7604
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -5,6 +5,7 @@ use upub::{model, traits::{Addresser, Processor}, Context};
pub async fn process(ctx: Context, job: &model::job::Model) -> crate::JobResult<()> { pub async fn process(ctx: Context, job: &model::job::Model) -> crate::JobResult<()> {
// TODO can we get rid of this cloned?? // TODO can we get rid of this cloned??
let now = chrono::Utc::now();
let mut activity = job.payload.as_ref().cloned().ok_or(crate::JobError::MissingPayload)?; let mut activity = job.payload.as_ref().cloned().ok_or(crate::JobError::MissingPayload)?;
let mut t = activity.object_type()?; let mut t = activity.object_type()?;
let tx = ctx.db().begin().await?; let tx = ctx.db().begin().await?;
@ -23,7 +24,7 @@ pub async fn process(ctx: Context, job: &model::job::Model) -> crate::JobResult<
activity = activity activity = activity
.set_id(Some(&job.activity)) .set_id(Some(&job.activity))
.set_actor(apb::Node::link(job.actor.clone())) .set_actor(apb::Node::link(job.actor.clone()))
.set_published(Some(chrono::Utc::now())); .set_published(Some(now));
if matches!(t, apb::ObjectType::Activity(apb::ActivityType::Create)) { if matches!(t, apb::ObjectType::Activity(apb::ActivityType::Create)) {
let raw_oid = Context::new_id(); let raw_oid = Context::new_id();
@ -57,7 +58,8 @@ pub async fn process(ctx: Context, job: &model::job::Model) -> crate::JobResult<
.set_id(Some(&oid)) .set_id(Some(&oid))
.set_content(content.as_deref()) .set_content(content.as_deref())
.set_attributed_to(apb::Node::link(job.actor.clone())) .set_attributed_to(apb::Node::link(job.actor.clone()))
.set_published(Some(chrono::Utc::now())) .set_published(Some(now))
.set_updated(Some(now))
.set_url(apb::Node::maybe_link(ctx.cfg().frontend_url(&format!("/objects/{raw_oid}")))), .set_url(apb::Node::maybe_link(ctx.cfg().frontend_url(&format!("/objects/{raw_oid}")))),
)); ));
} }