Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/eventHandlers/InterviewEventHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ async function sendInterviewScheduledNotifications (payload) {
const data = await notificationsSchedulerService.getDataForInterview(interviewEntity)
if (!data) { return }

const { meeting, zoomAccountApiKey } = await generateZoomMeetingLink(interviewEntity.startTimestamp, interviewEntity.duration, interviewEntity.guestTimezone || interviewEntity.hostTimezone)
const { meeting, zoomAccountApiKey } = await generateZoomMeetingLink(interviewEntity.startTimestamp, interviewEntity.duration)

const updatedInterview = await interviewEntity.update({ zoomAccountApiKey, zoomMeetingId: meeting.id })
await processUpdateInterview(updatedInterview.toJSON())
Expand Down Expand Up @@ -259,7 +259,7 @@ async function sendInterviewRescheduledNotifications (payload) {
const data = await notificationsSchedulerService.getDataForInterview(interviewEntity)
if (!data) { return }

await updateZoomMeeting(interviewEntity.startTimestamp, interviewEntity.duration, interviewEntity.zoomAccountApiKey, interviewEntity.zoomMeetingId, interviewEntity.guestTimezone || interviewEntity.hostTimezone)
await updateZoomMeeting(interviewEntity.startTimestamp, interviewEntity.duration, interviewEntity.zoomAccountApiKey, interviewEntity.zoomMeetingId)

const interviewCancelLink = `${config.TAAS_APP_BASE_URL}/interview/${interview.id}/cancel`
const interviewRescheduleLink = `${config.TAAS_APP_BASE_URL}/interview/${interview.id}/reschedule`
Expand Down
18 changes: 7 additions & 11 deletions src/services/ZoomService.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const _ = require('lodash')
const axios = require('axios')
const jwt = require('jsonwebtoken')
const config = require('config')
const moment = require('moment')

// get & parse all Zoom account credentials in an in-memory array
const ALL_ZOOM_ACCOUNTS = _.split(config.ZOOM_ACCOUNTS, ',')
Expand Down Expand Up @@ -66,18 +67,16 @@ async function generateZoomJWTBearerAccessToken (apiKey) {
*
* @param {Date} startTime the start time of the meeting
* @param {Integer} duration the duration of the meeting
* @param {String} timezone the timezone of the meeting
* @returns Zoom API response
*/
async function createZoomMeeting (startTime, duration, timezone) {
async function createZoomMeeting (startTime, duration) {
const { accessToken, zoomAccountApiKey } = await generateZoomJWTBearerAccessToken()

// POST request details in Zoom API docs:
// https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingcreate
const res = await axios.post('https://api.zoom.us/v2/users/me/meetings', {
type: 2,
start_time: startTime.toISOString(),
timezone,
start_time: moment(startTime).utc().format(),
duration
}, {
headers: {
Expand All @@ -96,12 +95,11 @@ async function createZoomMeeting (startTime, duration, timezone) {
*
* @param {Date} startTime the start time of the meeting
* @param {Integer} duration the duration of the meeting
* @param {String} timezone the timezone of the meeting
* @returns The meeting urls for the Zoom meeting
*/
async function generateZoomMeetingLink (startTime, duration, timezone) {
async function generateZoomMeetingLink (startTime, duration) {
try {
const { meeting, zoomAccountApiKey } = await createZoomMeeting(startTime, duration, timezone)
const { meeting, zoomAccountApiKey } = await createZoomMeeting(startTime, duration)

// learn more: https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingcreate#responses
console.log(meeting.start_url, 'Zoom meeting link for host')
Expand All @@ -121,16 +119,14 @@ async function generateZoomMeetingLink (startTime, duration, timezone) {
* @param {Integer} duration the duration of the meeting
* @param {String} apiKey zoom account api key
* @param {Integer} zoomMeetingId zoom meeting id
* @param {String} timezone the timezone of the meeting
* @returns {undefined}
*/
async function updateZoomMeeting (startTime, duration, zoomAccountApiKey, zoomMeetingId, timezone) {
async function updateZoomMeeting (startTime, duration, zoomAccountApiKey, zoomMeetingId) {
const { accessToken } = await generateZoomJWTBearerAccessToken(zoomAccountApiKey)
// PATCH request details in Zoom API docs:
// https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingupdate
await axios.patch(`https://api.zoom.us/v2/meetings/${zoomMeetingId}`, {
start_time: startTime.toISOString(),
timezone,
start_time: moment(startTime).utc().format(),
duration
}, {
headers: {
Expand Down