From ea6fedf34e63a7db7b6bbe61304a2aa257bacc1d Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 15 Aug 2024 05:48:01 +0200 Subject: [PATCH] fix: must do it with an update_many aaaaaaaaaaaaa --- upub/worker/src/outbound.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/upub/worker/src/outbound.rs b/upub/worker/src/outbound.rs index 1cfb676..4bd9339 100644 --- a/upub/worker/src/outbound.rs +++ b/upub/worker/src/outbound.rs @@ -1,5 +1,5 @@ use apb::{field::OptionalString, target::Addressed, Activity, ActivityMut, Actor, Base, BaseMut, Object, ObjectMut}; -use sea_orm::{ColumnTrait, DbErr, EntityTrait, QueryFilter, QueryOrder, QuerySelect, SelectColumns, TransactionTrait}; +use sea_orm::{prelude::Expr, ColumnTrait, DbErr, EntityTrait, QueryFilter, QueryOrder, QuerySelect, SelectColumns, TransactionTrait}; use upub::{model::{self, actor::Field}, traits::{Addresser, Processor}, Context}; @@ -20,14 +20,11 @@ pub async fn process(ctx: Context, job: &model::job::Model) -> crate::JobResult< let activity = upub::model::activity::Entity::ap_to_internal(activity.object().id()?, &tx) .await? .ok_or_else(|| DbErr::RecordNotFound(activity.object().id().unwrap_or_default().to_string()))?; - let notif_model = upub::model::notification::ActiveModel { - internal: sea_orm::ActiveValue::NotSet, - activity: sea_orm::ActiveValue::Unchanged(activity), - actor: sea_orm::ActiveValue::Unchanged(actor), - seen: sea_orm::ActiveValue::Set(true), - published: sea_orm::ActiveValue::NotSet, - }; - upub::model::notification::Entity::update(notif_model).exec(&tx).await?; + upub::model::notification::Entity::update_many() + .filter(upub::model::notification::Column::Activity.eq(activity)) + .filter(upub::model::notification::Column::Actor.eq(actor)) + .col_expr(upub::model::notification::Column::Seen, Expr::value(true)) + .exec(&tx).await?; tx.commit().await?; return Ok(()); }