浏览代码

Move username to configuration

Mark Rousskov 6 年之前
父节点
当前提交
9ce2eca4f8
共有 2 个文件被更改,包括 8 次插入7 次删除
  1. 3 4
      src/github.rs
  2. 5 3
      src/main.rs

+ 3 - 4
src/github.rs

@@ -135,7 +135,7 @@ trait RequestSend: Sized {
 impl RequestSend for RequestBuilder {
     fn configure(self, g: &GithubClient) -> RequestBuilder {
         self.header(USER_AGENT, "rust-lang-triagebot")
-            .basic_auth("rust-highfive", Some(&g.token))
+            .basic_auth(&g.username, Some(&g.token))
     }
 
     fn send_req(self) -> Result<Response, HttpError> {
@@ -154,12 +154,11 @@ pub struct GithubClient {
 }
 
 impl GithubClient {
-    pub fn new(c: Client, token: String) -> Self {
-        // XXX: configuration for username
+    pub fn new(c: Client, token: String, username: String) -> Self {
         GithubClient {
             client: c,
             token,
-            username: String::from("rust-highfive"),
+            username,
         }
     }
 

+ 5 - 3
src/main.rs

@@ -18,8 +18,6 @@ mod interactions;
 mod payload;
 mod team;
 
-static BOT_USER_NAME: &str = "rust-highfive";
-
 use github::{Comment, GithubClient, Issue};
 use payload::SignedPayload;
 use registry::HandleRegistry;
@@ -110,7 +108,11 @@ fn not_found(_: &Request) -> &'static str {
 fn main() {
     dotenv::dotenv().ok();
     let client = Client::new();
-    let gh = GithubClient::new(client.clone(), env::var("GITHUB_API_TOKEN").unwrap());
+    let gh = GithubClient::new(
+        client.clone(),
+        env::var("GITHUB_API_TOKEN").unwrap(),
+        env::var("GITHUB_USERNAME").unwrap(),
+    );
     let mut registry = HandleRegistry::new();
     handlers::register_all(&mut registry, gh.clone());
     rocket::ignite()