-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feat/site creation form email #679
Changes from 7 commits
c6c3a8a
fb54bff
24b6a19
68a8033
440a247
f6cdb2b
926b002
80cfbbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ const SITE_CREATE_FORM_KEY = config.get("formSg.siteCreateFormKey") | |
const REQUESTER_EMAIL_FIELD = "Government E-mail" | ||
const SITE_NAME_FIELD = "Site Name" | ||
const REPO_NAME_FIELD = "Repository Name" | ||
const OWNER_NAME_FIELD = "Site Owner E-mail" | ||
|
||
export interface FormsgRouterProps { | ||
usersService: UsersService | ||
|
@@ -51,6 +52,7 @@ export class FormsgRouter { | |
const requesterEmail = getField(responses, REQUESTER_EMAIL_FIELD) | ||
const siteName = getField(responses, SITE_NAME_FIELD) | ||
const repoName = getField(responses, REPO_NAME_FIELD) | ||
const ownerEmail = getField(responses, OWNER_NAME_FIELD)?.toLowerCase() | ||
|
||
logger.info( | ||
`Create site form submission [${submissionId}] (repoName '${repoName}', siteName '${siteName}') requested by <${requesterEmail}>` | ||
|
@@ -75,16 +77,20 @@ export class FormsgRouter { | |
await this.sendCreateError(requesterEmail, repoName, submissionId, err) | ||
return res.sendStatus(200) | ||
} | ||
const foundUser = await this.usersService.findByEmail(requesterEmail) | ||
if (!foundUser) { | ||
const foundIsomerRequester = await this.usersService.findByEmail( | ||
requesterEmail | ||
) | ||
if (!foundIsomerRequester) { | ||
const err = `Form submitter ${requesterEmail} is not an Isomer user. Register an account for this user and try again.` | ||
await this.sendCreateError(requesterEmail, repoName, submissionId, err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry a bit confused, this is an error flow right? Why are we returning 200 res after sendCreateError? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This endpoint is only triggered by forms, which expects a 200 response, otherwise it could trigger a retry! The error handling is done separately via email |
||
return res.sendStatus(200) | ||
} | ||
const foundOwner = await this.usersService.findOrCreateByEmail(ownerEmail) | ||
kishore03109 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// 3. Use service to create site | ||
const { deployment } = await this.infraService.createSite( | ||
foundUser, | ||
foundIsomerRequester, | ||
foundOwner, | ||
siteName, | ||
repoName | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: could we do a strip on the string?
worried if ops put space then the string equality operation fails and it registers as new email
(maybe this error case is captured downstream)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, added in 80cfbbd