Last active
December 20, 2021 09:29
-
-
Save thunder775/dce426b8d1165f20fe86679cd443959c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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