server: address lint

This commit is contained in:
Bill Thiede 2024-08-31 16:18:47 -07:00
parent 934cb9d91b
commit 7218c13b9e
3 changed files with 9 additions and 10 deletions

View File

@ -1,3 +1,6 @@
// Rocket generates a lot of warnings for handlers
// TODO: figure out why
#![allow(unreachable_patterns)]
#[macro_use] #[macro_use]
extern crate rocket; extern crate rocket;
use std::{error::Error, io::Cursor, str::FromStr}; use std::{error::Error, io::Cursor, str::FromStr};

View File

@ -14,19 +14,16 @@ use lol_html::{
RewriteStrSettings, RewriteStrSettings,
}; };
use maplit::{hashmap, hashset}; use maplit::{hashmap, hashset};
use scraper::{error::SelectorErrorKind, Html, Selector}; use scraper::{Html, Selector};
use thiserror::Error; use thiserror::Error;
use url::Url; use url::Url;
use crate::newsreader::{ use crate::newsreader::{extract_thread_id, is_newsreader_thread};
extract_thread_id, is_newsreader_search, is_newsreader_thread, make_news_tag,
};
const NON_EXISTENT_SITE_NAME: &'static str = "NO-SUCH-SITE";
// TODO: figure out how to use Cow // TODO: figure out how to use Cow
#[async_trait] #[async_trait]
trait Transformer: Send + Sync { trait Transformer: Send + Sync {
fn should_run(&self, addr: &Option<Url>, _html: &str) -> bool { fn should_run(&self, _addr: &Option<Url>, _html: &str) -> bool {
true true
} }
// TODO: should html be something like `html_escape` uses: // TODO: should html be something like `html_escape` uses:
@ -138,7 +135,7 @@ struct FrameImages;
#[async_trait] #[async_trait]
impl Transformer for FrameImages { impl Transformer for FrameImages {
async fn transform(&self, link: &Option<Url>, html: &str) -> Result<String, TransformError> { async fn transform(&self, _: &Option<Url>, html: &str) -> Result<String, TransformError> {
Ok(rewrite_str( Ok(rewrite_str(
html, html,
RewriteStrSettings { RewriteStrSettings {
@ -213,7 +210,7 @@ impl SlurpContents {
#[async_trait] #[async_trait]
impl Transformer for SlurpContents { impl Transformer for SlurpContents {
fn should_run(&self, link: &Option<Url>, html: &str) -> bool { fn should_run(&self, link: &Option<Url>, _: &str) -> bool {
if let Some(link) = link { if let Some(link) = link {
return self.get_selectors(link).is_some(); return self.get_selectors(link).is_some();
} }
@ -580,7 +577,6 @@ impl FromStr for Query {
let mut tag = None; let mut tag = None;
let mut uid = None; let mut uid = None;
let mut remainder = Vec::new(); let mut remainder = Vec::new();
let site_prefix = make_news_tag("");
let mut is_notmuch = false; let mut is_notmuch = false;
let mut is_newsreader = false; let mut is_newsreader = false;
for word in s.split_whitespace() { for word in s.split_whitespace() {

View File

@ -14,7 +14,7 @@ const THREAD_PREFIX: &'static str = "news:";
use crate::{ use crate::{
compute_offset_limit, compute_offset_limit,
error::ServerError, error::ServerError,
graphql::{Body, Email, Html, Message, NewsPost, Tag, Thread, ThreadSummary}, graphql::{NewsPost, Tag, Thread, ThreadSummary},
AddOutlink, EscapeHtml, FrameImages, InlineStyle, SanitizeHtml, SlurpContents, StripHtml, AddOutlink, EscapeHtml, FrameImages, InlineStyle, SanitizeHtml, SlurpContents, StripHtml,
Transformer, Transformer,
}; };