Minor - Plugins: Zoom - Add host email + add alternative hosts WIP

BT#17288
pull/3439/head
Julio Montoya 6 years ago
parent 5dd04ed09d
commit e08fc6a545
  1. 27
      plugin/zoom/endpoint.php
  2. 3
      plugin/zoom/lib/API/BaseMeetingTrait.php
  3. 70
      plugin/zoom/lib/ZoomPlugin.php

@ -44,41 +44,38 @@ if ($object->id) {
$meeting = $meetingRepository->findOneBy(['meetingId' => $object->id]);
}
$activity = null;
if ($meeting) {
$activity = new MeetingActivity();
$activity->setName($action);
$activity->setType($objectType);
$activity->setEvent(json_encode($object));
if (null === $meeting) {
error_log("Meeting not found");
error_log(sprintf('Event "%s" on %s was unhandled: %s', $action, $objectType, $body));
http_response_code(Response::HTTP_NOT_FOUND);
exit;
}
$activity = new MeetingActivity();
$activity->setName($action);
$activity->setType($objectType);
$activity->setEvent(json_encode($object));
switch ($objectType) {
case 'meeting':
$registrantRepository = $em->getRepository(Registrant::class);
if (null === $meeting) {
exit;
}
error_log('Meeting '.$action.' - '.$meeting->getId());
error_log(print_r($object, 1));
switch ($action) {
case 'deleted':
$em->remove($meeting);
$em->flush();
exit;
break;
case 'ended':
case 'started':
$meeting->setStatus($action);
$meeting->addActivity($activity);
$em->persist($meeting);
break;
default:
$meeting->addActivity($activity);
$em->persist($meeting);
break;
}
$em->persist($meeting);
$em->flush();
break;
case 'recording':

@ -27,4 +27,7 @@ trait BaseMeetingTrait
/** @var string description */
public $agenda;
/** @var string description */
public $host_email;
}

@ -762,7 +762,7 @@ class ZoomPlugin extends Plugin
}
try {
$newMeeting = $this->scheduleMeeting(
$newMeeting = $this->createScheduleMeeting(
$user,
$course,
$group,
@ -1222,17 +1222,17 @@ class ZoomPlugin extends Plugin
*/
private function createMeetingFromMeeting($meeting)
{
$approvalType = $meeting->getMeetingInfoGet()->settings->approval_type;
$meeting->getMeetingInfoGet()->settings->auto_recording = 'true' === $this->get('enableCloudRecording')
? 'cloud'
: 'local';
$meeting->getMeetingInfoGet()->settings->registrants_email_notification = false;
$meeting->setMeetingInfoGet($meeting->getMeetingInfoGet()->create());
$meeting->getMeetingInfoGet()->settings->approval_type = $approvalType;
$currentUser = api_get_user_entity(api_get_user_id());
$meeting->getMeetingInfoGet()->host_email = $currentUser->getEmail();
$meeting->getMeetingInfoGet()->settings->contact_email = $currentUser->getEmail();
$meeting->getMeetingInfoGet()->settings->contact_name = $currentUser->getFullname();
$recording = 'true' === $this->get('enableCloudRecording') ? 'cloud' : 'local';
$meeting->getMeetingInfoGet()->settings->auto_recording = $recording;
$meeting->getMeetingInfoGet()->settings->registrants_email_notification = false;
$meeting->getMeetingInfoGet()->settings->alternative_hosts = $currentUser->getEmail();
// Send create to Zoom.
$meeting->setMeetingInfoGet($meeting->getMeetingInfoGet()->create());
Database::getManager()->persist($meeting);
Database::getManager()->flush();
@ -1240,6 +1240,31 @@ class ZoomPlugin extends Plugin
return $meeting;
}
/**
* @throws Exception
*
* @return Meeting
*/
private function createGlobalMeeting()
{
$meetingInfoGet = MeetingInfoGet::fromTopicAndType(
$this->get_lang('GlobalMeeting'),
MeetingInfoGet::TYPE_SCHEDULED
);
$meetingInfoGet->start_time = (new DateTime())->format(DateTimeInterface::ISO8601);
$meetingInfoGet->duration = 60;
$meetingInfoGet->settings->approval_type =
('true' === $this->get('enableParticipantRegistration'))
? MeetingSettings::APPROVAL_TYPE_AUTOMATICALLY_APPROVE
: MeetingSettings::APPROVAL_TYPE_NO_REGISTRATION_REQUIRED;
// $meetingInfoGet->settings->host_video = true;
$meetingInfoGet->settings->participant_video = true;
$meetingInfoGet->settings->join_before_host = true;
$meetingInfoGet->settings->registrants_email_notification = false;
return $this->createMeetingFromMeeting((new Meeting())->setMeetingInfoGet($meetingInfoGet));
}
/**
* Schedules a meeting and returns it.
* set $course, $session and $user to null in order to create a global meeting.
@ -1257,7 +1282,7 @@ class ZoomPlugin extends Plugin
*
* @return Meeting meeting
*/
private function scheduleMeeting(
private function createScheduleMeeting(
$user,
$course,
$group,
@ -1299,29 +1324,4 @@ class ZoomPlugin extends Plugin
{
$this->registerUsers($meeting, $meeting->getRegistrableUsers());
}
/**
* @throws Exception
*
* @return Meeting
*/
private function createGlobalMeeting()
{
$meetingInfoGet = MeetingInfoGet::fromTopicAndType(
$this->get_lang('GlobalMeeting'),
MeetingInfoGet::TYPE_SCHEDULED
);
$meetingInfoGet->start_time = (new DateTime())->format(DateTimeInterface::ISO8601);
$meetingInfoGet->duration = 60;
$meetingInfoGet->settings->approval_type =
('true' === $this->get('enableParticipantRegistration'))
? MeetingSettings::APPROVAL_TYPE_AUTOMATICALLY_APPROVE
: MeetingSettings::APPROVAL_TYPE_NO_REGISTRATION_REQUIRED;
// $meetingInfoGet->settings->host_video = true;
$meetingInfoGet->settings->participant_video = true;
$meetingInfoGet->settings->join_before_host = true;
$meetingInfoGet->settings->registrants_email_notification = false;
return $this->createMeetingFromMeeting((new Meeting())->setMeetingInfoGet($meetingInfoGet));
}
}

Loading…
Cancel
Save