remove remains of query filtering anti-feature

This commit is contained in:
Milim 2024-08-15 21:14:11 +02:00
parent 253de6ff13
commit 8341310684
No known key found for this signature in database
3 changed files with 3 additions and 61 deletions

View file

@ -113,14 +113,6 @@ pub struct SearchResults {
/// Stores the information on which engines failed with their engine name
/// and the type of error that caused it.
pub engine_errors_info: Vec<EngineErrorInfo>,
/// Stores the flag option which holds the check value that the following
/// search query was disallowed when the safe search level set to 4 and it
/// was present in the `Blocklist` file.
pub disallowed: bool,
/// Stores the flag option which holds the check value that the following
/// search query was filtered when the safe search level set to 3 and it
/// was present in the `Blocklist` file.
pub filtered: bool,
/// Stores the safe search level `safesearch` provided in the search url.
pub safe_search_level: u8,
/// Stores the flag option which holds the check value that whether any search engines were
@ -143,23 +135,12 @@ impl SearchResults {
Self {
results,
engine_errors_info: engine_errors_info.to_owned(),
disallowed: Default::default(),
filtered: Default::default(),
safe_search_level: Default::default(),
no_engines_selected: Default::default(),
}
}
/// A setter function that sets disallowed to true.
pub fn set_disallowed(&mut self) {
self.disallowed = true;
}
/// A setter function that sets the filtered to true.
pub fn set_filtered(&mut self, filtered: bool) {
self.filtered = filtered;
}
/// A getter function that gets the value of `engine_errors_info`.
pub fn engine_errors_info(&mut self) -> Vec<EngineErrorInfo> {
std::mem::take(&mut self.engine_errors_info)

View file

@ -142,7 +142,7 @@ async fn results(
// default selected upstream search engines from the config file otherwise
// parse the non-empty cookie and grab the user selected engines from the
// UI and use that.
let mut results: SearchResults = match false {
let results: SearchResults = match false {
false => aggregate(query, page, config, &Vec::<EngineHandler>::from(upstream)).await?,
true => {
let mut search_results = SearchResults::default();
@ -150,12 +150,7 @@ async fn results(
search_results
}
};
let (engine_errors_info, results_empty_check, no_engines_selected) = (
results.engine_errors_info().is_empty(),
results.results().is_empty(),
results.no_engines_selected(),
);
results.set_filtered(engine_errors_info & results_empty_check & !no_engines_selected);
cache.cache_results(&[results.clone()], &[cache_key.clone()]);
Ok((results, cache_key))
}

View file

@ -39,40 +39,6 @@ pub fn search(query: &str, search_results: &SearchResults) -> Markup {
}
}
}
@else if search_results.disallowed{
.result_disallowed{
.description{
p{
"Your search - "{span class="user_query"{(query)}}" -
has been disallowed."
}
p class="description_paragraph"{"Dear user,"}
p class="description_paragraph"{
"The query - "{span class="user_query"{(query)}}" - has
been blacklisted via server configuration and hence disallowed by the
server. Henceforth no results could be displayed for your query."
}
}
img src="./images/barricade.png" alt="Image of a Barricade";
}
}
@else if search_results.filtered {
.result_filtered{
.description{
p{
"Your search - "{span class="user_query"{(query)}}" -
has been filtered."
}
p class="description_paragraph"{"Dear user,"}
p class="description_paragraph"{
"All the search results contain results that has been configured to be
filtered out via server configuration and henceforth has been
completely filtered out."
}
}
img src="./images/filter.png" alt="Image of a paper inside a funnel";
}
}
@else if search_results.no_engines_selected {
.result_engine_not_selected{
.description{