fix: dont reset followers/ing count on user update

This commit is contained in:
əlemi 2025-01-15 02:56:52 +01:00
parent d3987680d8
commit abffac146b
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -1,4 +1,4 @@
use apb::{target::Addressed, Activity, ActivityMut, Base, BaseMut, Object, ObjectMut, Shortcuts}; use apb::{target::Addressed, Activity, ActivityMut, ActorMut, Base, BaseMut, Object, ObjectMut, Shortcuts};
use sea_orm::{prelude::Expr, 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::{process::ProcessorError, Addresser, Processor}, Context}; use upub::{model::{self, actor::Field}, traits::{process::ProcessorError, Addresser, Processor}, Context};
@ -101,7 +101,15 @@ pub async fn process(ctx: Context, job: &model::job::Model) -> crate::JobResult<
.into(); .into();
} }
updated = ctx.ap(prev); // TODO ughhh since following/followers count are sensitive we hide them inside the .ap()
// method, but this means here we end up with these set to 0 here! every time any
// local user updates their profile, they also reset their followers/following
// counters... not great! so we have to overwrite _back_ the counts here so that they
// don't get set to 0 later. this is a ridicolous design and a comically bad botch....
let (following_count, followers_count) = (prev.following_count as u64, prev.followers_count as u64);
updated = ctx.ap(prev)
.set_following_count(Some(following_count))
.set_followers_count(Some(followers_count));
}, },
apb::ObjectType::Note => { apb::ObjectType::Note => {
let mut prev = model::object::Entity::find_by_ap_id(&updated.id()?) let mut prev = model::object::Entity::find_by_ap_id(&updated.id()?)