1
0
Fork 0
forked from alemi/upub

fix: increase replies counts from local replies

This commit is contained in:
əlemi 2024-05-02 16:35:46 +02:00
parent 34df958af0
commit 1ab351cc7f
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -33,6 +33,7 @@ impl apb::server::Outbox for Context {
object_model.context = Some(crate::url!(self, "/context/{}", uuid::Uuid::new_v4().to_string())),
(_, Some(_)) => {}, // leave it as set by user
}
let reply_to = object_model.in_reply_to.clone();
let activity_model = model::activity::Model {
id: aid.clone(),
@ -56,6 +57,13 @@ impl apb::server::Outbox for Context {
.filter(model::user::Column::Id.eq(&uid))
.exec(self.db())
.await?;
if let Some(reply_to) = reply_to {
model::object::Entity::update_many()
.filter(model::object::Column::Id.eq(reply_to))
.col_expr(model::object::Column::Comments, Expr::col(model::object::Column::Comments).add(1))
.exec(self.db())
.await?;
}
self.dispatch(&uid, activity_targets, &aid, Some(&oid)).await?;
@ -97,6 +105,7 @@ impl apb::server::Outbox for Context {
object_model.context = Some(crate::url!(self, "/context/{}", uuid::Uuid::new_v4().to_string())),
(_, Some(_)) => {}, // leave it as set by user
}
let reply_to = object_model.in_reply_to.clone();
model::object::Entity::insert(object_model.into_active_model())
.exec(self.db()).await?;
@ -107,6 +116,13 @@ impl apb::server::Outbox for Context {
.filter(model::user::Column::Id.eq(&uid))
.exec(self.db())
.await?;
if let Some(reply_to) = reply_to {
model::object::Entity::update_many()
.filter(model::object::Column::Id.eq(reply_to))
.col_expr(model::object::Column::Comments, Expr::col(model::object::Column::Comments).add(1))
.exec(self.db())
.await?;
}
self.dispatch(&uid, activity_targets, &aid, Some(&oid)).await?;