Conversation
|
[diff-counting] Significant lines: 34. |
…itialized in function call, disable eslint no logging
stevenyuser
left a comment
There was a problem hiding this comment.
The firebase cloud function onPendingUserCreate looks good to me.
A possible improvement is to put more information in the email (i.e. what course the pending user was invited/imported in), so that the professor knows which course they've been invited to sign up for.
We already have some of this information in the documents of "pendingUsers/{userEmail}" as under the roles property, we store [course.courseId]: role (as shown here). However, I think we would need to create another field with course name, which won't be hard, as we already pass a FireCourse into the function.
Afterwards, we could add some code in the text of the email to something like: "You've been invited to be a [role] in [course name] on QueueMeIn! Click here to sign up: https://queueme.in"
NIDHI2023
left a comment
There was a problem hiding this comment.
I agree with Steven's comment, adding the role and course name would improve the email message and make it more specific. I also think it's definitely better to use a .env file instead of functions.config to adhere to code standards.
Summary
This PR addresses this task
When an administrator adds email(s) that don't have a corresponding user in the QMI database, we automatically send that address an email inviting them to join QMI and prompting them to sign in and create an account.
Every time a new user is added to "pending users" this email will be sent.
Test Plan
Testing using the dev test emulator is shown below. We create a "pending users" collection and add a new user document to simulate an unknown user being added to the "pending users" collection on prod. Several seconds after that happens, an invitation email appears in the potential new user's inbox.
email-invite-dev-test.mov
Prod testing will be included later but should work based on the testing I've done so far
Technical Notes
One option for calling Firebase Cloud Functions is Cloud Firestore triggers, which handle events related to specific collections/documents. We attach an
onDocumentCreatedevent handler to thependingUserscollection that gets triggered every time a new document gets added, which corresponds exactly to every time an email was added to a course but didn't exist in the QMI database.Dependency requirements:
As part of shifting towards using 2nd Gen Firebase Functions (compatible with newer Node versions), we will be using .env files instead of functions.config. The full .env file with the Mailtrap token and previously existing Twilio authenticators will be posted on Notion.
Other Notes
Breaking Changes