@@ -6,13 +6,13 @@ use crate::config::get_setting;
66use crate :: server:: RequestExt ;
77use crate :: subreddit:: { can_access_quarantine, quarantine} ;
88use crate :: utils:: {
9- error, format_num, get_filters , nsfw_landing, param, parse_post, rewrite_emotes, setting, template, time, val, Author , Awards , Comment , Flair , FlairPart , Post , Preferences ,
9+ error, format_num, nsfw_landing, param, parse_post, rewrite_emotes, setting, template, time, val, Author , Awards , Comment , Flair , FlairPart , Post , Preferences ,
1010} ;
1111use hyper:: { Body , Request , Response } ;
1212
1313use askama:: Template ;
1414use regex:: Regex ;
15- use std:: collections:: { HashMap , HashSet } ;
15+ use std:: collections:: HashSet ;
1616use std:: sync:: LazyLock ;
1717
1818// STRUCTS
@@ -79,13 +79,13 @@ pub async fn item(req: Request<Body>) -> Result<Response<Body>, String> {
7979 None => String :: new ( ) ,
8080 } ;
8181
82- let query_string = format ! ( "q={query_body}&type=comment" ) ;
83- let form = url:: form_urlencoded:: parse ( query_string. as_bytes ( ) ) . collect :: < HashMap < _ , _ > > ( ) ;
84- let query = form. get ( "q" ) . unwrap ( ) . clone ( ) . to_string ( ) ;
82+ let query = query_body;
8583
84+ let prefs = Preferences :: new ( & req) ;
85+ let filters: HashSet < String > = prefs. filters . iter ( ) . cloned ( ) . collect ( ) ;
8686 let comments = match query. as_str ( ) {
87- "" => parse_comments ( & response[ 1 ] , & post. permalink , & post. author . name , highlighted_comment, & get_filters ( & req ) , & req) ,
88- _ => query_comments ( & response[ 1 ] , & post. permalink , & post. author . name , highlighted_comment, & get_filters ( & req ) , & query, & req) ,
87+ "" => parse_comments ( & response[ 1 ] , & post. permalink , & post. author . name , highlighted_comment, & filters , & req) ,
88+ _ => query_comments ( & response[ 1 ] , & post. permalink , & post. author . name , highlighted_comment, & filters , & query, & req) ,
8989 } ;
9090
9191 // Use the Post and Comment structs to generate a website to show users
@@ -94,7 +94,7 @@ pub async fn item(req: Request<Body>) -> Result<Response<Body>, String> {
9494 post,
9595 url_without_query : url. clone ( ) . trim_end_matches ( & format ! ( "?q={query}&type=comment" ) ) . to_string ( ) ,
9696 sort,
97- prefs : Preferences :: new ( & req ) ,
97+ prefs,
9898 single_thread,
9999 url : req_url,
100100 comment_query : query,
0 commit comments