0
0
mirror of https://github.com/neon-mmd/websurfx.git synced 2024-11-21 21:48:21 -05:00

Change get_safe_search_level logic back

This commit is contained in:
ddotthomas 2024-01-12 09:51:31 -07:00
parent ca96a76958
commit 31c9c676ee

View File

@ -68,8 +68,8 @@ pub async fn search(
) )
}); });
get_safesearch_level( search_settings.safe_search_level = get_safesearch_level(
&mut search_settings.safe_search_level, &Some(search_settings.safe_search_level),
&params.safesearch, &params.safesearch,
config.safe_search, config.safe_search,
); );
@ -235,12 +235,15 @@ fn is_match_from_filter_list(
/// * `url_level` - Safe search level from the url. /// * `url_level` - Safe search level from the url.
/// * `safe_search` - User's cookie, or the safe search level set by the server /// * `safe_search` - User's cookie, or the safe search level set by the server
/// * `config_level` - Safe search level to fall back to /// * `config_level` - Safe search level to fall back to
fn get_safesearch_level(safe_search: &mut u8, url_level: &Option<u8>, config_level: u8) { fn get_safesearch_level(cookie_level: &Option<u8>, url_level: &Option<u8>, config_level: u8) -> u8 {
if let Some(url_level) = url_level { match url_level {
if *url_level >= 3 { Some(url_level) => {
*safe_search = config_level if *url_level >= 3 {
} else { config_level
*safe_search = *url_level; } else {
*url_level
}
} }
None => cookie_level.unwrap_or(config_level),
} }
} }