-
Notifications
You must be signed in to change notification settings - Fork 0
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
Professor/TA Invite Email #823
base: master
Are you sure you want to change the base?
Conversation
[diff-counting] Significant lines: 34. |
…itialized in function call, disable eslint no logging
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.
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"
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.
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
onDocumentCreated
event handler to thependingUsers
collection 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