Allow NSFW searching

This commit is contained in:
spikecodes 2021-01-20 18:26:58 -08:00
parent 610fcfbf87
commit 6641e242af
1 changed files with 3 additions and 2 deletions

View File

@ -1,5 +1,5 @@
// CRATES // CRATES
use crate::utils::{error, fetch_posts, param, prefs, request, val, Post, Preferences}; use crate::utils::{error, fetch_posts, param, prefs, request, val, Post, Preferences, cookie};
use actix_web::{HttpRequest, HttpResponse}; use actix_web::{HttpRequest, HttpResponse};
use askama::Template; use askama::Template;
@ -33,7 +33,8 @@ struct SearchTemplate {
// SERVICES // SERVICES
pub async fn find(req: HttpRequest) -> HttpResponse { pub async fn find(req: HttpRequest) -> HttpResponse {
let path = format!("{}.json?{}", req.path(), req.query_string()); let nsfw_results = if cookie(&req, "hide_nsfw") != "on" { "&include_over_18=on" } else { "" };
let path = format!("{}.json?{}{}", req.path(), req.query_string(), nsfw_results);
let sub = req.match_info().get("sub").unwrap_or("").to_string(); let sub = req.match_info().get("sub").unwrap_or("").to_string();
let sort = if param(&path, "sort").is_empty() { let sort = if param(&path, "sort").is_empty() {