Skip to content
Merged
1 change: 1 addition & 0 deletions people/GuillaumeGomez.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ github = "GuillaumeGomez"
github-id = 3050060
irc = "imperio"
email = "[email protected]"
discord-id = 301677135293186049
1 change: 1 addition & 0 deletions people/Kixiron.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ name = "Chase Wilson"
github = "Kixiron"
github-id = 25047011
email = "[email protected]"
discord-id = 341327659428741120
1 change: 1 addition & 0 deletions people/Manishearth.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ github = "Manishearth"
github-id = 1617736
email = "[email protected]"
zulip-id = 132040
discord-id = 278623213448331265

[permissions]
bors.semverver.review = true
1 change: 1 addition & 0 deletions people/Mark-Simulacrum.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ github-id = 5047365
zulip-id = 116122
irc = "simulacrum"
email = "[email protected]"
discord-id = 442403469580566528

[permissions]
bors.cargo.review = true
1 change: 1 addition & 0 deletions people/Nemo157.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ name = "Wim"
github = "Nemo157"
github-id = 81079
email = "[email protected]"
discord-id = 274907435972427778
1 change: 1 addition & 0 deletions people/aidanhs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ name = "Aidan Hobson Sayers"
github = "aidanhs"
github-id = 1050652
email = "[email protected]"
discord-id = 155372553181855745
1 change: 1 addition & 0 deletions people/badboy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ name = "Jan-Erik Rediger"
github = "badboy"
github-id = 2129
email = "[email protected]"
discord-id = 347670185806659585
1 change: 1 addition & 0 deletions people/cramertj.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ name = "Taylor Cramer"
github = "cramertj"
github-id = 5963049
email = "[email protected]"
discord-id = 446773566478745611
1 change: 1 addition & 0 deletions people/cuviper.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ github = "cuviper"
github-id = 36186
email = "[email protected]"
irc = "jistone"
discord-id = 443825361256448003
1 change: 1 addition & 0 deletions people/eddyb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ name = "Eduard Burtescu"
github = "eddyb"
github-id = 77424
email = "[email protected]"
discord-id = 391665108490649601
1 change: 1 addition & 0 deletions people/estebank.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ name = "Esteban Kuber"
github = "estebank"
github-id = 1606434
email = "[email protected]"
discord-id = 449245991216873475
1 change: 1 addition & 0 deletions people/flaki.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ github = "flaki"
github-id = 2089432
irc = "flaki"
email = "[email protected]"
discord-id = 453958363152252928
1 change: 1 addition & 0 deletions people/fmoko.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ name = "Marisa"
github = "fmoko"
github-id = 6445316
email = "[email protected]"
discord-id = 780131913817129002
1 change: 1 addition & 0 deletions people/jyn514.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ github = 'jyn514'
github-id = 23638587
email = '[email protected]'
zulip-id = 232545
discord-id = 568772690438127647
1 change: 1 addition & 0 deletions people/kennytm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ name = "kennytm"
github = "kennytm"
github-id = 103023
email = "[email protected]"
discord-id = 382886245069488129
1 change: 1 addition & 0 deletions people/khionu.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ name = "Khionu Sybiern"
github = "khionu"
github-id = 11195266
email = "[email protected]"
discord-id = 96642168176807936

1 change: 1 addition & 0 deletions people/nagisa.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ github = "nagisa"
github-id = 679122
irc = "nagisa"
email = "[email protected]"
discord-id = 119181581033275392
1 change: 1 addition & 0 deletions people/nikomatsakis.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ github = "nikomatsakis"
github-id = 155238
email = "[email protected]"
zulip-id = 116009
discord-id = 442067131769683974
1 change: 1 addition & 0 deletions people/oli-obk.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ name = "Oliver Scherer"
github = "oli-obk"
github-id = 332036
email = "[email protected]"
discord-id = 282164774379192320
1 change: 1 addition & 0 deletions people/onur.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ name = "Onur Aslan"
github = "onur"
github-id = 345828
email = "[email protected]"
discord-id = 265936699861762048
1 change: 1 addition & 0 deletions people/petrochenkov.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ github-id = 5751617
zulip-id = 123856
irc = "petrochenkov"
email = "[email protected]"
discord-id = 300421337103466496
1 change: 1 addition & 0 deletions people/pnkfelix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ name = "Felix Klock"
github = "pnkfelix"
github-id = 173127
email = "[email protected]"
discord-id = 443061971114262528
1 change: 1 addition & 0 deletions people/scottmcm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ name = "Scott McMurray"
github = "scottmcm"
github-id = 18526288
email = "[email protected]"
discord-id = 446765297286774784
1 change: 1 addition & 0 deletions people/sebasmagri.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ name = "Sebastián Magrí"
github = "sebasmagri"
github-id = 11137
email = "[email protected]"
discord-id = 818556851112902657
1 change: 1 addition & 0 deletions people/shepmaster.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ github = "shepmaster"
github-id = 174509
zulip-id = 116155
email = "[email protected]"
discord-id = 453980540824059918
1 change: 1 addition & 0 deletions people/skade.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ name = "Florian Gilcher"
github = "skade"
github-id = 47542
email = "[email protected]"
discord-id = 433394056073183253
1 change: 1 addition & 0 deletions people/syphar.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ name = 'Denis Cornehl'
github = 'syphar'
github-id = 540890
email = '[email protected]'
discord-id = 635351653226381333
1 change: 1 addition & 0 deletions people/technetos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ name = "Joshua Gould"
github = "technetos"
github-id = 10949810
email = "[email protected]"
discord-id = 443810603417731092
1 change: 1 addition & 0 deletions people/wesleywiser.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ name = "Wesley Wiser"
github = "wesleywiser"
github-id = 831192
email = "[email protected]"
discord-id = 446730792933130242
8 changes: 8 additions & 0 deletions rust_team_data/src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct Team {
pub alumni: Vec<TeamMember>,
pub github: Option<TeamGitHub>,
pub website_data: Option<TeamWebsite>,
pub discord: Vec<TeamDiscord>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down Expand Up @@ -57,6 +58,13 @@ pub struct TeamWebsite {
pub weight: i64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TeamDiscord {
pub name: String,
pub members: Vec<usize>,
pub color: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DiscordInvite {
pub channel: String,
Expand Down
36 changes: 36 additions & 0 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ pub(crate) struct Team {
website: Option<WebsiteData>,
#[serde(default)]
lists: Vec<TeamList>,
discord_roles: Option<Vec<DiscordRole>>,
}

impl Team {
Expand Down Expand Up @@ -196,6 +197,10 @@ impl Team {
self.website.as_ref()
}

pub(crate) fn discord_roles(&self) -> Option<&Vec<DiscordRole>> {
self.discord_roles.as_ref()
}

pub(crate) fn members<'a>(&'a self, data: &'a Data) -> Result<HashSet<&'a str>, Error> {
let mut members: HashSet<_> = self.people.members.iter().map(|s| s.as_str()).collect();

Expand Down Expand Up @@ -330,11 +335,42 @@ impl Team {
Ok(result)
}

pub(crate) fn discord_ids(&self, data: &Data) -> Result<Vec<usize>, Error> {
Ok(self
.members(data)?
.iter()
.flat_map(|name| data.person(name).map(|p| p.discord_id()))
.flatten()
.collect())
}

pub(crate) fn is_alumni_team(&self) -> bool {
self.people.include_all_alumni
}
}

#[derive(serde_derive::Deserialize, Debug)]
#[serde(rename_all = "kebab-case", deny_unknown_fields)]
pub(crate) struct DiscordRole {
name: String,
color: Option<String>,
}

impl DiscordRole {
pub(crate) fn name(&self) -> &str {
&self.name
}

pub(crate) fn color(&self) -> Option<&str> {
self.color.as_ref().map(|s| &s[..])
}
}

#[derive(Eq, PartialEq, Debug)]
pub(crate) struct DiscordTeam {
pub(crate) members: Vec<usize>,
}

#[derive(Eq, PartialEq)]
pub(crate) struct GitHubTeam<'a> {
pub(crate) org: &'a str,
Expand Down
15 changes: 15 additions & 0 deletions src/static_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ impl<'a> Generator<'a> {
let mut github_teams = team.github_teams(&self.data)?;
github_teams.sort();

let member_discord_ids = team.discord_ids(&self.data)?;

let team_data = v1::Team {
name: team.name().into(),
kind: match team.kind() {
Expand Down Expand Up @@ -100,6 +102,19 @@ impl<'a> Generator<'a> {
zulip_stream: ws.zulip_stream().map(|s| s.into()),
weight: ws.weight(),
}),
discord: team
.discord_roles()
.map(|roles| {
roles
.iter()
.map(|role| v1::TeamDiscord {
name: role.name().into(),
color: role.color().map(String::from),
members: member_discord_ids.clone(),
})
.collect()
})
.unwrap_or_else(Vec::new),
};

self.add(&format!("v1/teams/{}.json", team.name()), &team_data)?;
Expand Down
24 changes: 24 additions & 0 deletions src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static CHECKS: &[Check<fn(&Data, &mut Vec<String>)>] = checks![
validate_discord_permissions,
validate_zulip_stream_name,
validate_project_groups_have_parent_teams,
validate_discord_team_members_have_discord_ids,
];

#[allow(clippy::type_complexity)]
Expand Down Expand Up @@ -520,6 +521,29 @@ fn validate_project_groups_have_parent_teams(data: &Data, errors: &mut Vec<Strin
})
}

fn validate_discord_team_members_have_discord_ids(data: &Data, errors: &mut Vec<String>) {
wrapper(data.teams(), errors, |team, _| {
if team.discord_roles().is_some() && team.name() != "all" {
let team_members = team.members(&data)?;
if team_members.len() != team.discord_ids(&data)?.len() {
let members: String = team_members
.into_iter()
.filter(|name| data.person(name).map(|p| p.discord_id()) == Some(None))
.map(|name| format!("{}, ", name))
.collect();

bail!(
"the following members of the \"{}\" team do not have discord_ids: {}",
team.name(),
&members[..members.len() - 2]
);
}
}

Ok(())
});
}

fn wrapper<T, I, F>(iter: I, errors: &mut Vec<String>, mut func: F)
where
I: Iterator<Item = T>,
Expand Down
3 changes: 3 additions & 0 deletions teams/all.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ include-team-members = false
extra-emails = [
"[email protected]",
]

[[discord-roles]]
name = "WGs and Teams"
4 changes: 4 additions & 0 deletions teams/community.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,7 @@ extra-people = [
"spastorino",
"skade",
]

[[discord-roles]]
name = "community-team"
color = "#c27c0e"
5 changes: 5 additions & 0 deletions teams/core.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,8 @@ extra-people = ["ashleygwilliams"]
address = "[email protected]"
include-team-members = false
extra-people = ["pietroalbini"]

[[discord-roles]]
name = "core-team"
color = "#3498db"

3 changes: 3 additions & 0 deletions teams/docs-rs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ address = "[email protected]"

[[lists]]
address = "[email protected]"

[[discord-roles]]
name = "docs-rs"
4 changes: 4 additions & 0 deletions teams/infra.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ address = "[email protected]"

[[lists]]
address = "[email protected]"

[[discord-roles]]
name = "infra-team"
color = "#ff5454"
4 changes: 4 additions & 0 deletions teams/lang.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ address = "[email protected]"

[[lists]]
address = "[email protected]"

[[discord-roles]]
name = "lang-team"
color = "#2ecc71"
4 changes: 4 additions & 0 deletions teams/mods-discord.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ description = "Moderating the Discord server"

[[lists]]
address = "[email protected]"

[[discord-roles]]
name = "mods"
color = "#e74c3c"
4 changes: 4 additions & 0 deletions teams/wg-security-response.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ repo = "https://github.com/rust-lang/wg-security-response"

[[lists]]
address = "[email protected]"

[[discord-roles]]
name = "security"
color = "#e91e63"
Loading