1
0
Fork 0
forked from alemi/upub

fix: maybe must be unchanged?

This commit is contained in:
əlemi 2024-06-10 06:34:13 +02:00
parent e7acc420f1
commit 2d08511e05
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 6 additions and 3 deletions

View file

@ -1,5 +1,5 @@
use apb::{target::Addressed, Activity, Base, Object};
use sea_orm::{sea_query::Expr, ActiveValue::{NotSet, Set}, ColumnTrait, Condition, DatabaseTransaction, EntityTrait, QueryFilter, QuerySelect, SelectColumns};
use sea_orm::{sea_query::Expr, ActiveValue::{NotSet, Set, Unchanged}, ColumnTrait, Condition, DatabaseTransaction, EntityTrait, QueryFilter, QuerySelect, SelectColumns};
use crate::{ext::{AnyQuery, LoggableError}, model, traits::{fetch::Pull, Fetcher, Normalizer}};
#[derive(Debug, thiserror::Error)]
@ -263,7 +263,7 @@ pub async fn update(ctx: &crate::Context, activity: impl apb::Activity, tx: &Dat
.await?
.ok_or(ProcessorError::Incomplete)?;
let mut actor_model = crate::AP::actor_q(object_node.as_actor()?)?;
actor_model.internal = Set(internal_uid);
actor_model.internal = Unchanged(internal_uid);
actor_model.updated = Set(chrono::Utc::now());
crate::model::actor::Entity::update(actor_model)
.exec(tx)
@ -274,7 +274,7 @@ pub async fn update(ctx: &crate::Context, activity: impl apb::Activity, tx: &Dat
.await?
.ok_or(ProcessorError::Incomplete)?;
let mut object_model = crate::AP::object_q(&object_node)?;
object_model.internal = Set(internal_oid);
object_model.internal = Unchanged(internal_oid);
object_model.updated = Set(chrono::Utc::now());
crate::model::object::Entity::update(object_model)
.exec(tx)

View file

@ -62,6 +62,9 @@ pub async fn process(ctx: Context, job: &model::job::Model) -> crate::JobResult<
));
}
// TODO very important that we limit Update activities!!! otherwise with .process() local users
// can change their document completely
let targets = activity.addressed();
ctx.process(activity, &tx).await?;
ctx.deliver(targets, &job.activity, &job.actor, &tx).await?;