diff --git a/src/mail.rs b/src/mail.rs
index 1698d8e..15f7088 100644
--- a/src/mail.rs
+++ b/src/mail.rs
@@ -6,7 +6,7 @@ use sendgrid::{Destination, Mail};
const RFD_FORUMS_BASE_URL: &str = "https://forums.redflagdeals.com";
-pub fn send(topic: &Topic, posts: &Posts, config: &Config) {
+pub fn send(topic: &Topic, posts: &Posts, expression: &str, config: &Config) {
let api_key = &config.sendgrid.api_key;
let sg = SGClient::new(api_key.to_string());
@@ -14,22 +14,28 @@ pub fn send(topic: &Topic, posts: &Posts, config: &Config) {
"\
First Posted: {}
- DEALER: {:?}
+ DEALER: {}
- DEAL: {:?}
+ DEAL: {}
POST: {}\
Body: {}
+
+
+ Matched by expression: {}
",
topic.post_time,
- topic.offer.dealer_name,
- topic.offer.url,
+ topic.offer.dealer_name.as_ref().unwrap_or(&"".to_string()),
+ topic.offer.url.as_ref().unwrap_or(&"".to_string()),
format!("{}/{}", RFD_FORUMS_BASE_URL, topic.web_path),
posts.posts[0].body,
+ expression,
);
+ debug!("{}", html_message);
+
let mail_info = Mail::new()
.add_to(Destination {
address: &config.sendgrid.mail_to,
diff --git a/src/rfd.rs b/src/rfd.rs
index 3bf25cd..7dee795 100644
--- a/src/rfd.rs
+++ b/src/rfd.rs
@@ -6,22 +6,22 @@ use crypto::sha2::Sha256;
use regex::RegexBuilder;
use serde::{Deserialize, Serialize};
-#[derive(Serialize, Deserialize, Debug)]
+#[derive(Serialize, Deserialize)]
pub struct Deals {
topics: Vec,
}
-#[derive(Serialize, Deserialize, Debug)]
+#[derive(Serialize, Deserialize)]
pub struct Posts {
pub posts: Vec,
}
-#[derive(Serialize, Deserialize, Debug)]
+#[derive(Serialize, Deserialize)]
pub struct Post {
pub body: String,
}
-#[derive(Serialize, Deserialize, Debug)]
+#[derive(Serialize, Deserialize)]
pub struct Topic {
#[serde(rename = "topic_id")]
pub id: u32,
@@ -31,7 +31,7 @@ pub struct Topic {
pub offer: Offer,
}
-#[derive(Serialize, Deserialize, Debug)]
+#[derive(Serialize, Deserialize)]
pub struct Offer {
pub dealer_name: Option,
pub url: Option,
@@ -111,7 +111,7 @@ pub fn match_deals(deals: Deals, config: Config) {
.unwrap(),
);
db::insert(&deal_hash);
- mail::send(topic, &posts, &config);
+ mail::send(topic, &posts, expression, &config);
}
}
}