forked from alemi/upub
fix: only count announces from persons
This commit is contained in:
parent
86ed372a54
commit
e636afd283
3 changed files with 5 additions and 6 deletions
|
@ -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<String>,
|
||||
sinks: BTreeSet<String>,
|
||||
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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(())
|
||||
}
|
||||
|
|
|
@ -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<String>) -> crate::Result<model::object::Model>;
|
||||
|
|
Loading…
Reference in a new issue