Skip to content

Instantly share code, notes, and snippets.

@thunder775
Last active December 20, 2021 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thunder775/dce426b8d1165f20fe86679cd443959c to your computer and use it in GitHub Desktop.
Save thunder775/dce426b8d1165f20fe86679cd443959c to your computer and use it in GitHub Desktop.
export const videoCallLinksCtrl = {
async create(meeting, params) {
const existingMeeting = await meetingsDao.get(meeting._id)
if (meeting.videoCallLink) {
return existingMeeting;
}
const {courseId} = meeting;
const course = await coursesDao.get(courseId);
const {teacherId} = course;
const teacher = await teacherApi.getTeacher(teacherId);
if (teacher.isVideoCallEnabled) {
const enrolledStudentIds = await findEnrolledStudentIds(course, moment(meeting.startTime));
const enrolledStudents = await userApi.getUsersById(enrolledStudentIds);
const areStudentsVideoCallEnabled = enrolledStudents.every(student => student.isVideoCallEnabled);
if (areStudentsVideoCallEnabled) {
const token = jwt.sign({_id: meeting._id}, jitsi.secret, {});
meeting.videoCallLink = "https://call.cerah.co/" + token.toLowerCase();
return meetingsDao.update(meeting._id, {...existingMeeting, videoCallLink: meeting.videoCallLink}, {});
}
}
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment