From c0aee244e74e4da54aec9677aa04431f409b97a1 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 25 Oct 2023 04:41:52 -0400 Subject: [PATCH] Hide public rss items for private instance. Fixes #3785 (#4097) --- crates/routes/src/feeds.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/routes/src/feeds.rs b/crates/routes/src/feeds.rs index 3ef760a51..46997055f 100644 --- a/crates/routes/src/feeds.rs +++ b/crates/routes/src/feeds.rs @@ -2,7 +2,7 @@ use crate::local_user_view_from_jwt; use actix_web::{error::ErrorBadRequest, web, Error, HttpRequest, HttpResponse, Result}; use anyhow::anyhow; use chrono::{DateTime, Utc}; -use lemmy_api_common::context::LemmyContext; +use lemmy_api_common::{context::LemmyContext, utils::check_private_instance}; use lemmy_db_schema::{ source::{community::Community, person::Person}, traits::ApubActor, @@ -132,6 +132,8 @@ async fn get_feed_data( ) -> Result { let site_view = SiteView::read_local(&mut context.pool()).await?; + check_private_instance(&None, &site_view.local_site)?; + let posts = PostQuery { listing_type: (Some(listing_type)), sort: (Some(sort_type)), @@ -235,6 +237,8 @@ async fn get_feed_user( let site_view = SiteView::read_local(&mut context.pool()).await?; let person = Person::read_from_name(&mut context.pool(), user_name, false).await?; + check_private_instance(&None, &site_view.local_site)?; + let posts = PostQuery { listing_type: (Some(ListingType::All)), sort: (Some(*sort_type)), @@ -269,6 +273,8 @@ async fn get_feed_community( let site_view = SiteView::read_local(&mut context.pool()).await?; let community = Community::read_from_name(&mut context.pool(), community_name, false).await?; + check_private_instance(&None, &site_view.local_site)?; + let posts = PostQuery { sort: (Some(*sort_type)), community_id: (Some(community.id)), @@ -306,6 +312,8 @@ async fn get_feed_front( let site_view = SiteView::read_local(&mut context.pool()).await?; let local_user = local_user_view_from_jwt(jwt, context).await?; + check_private_instance(&Some(local_user.clone()), &site_view.local_site)?; + let posts = PostQuery { listing_type: (Some(ListingType::Subscribed)), local_user: (Some(&local_user)), @@ -343,6 +351,8 @@ async fn get_feed_inbox(context: &LemmyContext, jwt: &str) -> Result