Skip to content

Commit

Permalink
refactor: More reliable identification of user type
Browse files Browse the repository at this point in the history
  • Loading branch information
akash1810 committed Oct 23, 2024
1 parent 7afe69d commit 121f350
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub struct GithubLabel {
pub struct GithubUser {
pub id: usize,
pub login: String,
pub r#type: String,
}

#[derive(Deserialize, Debug)]
Expand Down
11 changes: 7 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,16 @@ fn make_message(pull_request: GithubPullRequest, show_pr_age: bool) -> String {
"".to_string()
};

let user = if pull_request.user.login.contains("[bot]") {
format!("🤖 {}", pull_request.user.login)
let user_emoji = if pull_request.user.r#type.to_lowercase() == "bot" {
"🤖".to_string()
} else {
format!("👤 {}", pull_request.user.login)
"👤".to_string()
};

format!("{}{} \n\n{}\n", message, age_output, user)
format!(
"{}{} \n\n{} {}\n",
message, age_output, user_emoji, pull_request.user.login
)
}

fn get_age(d1: DateTime<Utc>, d2: DateTime<Utc>) -> String {
Expand Down

0 comments on commit 121f350

Please sign in to comment.