Skip to content

Commit

Permalink
Send feedback to student in embed
Browse files Browse the repository at this point in the history
  • Loading branch information
cptrodgers committed Aug 24, 2024
1 parent 78460c6 commit c84f2f7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
2 changes: 2 additions & 0 deletions graphql_server/src/db/embedded_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::collections::HashMap;
use uuid::Uuid;

use super::schema::{embedded_form_responses, embedded_sessions};
use crate::graphql::validator::id::Email;
use crate::impl_enum_for_db;
use crate::impl_jsonb_for_db;
use crate::util::get_now_as_secs;
Expand Down Expand Up @@ -99,6 +100,7 @@ impl EmbeddedSession {
#[diesel(sql_type = Jsonb)]
#[graphql(input_name = "EmbeddedResponseDataInput")]
pub struct EmbeddedResponse {
#[graphql(validator(custom = "Email"))]
pub email: String,
pub phone_number: String,
pub first_name: String,
Expand Down
9 changes: 7 additions & 2 deletions graphql_server/src/db/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,13 @@ Great news! Your teacher has provided feedback on your submission in {submission
)
}

fn get_url_path(&self, _: &User) -> String {
format_document_url(self.document_submission_id)
fn get_url_path(&self, receiver: &User) -> String {
generate_document_magic_link(
receiver.id,
self.document_submission_id,
Some(ONE_MONTH_SECONDS),
)
.unwrap_or(format_document_url(self.document_submission_id))
}
}

Expand Down
14 changes: 12 additions & 2 deletions graphql_server/src/db/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,18 @@ impl NewUser {
}
}

pub fn new_temp(temp_id: Uuid, first_name: String, last_name: String) -> NewUser {
let temp_email = format!("user_{temp_id}@ikigai.li");
pub fn new_temp(original_email: String, first_name: String, last_name: String) -> NewUser {
let components: Vec<&str> = original_email.split('@').collect();
let uuid = Uuid::new_v4();
let temp_email = if components.len() == 2 {
format!(
"{first_part}+{uuid}@{second_part}",
first_part = components[0],
second_part = components[1]
)
} else {
format!("user_{uuid}@ikigai.li")
};
NewUser::new(temp_email, first_name, last_name)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ impl DocumentMutation {
.transaction::<_, IkigaiError, _>(|conn| {
response.id = Uuid::new_v4();
let temp_user = NewUser::new_temp(
response.id,
response.response_data.email.clone(),
response.response_data.first_name.clone(),
response.response_data.last_name.clone(),
);
Expand Down

0 comments on commit c84f2f7

Please sign in to comment.