Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for matrix usernames/rooms #1080

Merged
merged 2 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/toml-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ discord-id = 123456 # Discord ID of the person (optional)
# This will, for example, avoid adding the person to the mailing lists.
email = "[email protected]" # 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)

[permissions]
# Optional, see the permissions documentation
Expand Down Expand Up @@ -134,6 +135,8 @@ discord-invite = "https://discord.gg/e6Q3cvu"
discord-name = "#wg-rustup"
# The name of the team's stream on Zulip.
zulip-stream = "t-lang"
# An alias for the team's matrix room.
matrix-room = "#t-lang:matrix.org"
# An integer to influence the sort order of team in the teams list.
# They are sorted in descending order, so very large positive values are
# first, and very negative values are last.
Expand Down
1 change: 1 addition & 0 deletions rust_team_data/src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub struct TeamWebsite {
pub repo: Option<String>,
pub discord: Option<DiscordInvite>,
pub zulip_stream: Option<String>,
pub matrix_room: Option<String>,
pub weight: i64,
}

Expand Down
11 changes: 11 additions & 0 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pub(crate) struct Person {
#[serde(default)]
email: EmailField,
discord_id: Option<u64>,
matrix: Option<String>,
#[serde(default)]
permissions: Permissions,
}
Expand Down Expand Up @@ -108,6 +109,11 @@ impl Person {
self.discord_id
}

#[allow(unused)]
pub(crate) fn matrix(&self) -> Option<&str> {
self.matrix.as_deref()
}

pub(crate) fn permissions(&self) -> &Permissions {
&self.permissions
}
Expand Down Expand Up @@ -595,6 +601,7 @@ pub(crate) struct WebsiteData {
repo: Option<String>,
discord_invite: Option<String>,
discord_name: Option<String>,
matrix_room: Option<String>,
zulip_stream: Option<String>,
#[serde(default)]
weight: i64,
Expand Down Expand Up @@ -639,6 +646,10 @@ impl WebsiteData {
pub(crate) fn zulip_stream(&self) -> Option<&str> {
self.zulip_stream.as_deref()
}

pub(crate) fn matrix_room(&self) -> Option<&str> {
self.matrix_room.as_deref()
}
}

#[derive(serde_derive::Deserialize, Debug)]
Expand Down
1 change: 1 addition & 0 deletions src/static_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ impl<'a> Generator<'a> {
url: i.url.into(),
}),
zulip_stream: ws.zulip_stream().map(|s| s.into()),
matrix_room: ws.matrix_room().map(|s| s.into()),
weight: ws.weight(),
}),
roles: team
Expand Down
1 change: 1 addition & 0 deletions teams/wg-embedded.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ page = "embedded"
name = "Embedded devices working group"
description = "Focusing on improving the end-to-end experience of using Rust in resource-constrained environments and non-traditional platforms"
repo = "https://github.com/rust-embedded/wg"
matrix-room = "#rust-embedded:matrix.org"

[[lists]]
address = "[email protected]"
1 change: 1 addition & 0 deletions tests/static-api/_expected/v1/teams.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"url": "https://discord.gg/AAAAA"
},
"zulip_stream": "t-foo",
"matrix_room": "#t-foo:example.com",
"weight": 1000
},
"roles": [],
Expand Down
1 change: 1 addition & 0 deletions tests/static-api/_expected/v1/teams/foo.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"url": "https://discord.gg/AAAAA"
},
"zulip_stream": "t-foo",
"matrix_room": "#t-foo:example.com",
"weight": 1000
},
"roles": [],
Expand Down
1 change: 1 addition & 0 deletions tests/static-api/teams/foo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ repo = "https://github.com/ghost/foo"
discord-invite = "https://discord.gg/AAAAA"
discord-name = "#foo"
zulip-stream = "t-foo"
matrix-room = "#t-foo:example.com"
weight = 1000

[[github]]
Expand Down