- Implemented
approveMeetingcontroller. - Updates meeting status to
"upcoming". - Fetches user from DB via
meeting.userId. - Uses stored
accessTokento create a Google Calendar event.
- Used
googleapisto authenticate with Google usingaccessToken. - Created event on user's primary Google Calendar with:
summary(title)description(meeting with user)startandendtimes- Timezone:
"Asia/Kolkata"
- Handled missing times and error cases.
- Parameters:
accessTokenstartDateTime,endDateTimetitle,descriptionlocation,attendees(optional)
- Added default reminders and safety checks.
- ✅ Fix: Corrected argument structure passed to
createCalendarEvent.
- ✅ Fix: Missing scopes during Google OAuth.
- Updated passport strategy to request:
passport.authenticate("google", { scope: [ "profile", "email", "https://www.googleapis.com/auth/calendar", "https://www.googleapis.com/auth/calendar.events", ], accessType: "offline", prompt: "consent", });
- ✅ Fix: Enabled the Google Calendar API from Google Cloud Console for project ID
519134446809.
- Goal: Auto-generate Google Meet links for events.
- Steps:
- Enable Google Calendar API and Google Meet Conference in the Google Cloud Console.
- Update
createCalendarEventto include:conferenceDataVersion: 1, requestBody: { conferenceData: { createRequest: { requestId: "some-unique-id", // e.g. uuid() conferenceSolutionKey: { type: "hangoutsMeet" }, }, }, }
- ✅
approveMeeting.js– Controller logic for approving meeting & syncing with calendar. - ✅
createCalendarEvent.js– Calendar helper with customizable parameters. - ✅
passport.js– OAuth2 strategy updated with correct scopes. - ✅
auth.js– Login route via Google with updated OAuth2 flow.
- Integrated
Meetingschema with fields likeuserId,title,selectDay,selectTime,slot,type,user_role,startDateTime,endDateTime,eventId, andmeetingLink. - Stored user details with
accessTokenandrefreshTokenfor Google Calendar integration.
- Implemented calendar event creation using OAuth2 credentials and refresh tokens.
- Stored
eventIdandmeetingLinkfrom Google Calendar when an event is created.
- Handled rescheduling logic without creating a new event.
- Updated the existing event and reset
startDateTimeandendDateTimetonullafter reschedule request.
-
Created
deleteCalendarEvent()utility:- Accepts
eventIdandrefreshToken. - Uses OAuth2 to authenticate and delete the event from the user's Google Calendar.
- Accepts
-
Enhanced
deleteMeeting()controller:- Fetches the meeting by
id. - Gets the user by
userIdfrom the meeting. - Checks if
eventIdexists:- If yes: Deletes event from Google Calendar using
refreshToken. - If no: Proceeds to delete the meeting directly.
- If yes: Deletes event from Google Calendar using
- Deletes the meeting document from MongoDB.
- Returns appropriate success or error response.
- Fetches the meeting by
- Ensured robust error handling and logging.
- Maintained clean API response structure with
success,message, anddata.
Next Steps (Optional):
- Add audit logs or notifications.
- Implement admin panel to view and manage all meetings.
- Schedule email reminders using
node-cronor similar scheduler.