diff --git a/src/main.rs b/src/main.rs index b275f2c..81b8896 100644 --- a/src/main.rs +++ b/src/main.rs @@ -65,6 +65,17 @@ struct Config { static CONFIG: Lazy = Lazy::new(Config::parse); +static WHITE_LIST: Lazy> = Lazy::new(|| { + use std::io::{BufRead, BufReader}; + match &CONFIG.email_white_list { + Some(str) => { + let reader = BufReader::new(File::open(str).unwrap()); + reader.lines().map(|line| line.unwrap()).collect() + } + _ => HashSet::new(), + } +}); + static GITHUB_TOKEN: Lazy = Lazy::new(|| { use std::env; use std::io::{stdin, BufRead, BufReader}; @@ -236,6 +247,8 @@ async fn handle_request(request: Request) -> http_types::Result let remaining = tree.collect_branches(&mut v); if !remaining { page.error = Some("There are no branches remaining to be tracked".to_string()) + } else if !WHITE_LIST.is_empty() && !WHITE_LIST.contains(&email) { + page.error = Some("You are not part of the white list.".to_string()) } else { page.subscribed = true; let folder = format!("{}/{}", CONFIG.data_folder, pr_number.unwrap());