From 2d08511e0577ff63b9ef9e9bf890cd432c646c36 Mon Sep 17 00:00:00 2001 From: alemi Date: Mon, 10 Jun 2024 06:34:13 +0200 Subject: [PATCH] fix: maybe must be unchanged? --- upub/core/src/traits/process.rs | 6 +++--- upub/worker/src/outbound.rs | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/upub/core/src/traits/process.rs b/upub/core/src/traits/process.rs index 2e4eef44..4ad0689c 100644 --- a/upub/core/src/traits/process.rs +++ b/upub/core/src/traits/process.rs @@ -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) diff --git a/upub/worker/src/outbound.rs b/upub/worker/src/outbound.rs index f2b97612..8cfb7839 100644 --- a/upub/worker/src/outbound.rs +++ b/upub/worker/src/outbound.rs @@ -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?;