Allow setting a channel for new users to auto-join (#9291)

Release Notes:

- Automatically add new users to the #zed channel
This commit is contained in:
Conrad Irwin 2024-03-13 11:11:31 -06:00 committed by GitHub
parent 88e33a1dbe
commit 77de5689a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 39 additions and 7 deletions

View file

@ -89,12 +89,15 @@ async fn get_authenticated_user(
Query(params): Query<AuthenticatedUserParams>,
Extension(app): Extension<Arc<AppState>>,
) -> Result<Json<AuthenticatedUserResponse>> {
let initial_channel_id = app.config.auto_join_channel_id;
let user = app
.db
.get_or_create_user_by_github_account(
&params.github_login,
params.github_user_id,
params.github_email.as_deref(),
initial_channel_id,
)
.await?;
let metrics_id = app.db.get_user_metrics_id(user.id).await?;
@ -179,11 +182,13 @@ async fn add_contributor(
Extension(app): Extension<Arc<AppState>>,
extract::Json(params): extract::Json<AuthenticatedUserParams>,
) -> Result<()> {
let initial_channel_id = app.config.auto_join_channel_id;
app.db
.add_contributor(
&params.github_login,
params.github_user_id,
params.github_email.as_deref(),
initial_channel_id,
)
.await
}