From 5883496d14d781e222357b873a5a26a799534f6f Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 24 Mar 2024 15:40:57 +0100 Subject: [PATCH] Use Zulip IDs instead of GitHub login in rfcbot issues --- src/actions.rs | 9 +++++++-- src/github.rs | 21 ++++++++++++++++++++- src/rfcbot.rs | 2 +- templates/_issues_rfcbot.tt | 2 +- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/actions.rs b/src/actions.rs index 1facfe80..11f9379f 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -9,7 +9,6 @@ use tera::{Context, Tera}; use crate::{ github::{self, GithubClient, Repository}, http_client::{CompilerMeeting, HttpClient}, - rfcbot, }; #[async_trait] @@ -62,6 +61,12 @@ pub struct FCPConcernDetails { pub concern_url: String, } +#[derive(Serialize, Deserialize, Debug)] +pub struct FCPReviewerDetails { + pub github_login: String, + pub zulip_id: Option, +} + #[derive(Serialize, Deserialize, Debug)] pub struct FCPDetails { pub bot_tracking_comment_html_url: String, @@ -69,7 +74,7 @@ pub struct FCPDetails { pub initiating_comment_html_url: String, pub initiating_comment_content: String, pub disposition: String, - pub pending_reviewers: Vec, + pub pending_reviewers: Vec, pub concerns: Vec, } diff --git a/src/github.rs b/src/github.rs index 06475651..ce960d6b 100644 --- a/src/github.rs +++ b/src/github.rs @@ -1719,6 +1719,12 @@ impl<'q> IssuesQuery for Query<'q> { HashMap::new() }; + let zulip_map = if include_fcp_details { + Some(crate::team_data::zulip_map(client).await?) + } else { + None + }; + let mut issues_decorator = Vec::new(); let re = regex::Regex::new("https://github.com/rust-lang/|/").unwrap(); let re_zulip_link = regex::Regex::new(r"\[stream\]:\s").unwrap(); @@ -1761,7 +1767,20 @@ impl<'q> IssuesQuery for Query<'q> { pending_reviewers: fcp .reviews .iter() - .filter_map(|r| (!r.approved).then(|| r.reviewer.clone())) + .filter_map(|r| { + (!r.approved).then(|| crate::actions::FCPReviewerDetails { + github_login: r.reviewer.login.clone(), + zulip_id: zulip_map + .as_ref() + .map(|map| { + map.users + .iter() + .find(|&(_, &github)| github == r.reviewer.id) + .map(|v| *v.0) + }) + .flatten(), + }) + }) .collect(), concerns: fcp .concerns diff --git a/src/rfcbot.rs b/src/rfcbot.rs index 0ab390d5..e3874548 100644 --- a/src/rfcbot.rs +++ b/src/rfcbot.rs @@ -15,7 +15,7 @@ pub struct FCP { } #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Reviewer { - pub id: u32, + pub id: u64, pub login: String, } #[derive(Serialize, Deserialize, Debug, Clone)] diff --git a/templates/_issues_rfcbot.tt b/templates/_issues_rfcbot.tt index 62e81be8..662cd7e6 100644 --- a/templates/_issues_rfcbot.tt +++ b/templates/_issues_rfcbot.tt @@ -4,7 +4,7 @@ {%- for issue in issues %} {%- if issue.fcp_details is object %} - {{issue.fcp_details.disposition}}: [{{issue.title}} ({{issue.repo_name}}#{{issue.number}})]({{issue.fcp_details.bot_tracking_comment_html_url}}) - *{% for reviewer in issue.fcp_details.pending_reviewers %} @**{{reviewer.login}}**{%else%} no pending checkboxs{% endfor %} + *{% for reviewer in issue.fcp_details.pending_reviewers %} @**|{{reviewer.zulip_id}}**{%else%} no pending checkboxs{% endfor %} *{% for concern in issue.fcp_details.concerns %} [{{concern.name}} (by {{concern.reviewer_login}})]({{concern.concern_url}}){%else%} no pending concerns{% endfor -%} {% else %} - "{{issue.title}}" {{issue.repo_name}}#{{issue.number}}