From f0e487f18a29afc0671eaf245801b80c442fdd1c Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 3 Jul 2023 18:02:57 -0400 Subject: [PATCH] 300 comment limit. (#3306) * 300 comment limit. * Another fix. --- crates/api_common/src/utils.rs | 1 - crates/db_views/src/comment_view.rs | 9 ++++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/api_common/src/utils.rs b/crates/api_common/src/utils.rs index f400cc9a..fd143ed9 100644 --- a/crates/api_common/src/utils.rs +++ b/crates/api_common/src/utils.rs @@ -670,7 +670,6 @@ pub async fn remove_user_data_in_community( .pool(pool) .creator_id(Some(banned_person_id)) .community_id(Some(community_id)) - .limit(Some(i64::MAX)) .build() .list() .await?; diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment_view.rs index 7c33158d..f3b1f83a 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment_view.rs @@ -36,7 +36,7 @@ use lemmy_db_schema::{ post::Post, }, traits::JoinView, - utils::{fuzzy_search, get_conn, limit_and_offset_unlimited, DbPool}, + utils::{fuzzy_search, get_conn, limit_and_offset, DbPool}, CommentSortType, ListingType, }; @@ -340,9 +340,12 @@ impl<'a> CommentQuery<'a> { // This does not work for comment trees, and the limit should be manually set to a high number // // If a max depth is given, then you know its a tree fetch, and limits should be ignored - (i64::MAX, 0) + // TODO a kludge to prevent attacks. Limit comments to 300 for now. + // (i64::MAX, 0) + (300, 0) } else { - limit_and_offset_unlimited(self.page, self.limit) + // limit_and_offset_unlimited(self.page, self.limit) + limit_and_offset(self.page, self.limit)? }; query = match self.sort.unwrap_or(CommentSortType::Hot) { -- 2.44.1