From e636afd28396d716316d72c9fee40766dc1f691e Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 30 May 2024 22:16:48 +0200 Subject: [PATCH] fix: only count announces from persons --- src/server/context.rs | 4 +++- src/server/inbox.rs | 5 ++--- src/server/normalizer.rs | 2 -- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/server/context.rs b/src/server/context.rs index d34da73c..7e1796f1 100644 --- a/src/server/context.rs +++ b/src/server/context.rs @@ -21,9 +21,10 @@ struct ContextInner { actor: model::actor::Model, instance: model::instance::Model, pkey: String, - relay: Relays, + #[allow(unused)] relay: Relays, } +#[allow(unused)] pub struct Relays { sources: BTreeSet, sinks: BTreeSet, @@ -178,6 +179,7 @@ impl Context { .await } + #[allow(unused)] pub fn is_relay(&self, id: &str) -> bool { self.0.relay.sources.contains(id) || self.0.relay.sinks.contains(id) } diff --git a/src/server/inbox.rs b/src/server/inbox.rs index ad7f186f..5aaa5309 100644 --- a/src/server/inbox.rs +++ b/src/server/inbox.rs @@ -1,6 +1,5 @@ use apb::{target::Addressed, Activity, Base, Object}; -use reqwest::StatusCode; -use sea_orm::{sea_query::Expr, ActiveValue::{Set, NotSet}, ColumnTrait, Condition, EntityTrait, QueryFilter, QuerySelect, SelectColumns}; +use sea_orm::{sea_query::Expr, ActiveValue::{Set, NotSet}, ColumnTrait, EntityTrait, QueryFilter, QuerySelect, SelectColumns}; use crate::{errors::{LoggableError, UpubError}, model, server::{addresser::Addresser, builders::AnyQuery, normalizer::Normalizer}}; @@ -267,7 +266,7 @@ impl apb::server::Inbox for Context { let announced = self.fetch_object(&announced_id).await?; // relays send us activities as Announce, but we don't really want to count those towards the // total shares count of an object, so just fetch the object and be done with it - if self.is_relay(&activity_model.actor) { + if matches!(actor.actor_type, apb::ActorType::Person) { tracing::info!("relay {} broadcasted {}", activity_model.actor, announced_id); return Ok(()) } diff --git a/src/server/normalizer.rs b/src/server/normalizer.rs index 8aeef667..7b56662c 100644 --- a/src/server/normalizer.rs +++ b/src/server/normalizer.rs @@ -2,8 +2,6 @@ use apb::{Node, Base, Object, Document}; use sea_orm::{sea_query::Expr, ActiveValue::{NotSet, Set}, ColumnTrait, EntityTrait, IntoActiveModel, QueryFilter}; use crate::{errors::UpubError, model, server::Context}; -use super::fetcher::Fetcher; - #[axum::async_trait] pub trait Normalizer { async fn insert_object(&self, obj: impl apb::Object, server: Option) -> crate::Result;