diff --git a/docs/toml-schema.md b/docs/toml-schema.md index aed7cc476..7718a0540 100644 --- a/docs/toml-schema.md +++ b/docs/toml-schema.md @@ -17,6 +17,11 @@ email = "john@doe.com" # Email address used for mailing lists (optional) irc = "jdoe" # Nickname of the person on IRC, if different than the GitHub one (optional) matrix = "@john:doe.com" # Matrix username (MXID) of the person (optional) +[funding] +# Optional, specify that you have GitHub Sponsors enabled and you +# are looking for sponsors to fund your work on Rust. +github-sponsors = true + [permissions] # Optional, see the permissions documentation ``` diff --git a/rust_team_data/src/v1.rs b/rust_team_data/src/v1.rs index 9693e1242..ebd482be5 100644 --- a/rust_team_data/src/v1.rs +++ b/rust_team_data/src/v1.rs @@ -249,6 +249,7 @@ pub struct Person { pub name: String, pub email: Option, pub github_id: u64, + pub github_sponsors: bool, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] diff --git a/src/schema.rs b/src/schema.rs index 976eba916..9840fdb03 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -65,6 +65,12 @@ pub(crate) enum Email<'a> { Present(&'a str), } +#[derive(serde_derive::Deserialize, Debug, Default)] +#[serde(deny_unknown_fields, rename_all = "kebab-case")] +pub(crate) struct Funding { + github_sponsors: bool, +} + #[derive(serde_derive::Deserialize, Debug)] #[serde(deny_unknown_fields, rename_all = "kebab-case")] pub(crate) struct Person { @@ -78,6 +84,8 @@ pub(crate) struct Person { discord_id: Option, matrix: Option, #[serde(default)] + funding: Funding, + #[serde(default)] permissions: Permissions, } @@ -98,6 +106,10 @@ impl Person { self.zulip_id } + pub(crate) fn has_github_sponsors(&self) -> bool { + self.funding.github_sponsors + } + #[allow(unused)] pub(crate) fn irc(&self) -> &str { if let Some(irc) = &self.irc { diff --git a/src/static_api.rs b/src/static_api.rs index 39c0d8f0e..bcfa2c501 100644 --- a/src/static_api.rs +++ b/src/static_api.rs @@ -367,6 +367,7 @@ impl<'a> Generator<'a> { Email::Present(s) => Some(s.into()), }, github_id: person.github_id(), + github_sponsors: person.has_github_sponsors(), }, ); } diff --git a/sync-team/src/github/tests/test_utils.rs b/sync-team/src/github/tests/test_utils.rs index 1e57c3268..8a83d4eb2 100644 --- a/sync-team/src/github/tests/test_utils.rs +++ b/sync-team/src/github/tests/test_utils.rs @@ -39,6 +39,7 @@ impl DataModel { name: name.to_string(), email: Some(format!("{name}@rust.com")), github_id, + github_sponsors: false, }); github_id } diff --git a/tests/static-api/_expected/v1/people.json b/tests/static-api/_expected/v1/people.json index 3a4ae9a7e..45e1c6e57 100644 --- a/tests/static-api/_expected/v1/people.json +++ b/tests/static-api/_expected/v1/people.json @@ -3,42 +3,50 @@ "test-admin": { "name": "Test Admin", "email": "test-admin@example.com", - "github_id": 7 + "github_id": 7, + "github_sponsors": false }, "user-0": { "name": "Zeroth user", "email": "user0@example.com", - "github_id": 0 + "github_id": 0, + "github_sponsors": false }, "user-1": { "name": "First user", "email": "user1@example.com", - "github_id": 0 + "github_id": 0, + "github_sponsors": false }, "user-2": { "name": "Second user", "email": "user2@example.com", - "github_id": 2 + "github_id": 2, + "github_sponsors": false }, "user-3": { "name": "Third user", "email": "user3@example.com", - "github_id": 3 + "github_id": 3, + "github_sponsors": false }, "user-4": { "name": "Fourth user", "email": "user4@example.com", - "github_id": 4 + "github_id": 4, + "github_sponsors": false }, "user-5": { "name": "Fifth user", "email": "user5@example.com", - "github_id": 5 + "github_id": 5, + "github_sponsors": false }, "user-6": { "name": "Sixth user", "email": "user6@example.com", - "github_id": 6 + "github_id": 6, + "github_sponsors": false } } } \ No newline at end of file