Skip to content

Commit 34b6e79

Browse files
author
Pietro Albini
authored
Merge pull request #340 from nellshamrell/make-discord-changes
2 parents 4dd4d98 + b85df3e commit 34b6e79

File tree

13 files changed

+60
-34
lines changed

13 files changed

+60
-34
lines changed

people/17cupsofcoffee.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name = "Joe Clay"
22
github = "17cupsofcoffee"
33
github-id = 784533
4-
5-
discord = "17cupsofcoffee#0419"
4+

people/AlexEne.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name = "Alexandru Ene"
22
github = "AlexEne"
33
github-id = 5849037
4-
5-
discord = "Alex#9085"
4+

people/Lokathor.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name = "Daniel Gee"
22
github = "Lokathor"
33
github-id = 5456384
4-
5-
discord = "Lokathor#2627"
4+

people/Wodann.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name = "Remco"
22
github = "Wodann"
33
github-id = 6917585
4-
5-
discord = "Wodann#9645"
4+

people/jtgeibel.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ name = "Justin Geibel"
22
github = "jtgeibel"
33
github-id = 22186
44
5+
6+
[permissions]
7+
crates-io-ops-bot.staging_crates_io = true

people/nellshamrell.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ name = "Nell Shamrell-Harrington"
22
github = "nellshamrell"
33
github-id = 813007
44
5+
discord-id = 244302461718757376
6+
7+
[permissions]
8+
crates-io-ops-bot.staging_crates_io = true

people/pietroalbini.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ name = "Pietro Albini"
22
github = "pietroalbini"
33
github-id = 2299951
44
5-
discord = "pietro#3134"
5+
6+
[permissions]
7+
crates-io-ops-bot.staging_crates_io = true

people/valgrimm.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
name = 'valgrimm'
22
github = 'valgrimm'
33
github-id = 56933147
4-
5-
discord = 'vgrimm#7551'
6-
4+

rust_team_data/src/v1.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ pub struct Lists {
8282
pub struct Permission {
8383
pub github_users: Vec<String>,
8484
pub github_ids: Vec<usize>,
85+
pub discord_ids: Vec<usize>,
8586
}
8687

8788
#[derive(Debug, Clone, Serialize, Deserialize)]

src/permissions.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ macro_rules! permissions {
1111
bors_repos {
1212
$($bors:ident,)*
1313
}
14+
crates_io_ops_apps {
15+
$($crates_io_ops_app:ident,)*
16+
}
1417
) => {
1518
#[derive(serde_derive::Deserialize, Debug)]
1619
#[serde(deny_unknown_fields)]
@@ -56,13 +59,16 @@ macro_rules! permissions {
5659
)*
5760
#[serde(default)]
5861
bors: BorsPermissions,
62+
#[serde(default)]
63+
crates_io_ops_bot: CratesIoOps,
5964
}
6065

6166
impl Default for Permissions {
6267
fn default() -> Self {
6368
Permissions {
6469
$($boolean: false,)*
6570
bors: BorsPermissions::default(),
71+
crates_io_ops_bot: CratesIoOps::default(),
6672
}
6773
}
6874
}
@@ -72,6 +78,7 @@ macro_rules! permissions {
7278
$(stringify!($boolean),)*
7379
$(concat!("bors.", stringify!($bors), ".review"),)*
7480
$(concat!("bors.", stringify!($bors), ".try"),)*
81+
$(concat!("crates_io_ops_bot.", stringify!($crates_io_ops_app)),)*
7582
];
7683

7784
pub(crate) fn has(&self, permission: &str) -> bool {
@@ -92,6 +99,11 @@ macro_rules! permissions {
9299
return self.bors.$bors.try_
93100
}
94101
)*
102+
$(
103+
if permission == concat!("crates_io_ops_bot", stringify!($crates_io_ops_app)) {
104+
return self.crates_io_ops_bot.$crates_io_ops_app
105+
}
106+
)*
95107
false
96108
}
97109

@@ -125,6 +137,23 @@ macro_rules! permissions {
125137
Ok(())
126138
}
127139
}
140+
141+
#[derive(serde_derive::Deserialize, Debug)]
142+
#[serde(deny_unknown_fields)]
143+
pub(crate) struct CratesIoOps {
144+
$(
145+
#[serde(default)]
146+
$crates_io_ops_app: bool,
147+
)*
148+
}
149+
150+
impl Default for CratesIoOps {
151+
fn default() -> Self {
152+
CratesIoOps {
153+
$($crates_io_ops_app: false,)*
154+
}
155+
}
156+
}
128157
}
129158
}
130159

@@ -150,6 +179,10 @@ permissions! {
150179
stdarch,
151180
team,
152181
}
182+
crates_io_ops_apps {
183+
crates_io,
184+
staging_crates_io,
185+
}
153186
}
154187

155188
pub(crate) fn allowed_people<'a>(

src/schema.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub(crate) struct Person {
5252
irc: Option<String>,
5353
#[serde(default)]
5454
email: EmailField,
55-
discord: Option<String>,
55+
discord_id: Option<usize>,
5656
#[serde(default)]
5757
permissions: Permissions,
5858
}
@@ -92,8 +92,8 @@ impl Person {
9292
}
9393
}
9494

95-
pub(crate) fn discord(&self) -> Option<&str> {
96-
self.discord.as_deref()
95+
pub(crate) fn discord_id(&self) -> Option<usize> {
96+
self.discord_id
9797
}
9898

9999
pub(crate) fn permissions(&self) -> &Permissions {

src/static_api.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,21 @@ impl<'a> Generator<'a> {
139139
.map(|p| p.github().to_string())
140140
.collect::<Vec<_>>();
141141
let mut github_ids = allowed.iter().map(|p| p.github_id()).collect::<Vec<_>>();
142+
143+
let mut discord_ids = allowed
144+
.iter()
145+
.map(|p| p.discord_id().unwrap_or(0))
146+
.collect::<Vec<_>>();
147+
142148
github_users.sort();
143149
github_ids.sort();
150+
discord_ids.sort();
144151
self.add(
145152
&format!("v1/permissions/{}.json", perm),
146153
&v1::Permission {
147154
github_users,
148155
github_ids,
156+
discord_ids,
149157
},
150158
)?;
151159
}

src/validate.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ static CHECKS: &[fn(&Data, &mut Vec<String>)] = &[
1717
validate_list_extra_teams,
1818
validate_list_addresses,
1919
validate_people_addresses,
20-
validate_discord_name,
2120
validate_duplicate_permissions,
2221
validate_permissions,
2322
validate_rfcbot_labels,
@@ -268,24 +267,6 @@ fn validate_people_addresses(data: &Data, errors: &mut Vec<String>) {
268267
});
269268
}
270269

271-
/// Ensure the Discord name is formatted properly
272-
fn validate_discord_name(data: &Data, errors: &mut Vec<String>) {
273-
// https://discordapp.com/developers/docs/resources/user#usernames-and-nicknames
274-
let name_re = Regex::new(r"^[^@#:`]{2,32}#[0-9]{4}$").unwrap();
275-
wrapper(data.people(), errors, |person, _| {
276-
if let Some(name) = person.discord() {
277-
if !name_re.is_match(name) {
278-
bail!(
279-
"user `{}` has an invalid discord name: {}",
280-
person.github(),
281-
name
282-
);
283-
}
284-
}
285-
Ok(())
286-
})
287-
}
288-
289270
/// Ensure members of teams with permissions don't explicitly have those permissions
290271
fn validate_duplicate_permissions(data: &Data, errors: &mut Vec<String>) {
291272
wrapper(data.teams(), errors, |team, errors| {

0 commit comments

Comments
 (0)