collab: Require github_user_created_at at ingress points (#17180)

This PR makes the `github_user_created_at` field required at ingress
points into collab.

In practice we already have this value passed up, this change just makes
that explicit.

This is a precursor to making it required in the database.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-08-30 17:09:59 -04:00 committed by GitHub
parent 9a8c301a7d
commit bb9f2f8713
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 26 additions and 26 deletions

View file

@ -12,6 +12,7 @@ use async_tungstenite::tungstenite::{
error::Error as WebsocketError,
http::{HeaderValue, Request, StatusCode},
};
use chrono::{DateTime, Utc};
use clock::SystemClock;
use collections::HashMap;
use futures::{
@ -1400,6 +1401,7 @@ impl Client {
struct GithubUser {
id: i32,
login: String,
created_at: DateTime<Utc>,
}
let request = {
@ -1445,13 +1447,15 @@ impl Client {
user
};
// Use the collab server's admin API to retrieve the id
// Use the collab server's admin API to retrieve the ID
// of the impersonated user.
let mut url = self.rpc_url(http.clone(), None).await?;
url.set_path("/user");
url.set_query(Some(&format!(
"github_login={}&github_user_id={}",
github_user.login, github_user.id
"github_login={login}&github_user_id={id}&github_user_created_at={created_at}",
login = github_user.login,
id = github_user.id,
created_at = github_user.created_at.to_rfc3339()
)));
let request: http_client::Request<AsyncBody> = Request::get(url.as_str())
.header("Authorization", format!("token {api_token}"))