fix: must do it with an update_many
aaaaaaaaaaaaa
This commit is contained in:
parent
52933da820
commit
ea6fedf34e
1 changed files with 6 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
||||||
use apb::{field::OptionalString, target::Addressed, Activity, ActivityMut, Actor, Base, BaseMut, Object, ObjectMut};
|
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};
|
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)
|
let activity = upub::model::activity::Entity::ap_to_internal(activity.object().id()?, &tx)
|
||||||
.await?
|
.await?
|
||||||
.ok_or_else(|| DbErr::RecordNotFound(activity.object().id().unwrap_or_default().to_string()))?;
|
.ok_or_else(|| DbErr::RecordNotFound(activity.object().id().unwrap_or_default().to_string()))?;
|
||||||
let notif_model = upub::model::notification::ActiveModel {
|
upub::model::notification::Entity::update_many()
|
||||||
internal: sea_orm::ActiveValue::NotSet,
|
.filter(upub::model::notification::Column::Activity.eq(activity))
|
||||||
activity: sea_orm::ActiveValue::Unchanged(activity),
|
.filter(upub::model::notification::Column::Actor.eq(actor))
|
||||||
actor: sea_orm::ActiveValue::Unchanged(actor),
|
.col_expr(upub::model::notification::Column::Seen, Expr::value(true))
|
||||||
seen: sea_orm::ActiveValue::Set(true),
|
.exec(&tx).await?;
|
||||||
published: sea_orm::ActiveValue::NotSet,
|
|
||||||
};
|
|
||||||
upub::model::notification::Entity::update(notif_model).exec(&tx).await?;
|
|
||||||
tx.commit().await?;
|
tx.commit().await?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue