diff --git a/Dockerfile b/Dockerfile index 57336fb..82da00d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG BASE_IMAGE=rust:1.63 +ARG BASE_IMAGE=rust:latest FROM $BASE_IMAGE as builder WORKDIR /app diff --git a/src/conduit/alert.rs b/src/conduit/alert.rs index a4edb1e..482f755 100644 --- a/src/conduit/alert.rs +++ b/src/conduit/alert.rs @@ -54,7 +54,7 @@ pub async fn delete(pool: &SqlitePool, discord_id: i64, alert_id: &str) -> Resul if rows_affected == 0 { bail!("Could not find this alert to delete") - } else { - Ok(()) } + + Ok(()) } diff --git a/src/discord/mod.rs b/src/discord/mod.rs index 3986f9f..e5d099a 100644 --- a/src/discord/mod.rs +++ b/src/discord/mod.rs @@ -1,5 +1,6 @@ use std::convert::TryInto; use std::env; +use std::fmt::Write; use std::iter::FromIterator; use std::sync::Arc; @@ -170,20 +171,27 @@ async fn list(ctx: &Context, msg: &Message) -> CommandResult { let mut response = MessageBuilder::new(); if !alerts.is_empty() { - let results: String = alerts - .into_iter() - .enumerate() - .map(|(i, a)| { - format!( - "{}.\n Id: {}\n Url: {}\n Matching Text: {}\n Non Matching: {}\n", - i + 1, - a.alert_id, - a.url, - a.matching_text, - if a.non_matching == 1 { "True" } else { "False" }, - ) - }) - .collect(); + let results: String = + alerts + .iter() + .enumerate() + .fold(String::new(), |mut output, (i, a)| { + let _ = write!( + output, + r#"{}. + Id: {} + Url: {} + Matching Text: {} + Non Matching: {} +"#, + i + 1, + a.alert_id, + a.url, + a.matching_text, + if a.non_matching == 1 { "True" } else { "False" }, + ); + output + }); // If message is too large then send it in chunks; if results.len() > 1900 { diff --git a/src/models/alert.rs b/src/models/alert.rs index 987633d..28145b8 100644 --- a/src/models/alert.rs +++ b/src/models/alert.rs @@ -53,7 +53,7 @@ impl Alert { .context("Failed to convert discord_id into i64")?; Ok(Self::new( - &url, + url, matching_text.replace("'''", "\"").replace('~', ""), non_matching, discord_id,