From 781619a899f6b8082cbb1cfbefa95bca1d83894e Mon Sep 17 00:00:00 2001 From: alemi Date: Tue, 2 Jul 2024 01:54:07 +0200 Subject: [PATCH] chore: removed filter_objects --- upub/routes/src/activitypub/activity.rs | 2 +- upub/routes/src/activitypub/actor/outbox.rs | 2 +- upub/routes/src/activitypub/inbox.rs | 2 +- upub/routes/src/activitypub/outbox.rs | 2 +- upub/routes/src/auth.rs | 14 +------------- 5 files changed, 5 insertions(+), 17 deletions(-) diff --git a/upub/routes/src/activitypub/activity.rs b/upub/routes/src/activitypub/activity.rs index 97d0cd3b..4eb23cf6 100644 --- a/upub/routes/src/activitypub/activity.rs +++ b/upub/routes/src/activitypub/activity.rs @@ -25,7 +25,7 @@ pub async fn view( let row = upub::Query::feed(auth.my_id()) .filter(model::activity::Column::Id.eq(&aid)) - .filter(auth.filter_activities()) + .filter(auth.filter()) .into_model::() .one(ctx.db()) .await? diff --git a/upub/routes/src/activitypub/actor/outbox.rs b/upub/routes/src/activitypub/actor/outbox.rs index aeba8578..a0e062cb 100644 --- a/upub/routes/src/activitypub/actor/outbox.rs +++ b/upub/routes/src/activitypub/actor/outbox.rs @@ -26,7 +26,7 @@ pub async fn page( .add(model::object::Column::AttributedTo.eq(&uid)) ); if !auth.is(&uid) { - filter = filter.add(auth.filter_activities()); + filter = filter.add(auth.filter()); } crate::builders::paginate_feed( upub::url!(ctx, "/actors/{id}/outbox/page"), diff --git a/upub/routes/src/activitypub/inbox.rs b/upub/routes/src/activitypub/inbox.rs index fc793800..72145e90 100644 --- a/upub/routes/src/activitypub/inbox.rs +++ b/upub/routes/src/activitypub/inbox.rs @@ -21,7 +21,7 @@ pub async fn page( ) -> crate::ApiResult> { crate::builders::paginate_feed( upub::url!(ctx, "/inbox/page"), - auth.filter_activities(), + auth.filter(), ctx.db(), page, auth.my_id(), diff --git a/upub/routes/src/activitypub/outbox.rs b/upub/routes/src/activitypub/outbox.rs index 1c5c91f6..b502ed88 100644 --- a/upub/routes/src/activitypub/outbox.rs +++ b/upub/routes/src/activitypub/outbox.rs @@ -16,7 +16,7 @@ pub async fn page( crate::builders::paginate_feed( upub::url!(ctx, "/outbox/page"), Condition::all() - .add(auth.filter_activities()) + .add(auth.filter()) .add(upub::model::actor::Column::Domain.eq(ctx.domain().to_string())), ctx.db(), page, diff --git a/upub/routes/src/auth.rs b/upub/routes/src/auth.rs index 609cafba..8a3a4023 100644 --- a/upub/routes/src/auth.rs +++ b/upub/routes/src/auth.rs @@ -20,7 +20,7 @@ pub enum Identity { } impl Identity { - pub fn filter_activities(&self) -> Condition { + pub fn filter(&self) -> Condition { let base_cond = Condition::any().add(upub::model::addressing::Column::Actor.is_null()); match self { Identity::Anonymous => base_cond, @@ -29,18 +29,6 @@ impl Identity { } } - pub fn filter_objects(&self) -> Condition { - let base_cond = Condition::any().add(upub::model::addressing::Column::Actor.is_null()); - match self { - Identity::Anonymous => base_cond, - Identity::Remote { internal, .. } => base_cond.add(upub::model::addressing::Column::Instance.eq(*internal)), - // TODO should we allow all users on same server to see? or just specific user?? - Identity::Local { id, internal } => base_cond - .add(upub::model::addressing::Column::Actor.eq(*internal)) - .add(upub::model::object::Column::AttributedTo.eq(id)), - } - } - pub fn my_id(&self) -> Option { match self { Identity::Local { internal, .. } => Some(*internal),