Skip to content
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

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open

Conversation

rgu0114
Copy link
Contributor

@rgu0114 rgu0114 commented Mar 30, 2024

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 the pendingUsers 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:

  • Node version 18.20.0 (v18 required for firebase-tools) + added to Firebase runtime
  • Firebase Admin SDK version 12.0.0
  • Firebase Functions version 4.8.2
  • Mailtrap version 3.3.0
  • TypeScript version 4.1.6

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

  • open to feedback on what the email prompt should look like – this was just a basic version to get things working

Breaking Changes

  • these newer Firebase versions may not be compatible with previous versions, and other Firebase Functions may need to be updated to work well (style wise or functionality wise)
  • I have updated the documentation accordingly.
  • My PR adds a @ts-ignore

@rgu0114 rgu0114 requested a review from a team as a code owner March 30, 2024 19:04
@dti-github-bot
Copy link
Member

dti-github-bot commented Mar 30, 2024

[diff-counting] Significant lines: 34.

@rgu0114 rgu0114 changed the title [Draft] prof ta invite email Professor/TA Invite Email Mar 31, 2024
Copy link
Contributor

@stevenyuser stevenyuser left a 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"

Copy link
Contributor

@NIDHI2023 NIDHI2023 left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants