icssc / AntAlmanac

A course exploration and scheduling tool for UCI Anteaters
https://antalmanac.com
MIT License
55 stars 62 forks source link

Nodemailer Email Implementation #981

Open MinhxNguyen7 opened 2 months ago

MinhxNguyen7 commented 2 months ago

@ap0nia please add notes.

ap0nia commented 2 months ago

Steps

  1. Get Google refresh token for OAuth project, e.g. via Google Developer Playground -- I can provide this.
  2. Install nodemailer npm package.
  3. Write a function that can send an email, based on the provided interface below.
  4. To test this, can make it an endpoint on the backend (can ask for help if needed).
  5. Report back for next steps.

Details

Function signature

// Map user ID to section codes that the user is subscribed to.
export const exampleDb = {
  user1: {
    subscriptions: [1, 2, 3],
    email: 'user1@gmail.com'
  },
  user2: {
    subscriptions: [1, 5, 9],
    email: 'user2@gmail.com',
  },
  user3: {
    subscriptions: [2, 7, 9],
    email: 'user3@gmail.com',
}

// Information 
export type ClassUpdate = { 
  section: number
  status: string
}

export type NotifyParams = {
  updates: ClassUpdate[]
}

import nodemailer from 'nodemailer'

async function notify(params: NotifyParams) {
  //
}