forked from alemi/upub
fix: increase follow counts on Accept
both for inbox and outbox
This commit is contained in:
parent
9cb2acdafd
commit
094a8b957c
3 changed files with 18 additions and 5 deletions
|
@ -27,10 +27,7 @@ impl Identity {
|
|||
}
|
||||
|
||||
pub fn is_anon(&self) -> bool {
|
||||
match self {
|
||||
Self::Anonymous => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(self, Self::Anonymous)
|
||||
}
|
||||
|
||||
pub fn is_user(&self, uid: &str) -> bool {
|
||||
|
|
|
@ -96,6 +96,14 @@ impl apb::server::Inbox for Context {
|
|||
model::activity::Entity::insert(activity_model.clone().into_active_model())
|
||||
.exec(self.db())
|
||||
.await?;
|
||||
model::user::Entity::update_many()
|
||||
.col_expr(
|
||||
model::user::Column::FollowingCount,
|
||||
Expr::col(model::user::Column::FollowingCount).add(1)
|
||||
)
|
||||
.filter(model::user::Column::Id.eq(&follow_activity.actor))
|
||||
.exec(self.db())
|
||||
.await?;
|
||||
model::relation::Entity::insert(
|
||||
model::relation::ActiveModel {
|
||||
follower: Set(follow_activity.actor),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use apb::{target::Addressed, Activity, ActivityMut, BaseMut, Node, ObjectMut};
|
||||
use sea_orm::{EntityTrait, IntoActiveModel, Set};
|
||||
use sea_orm::{sea_query::Expr, ColumnTrait, EntityTrait, IntoActiveModel, QueryFilter, Set};
|
||||
|
||||
use crate::{errors::UpubError, model};
|
||||
|
||||
|
@ -148,6 +148,14 @@ impl apb::server::Outbox for Context {
|
|||
|
||||
match accepted_activity.activity_type {
|
||||
apb::ActivityType::Follow => {
|
||||
model::user::Entity::update_many()
|
||||
.col_expr(
|
||||
model::user::Column::FollowersCount,
|
||||
Expr::col(model::user::Column::FollowersCount).add(1)
|
||||
)
|
||||
.filter(model::user::Column::Id.eq(&uid))
|
||||
.exec(self.db())
|
||||
.await?;
|
||||
model::relation::Entity::insert(
|
||||
model::relation::ActiveModel {
|
||||
follower: Set(accepted_activity.actor), following: Set(uid.clone()),
|
||||
|
|
Loading…
Reference in a new issue