Skip to content

Commit 858fbfc

Browse files
committed
more edits to add discord_id to Person and avaialble through the static api
Signed-off-by: Nell Shamrell <[email protected]>
1 parent 0c55b32 commit 858fbfc

File tree

4 files changed

+12
-22
lines changed

4 files changed

+12
-22
lines changed

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/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_id: 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_id(&self) -> Option<&str> {
96-
self.discord_id.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_id,
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 id is formatted properly
272-
fn validate_discord_id(data: &Data, errors: &mut Vec<String>) {
273-
// A Discord ID is 18 digits
274-
let id_re = Regex::new(r"^[0-9]{18}$").unwrap();
275-
wrapper(data.people(), errors, |person, _| {
276-
if let Some(id) = person.discord_id() {
277-
if !id_re.is_match(id) {
278-
bail!(
279-
"user `{}` has an invalid discord id: {}",
280-
person.github(),
281-
id
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)