mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Revert unnecessary logic for fetching invites' platform_unknown flag
This commit is contained in:
parent
3a4e802093
commit
b541ac313c
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
auth,
|
||||
db::{Invite, NewUserParams, ProjectId, Signup, UnsentInvite, User, UserId, WaitlistSummary},
|
||||
db::{Invite, NewUserParams, ProjectId, Signup, User, UserId, WaitlistSummary},
|
||||
rpc::{self, ResultExt},
|
||||
AppState, Error, Result,
|
||||
};
|
||||
@ -471,7 +471,7 @@ pub struct GetUnsentInvitesParams {
|
||||
async fn get_unsent_invites(
|
||||
Query(params): Query<GetUnsentInvitesParams>,
|
||||
Extension(app): Extension<Arc<AppState>>,
|
||||
) -> Result<Json<Vec<UnsentInvite>>> {
|
||||
) -> Result<Json<Vec<Invite>>> {
|
||||
Ok(Json(app.db.get_unsent_invites(params.count).await?))
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ pub trait Db: Send + Sync {
|
||||
|
||||
async fn create_signup(&self, signup: Signup) -> Result<()>;
|
||||
async fn get_waitlist_summary(&self) -> Result<WaitlistSummary>;
|
||||
async fn get_unsent_invites(&self, count: usize) -> Result<Vec<UnsentInvite>>;
|
||||
async fn get_unsent_invites(&self, count: usize) -> Result<Vec<Invite>>;
|
||||
async fn record_sent_invites(&self, invites: &[Invite]) -> Result<()>;
|
||||
async fn create_user_from_invite(
|
||||
&self,
|
||||
@ -442,11 +442,11 @@ impl Db for PostgresDb {
|
||||
.await?)
|
||||
}
|
||||
|
||||
async fn get_unsent_invites(&self, count: usize) -> Result<Vec<UnsentInvite>> {
|
||||
let rows: Vec<(String, String, bool)> = sqlx::query_as(
|
||||
async fn get_unsent_invites(&self, count: usize) -> Result<Vec<Invite>> {
|
||||
Ok(sqlx::query_as(
|
||||
"
|
||||
SELECT
|
||||
email_address, email_confirmation_code, platform_unknown
|
||||
email_address, email_confirmation_code
|
||||
FROM signups
|
||||
WHERE
|
||||
NOT email_confirmation_sent AND
|
||||
@ -456,19 +456,7 @@ impl Db for PostgresDb {
|
||||
)
|
||||
.bind(count as i32)
|
||||
.fetch_all(&self.pool)
|
||||
.await?;
|
||||
Ok(rows
|
||||
.into_iter()
|
||||
.map(
|
||||
|(email_address, email_confirmation_code, platform_unknown)| UnsentInvite {
|
||||
invite: Invite {
|
||||
email_address,
|
||||
email_confirmation_code,
|
||||
},
|
||||
platform_unknown,
|
||||
},
|
||||
)
|
||||
.collect())
|
||||
.await?)
|
||||
}
|
||||
|
||||
async fn record_sent_invites(&self, invites: &[Invite]) -> Result<()> {
|
||||
@ -1737,19 +1725,12 @@ pub struct WaitlistSummary {
|
||||
pub unknown_count: i64,
|
||||
}
|
||||
|
||||
#[derive(Clone, FromRow, PartialEq, Debug, Serialize, Deserialize)]
|
||||
#[derive(FromRow, PartialEq, Debug, Serialize, Deserialize)]
|
||||
pub struct Invite {
|
||||
pub email_address: String,
|
||||
pub email_confirmation_code: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug, PartialEq)]
|
||||
pub struct UnsentInvite {
|
||||
#[serde(flatten)]
|
||||
pub invite: Invite,
|
||||
pub platform_unknown: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct NewUserParams {
|
||||
pub github_login: String,
|
||||
@ -1965,7 +1946,7 @@ mod test {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
async fn get_unsent_invites(&self, _count: usize) -> Result<Vec<UnsentInvite>> {
|
||||
async fn get_unsent_invites(&self, _count: usize) -> Result<Vec<Invite>> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
|
@ -1030,7 +1030,7 @@ async fn test_signups() {
|
||||
let signups_batch1 = db.get_unsent_invites(3).await.unwrap();
|
||||
let addresses = signups_batch1
|
||||
.iter()
|
||||
.map(|s| &s.invite.email_address)
|
||||
.map(|s| &s.email_address)
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(
|
||||
addresses,
|
||||
@ -1041,8 +1041,8 @@ async fn test_signups() {
|
||||
]
|
||||
);
|
||||
assert_ne!(
|
||||
signups_batch1[0].invite.email_confirmation_code,
|
||||
signups_batch1[1].invite.email_confirmation_code
|
||||
signups_batch1[0].email_confirmation_code,
|
||||
signups_batch1[1].email_confirmation_code
|
||||
);
|
||||
|
||||
// the waitlist isn't updated until we record that the emails
|
||||
@ -1052,18 +1052,11 @@ async fn test_signups() {
|
||||
|
||||
// once the emails go out, we can retrieve the next batch
|
||||
// of signups.
|
||||
db.record_sent_invites(
|
||||
&signups_batch1
|
||||
.iter()
|
||||
.map(|i| i.invite.clone())
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
db.record_sent_invites(&signups_batch1).await.unwrap();
|
||||
let signups_batch2 = db.get_unsent_invites(3).await.unwrap();
|
||||
let addresses = signups_batch2
|
||||
.iter()
|
||||
.map(|s| &s.invite.email_address)
|
||||
.map(|s| &s.email_address)
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(
|
||||
addresses,
|
||||
@ -1096,8 +1089,8 @@ async fn test_signups() {
|
||||
} = db
|
||||
.create_user_from_invite(
|
||||
&Invite {
|
||||
email_address: signups_batch1[0].invite.email_address.clone(),
|
||||
email_confirmation_code: signups_batch1[0].invite.email_confirmation_code.clone(),
|
||||
email_address: signups_batch1[0].email_address.clone(),
|
||||
email_confirmation_code: signups_batch1[0].email_confirmation_code.clone(),
|
||||
},
|
||||
NewUserParams {
|
||||
github_login: "person-0".into(),
|
||||
@ -1117,8 +1110,8 @@ async fn test_signups() {
|
||||
// cannot redeem the same signup again.
|
||||
db.create_user_from_invite(
|
||||
&Invite {
|
||||
email_address: signups_batch1[0].invite.email_address.clone(),
|
||||
email_confirmation_code: signups_batch1[0].invite.email_confirmation_code.clone(),
|
||||
email_address: signups_batch1[0].email_address.clone(),
|
||||
email_confirmation_code: signups_batch1[0].email_confirmation_code.clone(),
|
||||
},
|
||||
NewUserParams {
|
||||
github_login: "some-other-github_account".into(),
|
||||
@ -1132,7 +1125,7 @@ async fn test_signups() {
|
||||
// cannot redeem a signup with the wrong confirmation code.
|
||||
db.create_user_from_invite(
|
||||
&Invite {
|
||||
email_address: signups_batch1[1].invite.email_address.clone(),
|
||||
email_address: signups_batch1[1].email_address.clone(),
|
||||
email_confirmation_code: "the-wrong-code".to_string(),
|
||||
},
|
||||
NewUserParams {
|
||||
|
Loading…
Reference in New Issue
Block a user