Skip to content

Commit

Permalink
use static_files() to get image
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan0xC committed Oct 6, 2022
1 parent b8d1f86 commit e5c3ac7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub use crate::api::{
notifications::{start_notification_server, Notify, UpdateType},
web::catchers as web_catchers,
web::routes as web_routes,
web::static_files,
};
use crate::util;

Expand Down
2 changes: 1 addition & 1 deletion src/api/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fn alive(_conn: DbConn) -> Json<String> {
}

#[get("/vw_static/<filename>")]
fn static_files(filename: String) -> Result<(ContentType, &'static [u8]), Error> {
pub fn static_files(filename: String) -> Result<(ContentType, &'static [u8]), Error> {
match filename.as_ref() {
"mail-github.png" => Ok((ContentType::PNG, include_bytes!("../static/images/mail-github.png"))),
"logo-gray.png" => Ok((ContentType::PNG, include_bytes!("../static/images/logo-gray.png"))),
Expand Down
6 changes: 4 additions & 2 deletions src/mail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,10 @@ pub async fn send_test(address: &str) -> EmptyResult {
}

async fn send_email(address: &str, subject: &str, body_html: String, body_text: String) -> EmptyResult {
let logo_gray_body = Body::new(include_bytes!("static/images/logo-gray.png").to_vec());
let mail_github_body = Body::new(include_bytes!("static/images/mail-github.png").to_vec());
let (_, logo_gray) = crate::api::static_files("logo-gray.png".to_string()).unwrap();
let (_, mail_github) = crate::api::static_files("mail-github.png".to_string()).unwrap();
let logo_gray_body = Body::new(logo_gray.to_vec());
let mail_github_body = Body::new(mail_github.to_vec());
let smtp_from = &CONFIG.smtp_from();

let body = if CONFIG.smtp_embed_images() {
Expand Down

0 comments on commit e5c3ac7

Please sign in to comment.