Import assets from MUX
Added new endpoints POST api/v1/summits/{id}/presentations/all/import/mux payload * mux_token_id ( string|required) * mux_token_secret ( string|required) * email_to (optional|email) required scopes REALM_URL/summits/write REALM_URL/summits/write-event REALM_URL/summits/write-presentation Change-Id: If3af7466f5c2fd1a38e1129fecd7e0b86312590e Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
parent
95f7b0b3df
commit
4432a5f2b9
@ -0,0 +1,35 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
/**
|
||||
* Copyright 2021 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Class PresentationLinkValidationRulesFactory
|
||||
* @package App\Http\Controllers
|
||||
*/
|
||||
final class PresentationLinkValidationRulesFactory
|
||||
{
|
||||
public static function build(array $data, $update = false)
|
||||
{
|
||||
|
||||
$former_rules = PresentationMaterialValidationRulesFactory::build($data, $update);
|
||||
if ($update) {
|
||||
return array_merge($former_rules, [
|
||||
'link' => 'sometimes|required|url',
|
||||
]);
|
||||
}
|
||||
|
||||
return array_merge($former_rules, [
|
||||
'link' => 'required|url',
|
||||
]);
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
/**
|
||||
* Copyright 2021 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
* Class PresentationMaterialValidationRulesFactory
|
||||
* @package App\Http\Controllers
|
||||
*/
|
||||
final class PresentationMaterialValidationRulesFactory
|
||||
{
|
||||
public static function build(array $data, $update = false){
|
||||
|
||||
if($update){
|
||||
return [
|
||||
'name' => 'sometimes|required|string:512',
|
||||
'description' => 'sometimes|required|string',
|
||||
'display_on_site' => 'sometimes|required|boolean',
|
||||
'featured' => 'sometimes|required|boolean',
|
||||
'order' => 'sometimes|integer|min:1',
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'name' => 'sometimes|required|string:512',
|
||||
'description' => 'sometimes|required|string',
|
||||
'display_on_site' => 'sometimes|required|boolean',
|
||||
'featured' => 'sometimes|required|boolean',
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
/**
|
||||
* Copyright 2021 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Class PresentationSlideValidationRulesFactory
|
||||
* @package App\Http\Controllers
|
||||
*/
|
||||
final class PresentationSlideValidationRulesFactory
|
||||
{
|
||||
public static function build(array $data, $update = false)
|
||||
{
|
||||
|
||||
$former_rules = PresentationMaterialValidationRulesFactory::build($data,$update);
|
||||
if ($update) {
|
||||
return array_merge($former_rules, [
|
||||
'link' => 'nullable|url',
|
||||
]);
|
||||
}
|
||||
|
||||
return array_merge($former_rules, [
|
||||
'file' => 'required_without_all:link,filepath',
|
||||
'link' => 'required_without_all:file,filepath|url',
|
||||
'filepath' => 'required_without_all:link,file',
|
||||
]);
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
/**
|
||||
* Copyright 2021 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Class PresentationVideoValidationRulesFactory
|
||||
* @package App\Http\Controllers
|
||||
*/
|
||||
final class PresentationVideoValidationRulesFactory
|
||||
{
|
||||
public static function build(array $data, $update = false)
|
||||
{
|
||||
|
||||
$former_rules = PresentationMaterialValidationRulesFactory::build($data,$update);
|
||||
if ($update) {
|
||||
return array_merge($former_rules, [
|
||||
'youtube_id' => 'required_without:external_url|alpha_dash',
|
||||
'external_url' => 'required_without:youtube_id|string:512|url',
|
||||
]);
|
||||
}
|
||||
|
||||
return array_merge($former_rules, [
|
||||
'youtube_id' => 'required_without:external_url|alpha_dash',
|
||||
'external_url' => 'required_without:youtube_id|string:512|url',
|
||||
]);
|
||||
}
|
||||
}
|
@ -11,8 +11,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use App\Http\Utils\FileTypes;
|
||||
use App\Http\Utils\MultipartFormDataCleaner;
|
||||
use App\Jobs\VideoStreamUrlMUXProcessingForSummitJob;
|
||||
use App\Models\Foundation\Main\IGroup;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use libs\utils\HTMLCleaner;
|
||||
@ -32,6 +34,7 @@ use models\summit\Presentation;
|
||||
use models\utils\IEntity;
|
||||
use ModelSerializers\SerializerRegistry;
|
||||
use services\model\IPresentationService;
|
||||
|
||||
/**
|
||||
* Class OAuth2PresentationApiController
|
||||
* @package App\Http\Controllers
|
||||
@ -77,16 +80,17 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
{
|
||||
parent::__construct($resource_server_context);
|
||||
$this->presentation_repository = $presentation_repository;
|
||||
$this->presentation_service = $presentation_service;
|
||||
$this->member_repository = $member_repository;
|
||||
$this->summit_repository = $summit_repository;
|
||||
$this->presentation_service = $presentation_service;
|
||||
$this->member_repository = $member_repository;
|
||||
$this->summit_repository = $summit_repository;
|
||||
}
|
||||
|
||||
//presentations
|
||||
|
||||
//videos
|
||||
|
||||
public function getPresentationVideos($summit_id, $presentation_id){
|
||||
public function getPresentationVideos($summit_id, $presentation_id)
|
||||
{
|
||||
try {
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
@ -98,10 +102,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$videos = $presentation->getVideos();
|
||||
|
||||
$items = [];
|
||||
foreach($videos as $i)
|
||||
{
|
||||
if($i instanceof IEntity)
|
||||
{
|
||||
foreach ($videos as $i) {
|
||||
if ($i instanceof IEntity) {
|
||||
$i = SerializerRegistry::getInstance()->getSerializer($i)->serialize();
|
||||
}
|
||||
$items[] = $i;
|
||||
@ -121,7 +123,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $video_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function getPresentationVideo($summit_id, $presentation_id, $video_id){
|
||||
public function getPresentationVideo($summit_id, $presentation_id, $video_id)
|
||||
{
|
||||
try {
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
@ -148,33 +151,25 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $presentation_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function addVideo(LaravelRequest $request, $summit_id, $presentation_id){
|
||||
public function addVideo(LaravelRequest $request, $summit_id, $presentation_id)
|
||||
{
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
if(!Request::isJson()) return $this->error400();
|
||||
if (!Request::isJson()) return $this->error400();
|
||||
|
||||
$data = Input::json();
|
||||
|
||||
$rules =
|
||||
[
|
||||
'youtube_id' => 'required|alpha_dash',
|
||||
'name' => 'sometimes|required|string:512',
|
||||
'description' => 'sometimes|required|string',
|
||||
'featured' => 'sometimes|required|boolean',
|
||||
'display_on_site' => 'sometimes|required|boolean',
|
||||
];
|
||||
|
||||
$data = $data->all();
|
||||
// Creates a Validator instance and validates the data.
|
||||
$validation = Validator::make($data, $rules);
|
||||
$validation = Validator::make($data, PresentationVideoValidationRulesFactory::build($data));
|
||||
|
||||
if ($validation->fails()) {
|
||||
$ex = new ValidationException;
|
||||
$ex->setMessages($validation->messages()->toArray());
|
||||
throw $ex;
|
||||
$ex = new ValidationException;
|
||||
$ex->setMessages($validation->messages()->toArray());
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
$fields = [
|
||||
@ -185,19 +180,13 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$video = $this->presentation_service->addVideoTo($presentation_id, HTMLCleaner::cleanData($data, $fields));
|
||||
|
||||
return $this->created(SerializerRegistry::getInstance()->getSerializer($video)->serialize());
|
||||
}
|
||||
catch (EntityNotFoundException $ex1)
|
||||
{
|
||||
} catch (EntityNotFoundException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2)
|
||||
{
|
||||
} catch (ValidationException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
@ -210,28 +199,19 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $video_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function updateVideo(LaravelRequest $request, $summit_id, $presentation_id, $video_id){
|
||||
public function updateVideo(LaravelRequest $request, $summit_id, $presentation_id, $video_id)
|
||||
{
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
if(!Request::isJson()) return $this->error400();
|
||||
if (!Request::isJson()) return $this->error400();
|
||||
|
||||
$data = Input::json();
|
||||
|
||||
$rules = [
|
||||
'youtube_id' => 'required|alpha_dash',
|
||||
'name' => 'sometimes|required|string:512',
|
||||
'description' => 'sometimes|required|string',
|
||||
'display_on_site' => 'sometimes|required|boolean',
|
||||
'featured' => 'sometimes|required|boolean',
|
||||
'order' => 'sometimes|integer|min:1',
|
||||
];
|
||||
|
||||
$data = $data->all();
|
||||
// Creates a Validator instance and validates the data.
|
||||
$validation = Validator::make($data, $rules);
|
||||
$validation = Validator::make($data, PresentationVideoValidationRulesFactory::build($data, true));
|
||||
|
||||
if ($validation->fails()) {
|
||||
$ex = new ValidationException;
|
||||
@ -247,19 +227,13 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$video = $this->presentation_service->updateVideo($presentation_id, $video_id, HTMLCleaner::cleanData($data, $fields));
|
||||
|
||||
return $this->updated(SerializerRegistry::getInstance()->getSerializer($video)->serialize());
|
||||
}
|
||||
catch (EntityNotFoundException $ex1)
|
||||
{
|
||||
} catch (EntityNotFoundException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2)
|
||||
{
|
||||
} catch (ValidationException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
@ -271,7 +245,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $video_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function deleteVideo($summit_id, $presentation_id, $video_id){
|
||||
public function deleteVideo($summit_id, $presentation_id, $video_id)
|
||||
{
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
@ -280,19 +255,13 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$this->presentation_service->deleteVideo($presentation_id, $video_id);
|
||||
|
||||
return $this->deleted();
|
||||
}
|
||||
catch (EntityNotFoundException $ex1)
|
||||
{
|
||||
} catch (EntityNotFoundException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2)
|
||||
{
|
||||
} catch (ValidationException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
@ -302,13 +271,14 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $summit_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function submitPresentation($summit_id){
|
||||
public function submitPresentation($summit_id)
|
||||
{
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
if(!Request::isJson()) return $this->error400();
|
||||
if (!Request::isJson()) return $this->error400();
|
||||
|
||||
$current_member = $this->resource_server_context->getCurrentUser();
|
||||
if (is_null($current_member)) return $this->error403();
|
||||
@ -334,19 +304,13 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$presentation = $this->presentation_service->submitPresentation($summit, HTMLCleaner::cleanData($data, $fields));
|
||||
|
||||
return $this->created(SerializerRegistry::getInstance()->getSerializer($presentation)->serialize(Request::input('expand', '')));
|
||||
}
|
||||
catch (EntityNotFoundException $ex1)
|
||||
{
|
||||
} catch (EntityNotFoundException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error404(['message' => $ex1->getMessage()]);
|
||||
}
|
||||
catch (ValidationException $ex2)
|
||||
{
|
||||
} catch (ValidationException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
@ -357,13 +321,14 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $presentation_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function updatePresentationSubmission($summit_id, $presentation_id){
|
||||
public function updatePresentationSubmission($summit_id, $presentation_id)
|
||||
{
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
if(!Request::isJson()) return $this->error400();
|
||||
if (!Request::isJson()) return $this->error400();
|
||||
|
||||
$current_member = $this->resource_server_context->getCurrentUser();
|
||||
if (is_null($current_member)) return $this->error403();
|
||||
@ -372,7 +337,7 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
|
||||
$data = $data->all();
|
||||
// Creates a Validator instance and validates the data.
|
||||
$validation = Validator::make($data, SummitEventValidationRulesFactory::buildForSubmission($data. true));
|
||||
$validation = Validator::make($data, SummitEventValidationRulesFactory::buildForSubmission($data . true));
|
||||
|
||||
if ($validation->fails()) {
|
||||
$ex = new ValidationException;
|
||||
@ -395,19 +360,13 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
);
|
||||
|
||||
return $this->updated(SerializerRegistry::getInstance()->getSerializer($presentation)->serialize(Request::input('expand', '')));
|
||||
}
|
||||
catch (EntityNotFoundException $ex1)
|
||||
{
|
||||
} catch (EntityNotFoundException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2)
|
||||
{
|
||||
} catch (ValidationException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
@ -418,7 +377,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $presentation_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function completePresentationSubmission($summit_id, $presentation_id){
|
||||
public function completePresentationSubmission($summit_id, $presentation_id)
|
||||
{
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
@ -434,19 +394,13 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
);
|
||||
|
||||
return $this->updated(SerializerRegistry::getInstance()->getSerializer($presentation)->serialize(Request::input('expand', '')));
|
||||
}
|
||||
catch (EntityNotFoundException $ex1)
|
||||
{
|
||||
} catch (EntityNotFoundException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2)
|
||||
{
|
||||
} catch (ValidationException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
@ -457,7 +411,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $presentation_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function deletePresentation($summit_id, $presentation_id){
|
||||
public function deletePresentation($summit_id, $presentation_id)
|
||||
{
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
@ -489,7 +444,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $presentation_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function getPresentationSlides($summit_id, $presentation_id){
|
||||
public function getPresentationSlides($summit_id, $presentation_id)
|
||||
{
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
@ -502,10 +458,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$slides = $presentation->getSlides();
|
||||
|
||||
$items = [];
|
||||
foreach($slides as $i)
|
||||
{
|
||||
if($i instanceof IEntity)
|
||||
{
|
||||
foreach ($slides as $i) {
|
||||
if ($i instanceof IEntity) {
|
||||
$i = SerializerRegistry::getInstance()->getSerializer($i)->serialize();
|
||||
}
|
||||
$items[] = $i;
|
||||
@ -531,7 +485,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $slide_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function getPresentationSlide($summit_id, $presentation_id, $slide_id){
|
||||
public function getPresentationSlide($summit_id, $presentation_id, $slide_id)
|
||||
{
|
||||
try {
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
@ -558,7 +513,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $presentation_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function addPresentationSlide(LaravelRequest $request, $summit_id, $presentation_id){
|
||||
public function addPresentationSlide(LaravelRequest $request, $summit_id, $presentation_id)
|
||||
{
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
@ -567,12 +523,12 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$current_member = $this->resource_server_context->getCurrentUser();
|
||||
if (is_null($current_member)) return $this->error403();
|
||||
$isAdmin = $current_member->isAdmin() || $current_member->hasPermissionForOnGroup($summit, IGroup::SummitAdministrators);
|
||||
if(!$isAdmin){
|
||||
if (!$isAdmin) {
|
||||
// check if we could edit presentation
|
||||
$presentation = $summit->getEvent($presentation_id);
|
||||
if(is_null($presentation) || !$presentation instanceof Presentation)
|
||||
if (is_null($presentation) || !$presentation instanceof Presentation)
|
||||
return $this->error404();
|
||||
if(!$current_member->hasSpeaker() || !$presentation->canEdit($current_member->getSpeaker()))
|
||||
if (!$current_member->hasSpeaker() || !$presentation->canEdit($current_member->getSpeaker()))
|
||||
return $this->error403();
|
||||
}
|
||||
|
||||
@ -580,18 +536,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$data = MultipartFormDataCleaner::cleanBool('display_on_site', $data);
|
||||
$data = MultipartFormDataCleaner::cleanBool('featured', $data);
|
||||
|
||||
$rules = [
|
||||
'file' => 'required_without_all:link,filepath',
|
||||
'link' => 'required_without_all:file,filepath|url',
|
||||
'filepath' => 'required_without_all:link,file',
|
||||
'name' => 'required|string:512',
|
||||
'description' => 'nullable|string',
|
||||
'display_on_site' => 'nullable|boolean',
|
||||
'featured' => 'nullable|boolean',
|
||||
];
|
||||
|
||||
// Creates a Validator instance and validates the data.
|
||||
$validation = Validator::make($data, $rules);
|
||||
$validation = Validator::make($data, PresentationSlideValidationRulesFactory::build($data));
|
||||
|
||||
if ($validation->fails()) {
|
||||
$ex = new ValidationException;
|
||||
@ -614,19 +560,13 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
);
|
||||
|
||||
return $this->created(SerializerRegistry::getInstance()->getSerializer($slide)->serialize());
|
||||
}
|
||||
catch (EntityNotFoundException $ex1)
|
||||
{
|
||||
} catch (EntityNotFoundException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2)
|
||||
{
|
||||
} catch (ValidationException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
@ -639,7 +579,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $slide_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function updatePresentationSlide(LaravelRequest $request, $summit_id, $presentation_id, $slide_id){
|
||||
public function updatePresentationSlide(LaravelRequest $request, $summit_id, $presentation_id, $slide_id)
|
||||
{
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
@ -648,12 +589,12 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$current_member = $this->resource_server_context->getCurrentUser();
|
||||
if (is_null($current_member)) return $this->error403();
|
||||
$isAdmin = $current_member->isAdmin() || $current_member->hasPermissionForOnGroup($summit, IGroup::SummitAdministrators);
|
||||
if(!$isAdmin){
|
||||
if (!$isAdmin) {
|
||||
// check if we could edit presentation
|
||||
$presentation = $summit->getEvent($presentation_id);
|
||||
if(is_null($presentation) || !$presentation instanceof Presentation)
|
||||
if (is_null($presentation) || !$presentation instanceof Presentation)
|
||||
return $this->error404();
|
||||
if(!$current_member->hasSpeaker() || !$presentation->canEdit($current_member->getSpeaker()))
|
||||
if (!$current_member->hasSpeaker() || !$presentation->canEdit($current_member->getSpeaker()))
|
||||
return $this->error403();
|
||||
}
|
||||
|
||||
@ -662,17 +603,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$data = MultipartFormDataCleaner::cleanBool('featured', $data);
|
||||
$data = MultipartFormDataCleaner::cleanInt('order', $data);
|
||||
|
||||
$rules = [
|
||||
'link' => 'nullable|url',
|
||||
'name' => 'nullable|string:512',
|
||||
'description' => 'nullable|string',
|
||||
'display_on_site' => 'nullable|boolean',
|
||||
'featured' => 'nullable|boolean',
|
||||
'order' => 'nullable|integer|min:1',
|
||||
];
|
||||
|
||||
// Creates a Validator instance and validates the data.
|
||||
$validation = Validator::make($data, $rules);
|
||||
$validation = Validator::make($data, PresentationSlideValidationRulesFactory::build($data, true));
|
||||
|
||||
if ($validation->fails()) {
|
||||
$ex = new ValidationException;
|
||||
@ -696,19 +628,13 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
);
|
||||
|
||||
return $this->updated(SerializerRegistry::getInstance()->getSerializer($slide)->serialize());
|
||||
}
|
||||
catch (EntityNotFoundException $ex1)
|
||||
{
|
||||
} catch (EntityNotFoundException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2)
|
||||
{
|
||||
} catch (ValidationException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
@ -720,7 +646,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $slide_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function deletePresentationSlide($summit_id, $presentation_id, $slide_id){
|
||||
public function deletePresentationSlide($summit_id, $presentation_id, $slide_id)
|
||||
{
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
@ -729,31 +656,25 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$current_member = $this->resource_server_context->getCurrentUser();
|
||||
if (is_null($current_member)) return $this->error403();
|
||||
$isAdmin = $current_member->isAdmin() || $current_member->hasPermissionForOnGroup($summit, IGroup::SummitAdministrators);
|
||||
if(!$isAdmin){
|
||||
if (!$isAdmin) {
|
||||
// check if we could edit presentation
|
||||
$presentation = $summit->getEvent($presentation_id);
|
||||
if(is_null($presentation) || !$presentation instanceof Presentation)
|
||||
if (is_null($presentation) || !$presentation instanceof Presentation)
|
||||
return $this->error404();
|
||||
if(!$current_member->hasSpeaker() || !$presentation->canEdit($current_member->getSpeaker()))
|
||||
if (!$current_member->hasSpeaker() || !$presentation->canEdit($current_member->getSpeaker()))
|
||||
return $this->error403();
|
||||
}
|
||||
|
||||
$this->presentation_service->deleteSlide($presentation_id, $slide_id);
|
||||
|
||||
return $this->deleted();
|
||||
}
|
||||
catch (EntityNotFoundException $ex1)
|
||||
{
|
||||
} catch (EntityNotFoundException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2)
|
||||
{
|
||||
} catch (ValidationException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
@ -766,7 +687,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $presentation_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function getPresentationLinks($summit_id, $presentation_id){
|
||||
public function getPresentationLinks($summit_id, $presentation_id)
|
||||
{
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
@ -779,10 +701,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$links = $presentation->getLinks();
|
||||
|
||||
$items = [];
|
||||
foreach($links as $i)
|
||||
{
|
||||
if($i instanceof IEntity)
|
||||
{
|
||||
foreach ($links as $i) {
|
||||
if ($i instanceof IEntity) {
|
||||
$i = SerializerRegistry::getInstance()->getSerializer($i)->serialize();
|
||||
}
|
||||
$items[] = $i;
|
||||
@ -808,7 +728,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $link_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function getPresentationLink($summit_id, $presentation_id, $link_id){
|
||||
public function getPresentationLink($summit_id, $presentation_id, $link_id)
|
||||
{
|
||||
try {
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
@ -835,7 +756,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $presentation_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function addPresentationLink(LaravelRequest $request, $summit_id, $presentation_id){
|
||||
public function addPresentationLink(LaravelRequest $request, $summit_id, $presentation_id)
|
||||
{
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
@ -844,12 +766,12 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$current_member = $this->resource_server_context->getCurrentUser();
|
||||
if (is_null($current_member)) return $this->error403();
|
||||
$isAdmin = $current_member->isAdmin() || $current_member->hasPermissionForOnGroup($summit, IGroup::SummitAdministrators);
|
||||
if(!$isAdmin){
|
||||
if (!$isAdmin) {
|
||||
// check if we could edit presentation
|
||||
$presentation = $summit->getEvent($presentation_id);
|
||||
if(is_null($presentation) || !$presentation instanceof Presentation)
|
||||
if (is_null($presentation) || !$presentation instanceof Presentation)
|
||||
return $this->error404();
|
||||
if(!$current_member->hasSpeaker() || !$presentation->canEdit($current_member->getSpeaker()))
|
||||
if (!$current_member->hasSpeaker() || !$presentation->canEdit($current_member->getSpeaker()))
|
||||
return $this->error403();
|
||||
}
|
||||
|
||||
@ -857,16 +779,9 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$data = MultipartFormDataCleaner::cleanBool('display_on_site', $data);
|
||||
$data = MultipartFormDataCleaner::cleanBool('featured', $data);
|
||||
|
||||
$rules = [
|
||||
'link' => 'required|url',
|
||||
'name' => 'required|string:512',
|
||||
'description' => 'nullable|string',
|
||||
'display_on_site' => 'nullable|boolean',
|
||||
'featured' => 'nullable|boolean',
|
||||
];
|
||||
|
||||
// Creates a Validator instance and validates the data.
|
||||
$validation = Validator::make($data, $rules);
|
||||
$validation = Validator::make($data, PresentationLinkValidationRulesFactory::build($data));
|
||||
|
||||
if ($validation->fails()) {
|
||||
$ex = new ValidationException;
|
||||
@ -882,19 +797,13 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$link = $this->presentation_service->addLinkTo($presentation_id, HTMLCleaner::cleanData($data, $fields));
|
||||
|
||||
return $this->created(SerializerRegistry::getInstance()->getSerializer($link)->serialize());
|
||||
}
|
||||
catch (EntityNotFoundException $ex1)
|
||||
{
|
||||
} catch (EntityNotFoundException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2)
|
||||
{
|
||||
} catch (ValidationException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
@ -907,7 +816,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $link_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function updatePresentationLink(LaravelRequest $request, $summit_id, $presentation_id, $link_id){
|
||||
public function updatePresentationLink(LaravelRequest $request, $summit_id, $presentation_id, $link_id)
|
||||
{
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
@ -916,12 +826,12 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$current_member = $this->resource_server_context->getCurrentUser();
|
||||
if (is_null($current_member)) return $this->error403();
|
||||
$isAdmin = $current_member->isAdmin() || $current_member->hasPermissionForOnGroup($summit, IGroup::SummitAdministrators);
|
||||
if(!$isAdmin){
|
||||
if (!$isAdmin) {
|
||||
// check if we could edit presentation
|
||||
$presentation = $summit->getEvent($presentation_id);
|
||||
if(is_null($presentation) || !$presentation instanceof Presentation)
|
||||
if (is_null($presentation) || !$presentation instanceof Presentation)
|
||||
return $this->error404();
|
||||
if(!$current_member->hasSpeaker() || !$presentation->canEdit($current_member->getSpeaker()))
|
||||
if (!$current_member->hasSpeaker() || !$presentation->canEdit($current_member->getSpeaker()))
|
||||
return $this->error403();
|
||||
}
|
||||
|
||||
@ -930,17 +840,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$data = MultipartFormDataCleaner::cleanBool('featured', $data);
|
||||
$data = MultipartFormDataCleaner::cleanInt('order', $data);
|
||||
|
||||
$rules = [
|
||||
'link' => 'sometimes|required|url',
|
||||
'name' => 'sometimes|required|string:512',
|
||||
'description' => 'nullable|string',
|
||||
'display_on_site' => 'nullable|boolean',
|
||||
'featured' => 'nullable|boolean',
|
||||
'order' => 'nullable|integer|min:1',
|
||||
];
|
||||
|
||||
// Creates a Validator instance and validates the data.
|
||||
$validation = Validator::make($data, $rules);
|
||||
$validation = Validator::make($data, PresentationLinkValidationRulesFactory::build($data, true));
|
||||
|
||||
if ($validation->fails()) {
|
||||
$ex = new ValidationException;
|
||||
@ -956,19 +857,13 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$link = $this->presentation_service->updateLink($presentation_id, $link_id, HTMLCleaner::cleanData($data, $fields));
|
||||
|
||||
return $this->updated(SerializerRegistry::getInstance()->getSerializer($link)->serialize());
|
||||
}
|
||||
catch (EntityNotFoundException $ex1)
|
||||
{
|
||||
} catch (EntityNotFoundException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2)
|
||||
{
|
||||
} catch (ValidationException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
@ -980,7 +875,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $link_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function deletePresentationLink($summit_id, $presentation_id, $link_id){
|
||||
public function deletePresentationLink($summit_id, $presentation_id, $link_id)
|
||||
{
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
@ -989,31 +885,25 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$current_member = $this->resource_server_context->getCurrentUser();
|
||||
if (is_null($current_member)) return $this->error403();
|
||||
$isAdmin = $current_member->isAdmin() || $current_member->hasPermissionForOnGroup($summit, IGroup::SummitAdministrators);
|
||||
if(!$isAdmin){
|
||||
if (!$isAdmin) {
|
||||
// check if we could edit presentation
|
||||
$presentation = $summit->getEvent($presentation_id);
|
||||
if(is_null($presentation) || !$presentation instanceof Presentation)
|
||||
if (is_null($presentation) || !$presentation instanceof Presentation)
|
||||
return $this->error404();
|
||||
if(!$current_member->hasSpeaker() || !$presentation->canEdit($current_member->getSpeaker()))
|
||||
if (!$current_member->hasSpeaker() || !$presentation->canEdit($current_member->getSpeaker()))
|
||||
return $this->error403();
|
||||
}
|
||||
|
||||
$this->presentation_service->deleteLink($presentation_id, $link_id);
|
||||
|
||||
return $this->deleted();
|
||||
}
|
||||
catch (EntityNotFoundException $ex1)
|
||||
{
|
||||
} catch (EntityNotFoundException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2)
|
||||
{
|
||||
} catch (ValidationException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
@ -1026,7 +916,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $presentation_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function getPresentationMediaUploads($summit_id, $presentation_id){
|
||||
public function getPresentationMediaUploads($summit_id, $presentation_id)
|
||||
{
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
@ -1039,10 +930,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$mediaUploads = $presentation->getMediaUploads();
|
||||
|
||||
$items = [];
|
||||
foreach($mediaUploads as $i)
|
||||
{
|
||||
if($i instanceof IEntity)
|
||||
{
|
||||
foreach ($mediaUploads as $i) {
|
||||
if ($i instanceof IEntity) {
|
||||
$i = SerializerRegistry::getInstance()->getSerializer($i)->serialize();
|
||||
}
|
||||
$items[] = $i;
|
||||
@ -1068,7 +957,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $media_upload_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function getPresentationMediaUpload($summit_id, $presentation_id, $media_upload_id){
|
||||
public function getPresentationMediaUpload($summit_id, $presentation_id, $media_upload_id)
|
||||
{
|
||||
try {
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
@ -1095,7 +985,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $presentation_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function addPresentationMediaUpload(LaravelRequest $request, $summit_id, $presentation_id){
|
||||
public function addPresentationMediaUpload(LaravelRequest $request, $summit_id, $presentation_id)
|
||||
{
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
@ -1106,13 +997,13 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$serializeType = SerializerRegistry::SerializerType_Private;
|
||||
|
||||
$isAdmin = $current_member->isAdmin() || $current_member->hasPermissionForOnGroup($summit, IGroup::SummitAdministrators);
|
||||
if(!$isAdmin){
|
||||
if (!$isAdmin) {
|
||||
$serializeType = SerializerRegistry::SerializerType_Public;
|
||||
// check if we could edit presentation
|
||||
$presentation = $summit->getEvent($presentation_id);
|
||||
if(is_null($presentation) || !$presentation instanceof Presentation)
|
||||
if (is_null($presentation) || !$presentation instanceof Presentation)
|
||||
return $this->error404();
|
||||
if(!$current_member->hasSpeaker() || !$presentation->canEdit($current_member->getSpeaker()))
|
||||
if (!$current_member->hasSpeaker() || !$presentation->canEdit($current_member->getSpeaker()))
|
||||
return $this->error403();
|
||||
}
|
||||
|
||||
@ -1156,19 +1047,13 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$relations
|
||||
)
|
||||
);
|
||||
}
|
||||
catch (EntityNotFoundException $ex1)
|
||||
{
|
||||
} catch (EntityNotFoundException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2)
|
||||
{
|
||||
} catch (ValidationException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
@ -1181,7 +1066,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $media_upload_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function updatePresentationMediaUpload(LaravelRequest $request, $summit_id, $presentation_id, $media_upload_id){
|
||||
public function updatePresentationMediaUpload(LaravelRequest $request, $summit_id, $presentation_id, $media_upload_id)
|
||||
{
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
@ -1191,13 +1077,13 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
if (is_null($current_member)) return $this->error403();
|
||||
$serializeType = SerializerRegistry::SerializerType_Private;
|
||||
$isAdmin = $current_member->isAdmin() || $current_member->hasPermissionForOnGroup($summit, IGroup::SummitAdministrators);
|
||||
if(!$isAdmin){
|
||||
if (!$isAdmin) {
|
||||
$serializeType = SerializerRegistry::SerializerType_Public;
|
||||
// check if we could edit presentation
|
||||
$presentation = $summit->getEvent($presentation_id);
|
||||
if(is_null($presentation) || !$presentation instanceof Presentation)
|
||||
if (is_null($presentation) || !$presentation instanceof Presentation)
|
||||
return $this->error404();
|
||||
if(!$current_member->hasSpeaker() || !$presentation->canEdit($current_member->getSpeaker()))
|
||||
if (!$current_member->hasSpeaker() || !$presentation->canEdit($current_member->getSpeaker()))
|
||||
return $this->error403();
|
||||
}
|
||||
|
||||
@ -1242,19 +1128,13 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$relations
|
||||
)
|
||||
);
|
||||
}
|
||||
catch (EntityNotFoundException $ex1)
|
||||
{
|
||||
} catch (EntityNotFoundException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2)
|
||||
{
|
||||
} catch (ValidationException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
@ -1266,7 +1146,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
* @param $media_upload_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function deletePresentationMediaUpload($summit_id, $presentation_id, $media_upload_id){
|
||||
public function deletePresentationMediaUpload($summit_id, $presentation_id, $media_upload_id)
|
||||
{
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
@ -1275,31 +1156,76 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$current_member = $this->resource_server_context->getCurrentUser();
|
||||
if (is_null($current_member)) return $this->error403();
|
||||
$isAdmin = $current_member->isAdmin() || $current_member->hasPermissionForOnGroup($summit, IGroup::SummitAdministrators);
|
||||
if(!$isAdmin){
|
||||
if (!$isAdmin) {
|
||||
// check if we could edit presentation
|
||||
$presentation = $summit->getEvent($presentation_id);
|
||||
if(is_null($presentation) || !$presentation instanceof Presentation)
|
||||
if (is_null($presentation) || !$presentation instanceof Presentation)
|
||||
return $this->error404();
|
||||
if(!$current_member->hasSpeaker() || !$presentation->canEdit($current_member->getSpeaker()))
|
||||
if (!$current_member->hasSpeaker() || !$presentation->canEdit($current_member->getSpeaker()))
|
||||
return $this->error403();
|
||||
}
|
||||
|
||||
$this->presentation_service->deleteMediaUpload($summit, intval($presentation_id), intval($media_upload_id));
|
||||
|
||||
return $this->deleted();
|
||||
}
|
||||
catch (EntityNotFoundException $ex1)
|
||||
{
|
||||
} catch (EntityNotFoundException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2)
|
||||
{
|
||||
} catch (ValidationException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function importAssetsFromMUX($summit_id)
|
||||
{
|
||||
try {
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
if (!Request::isJson()) return $this->error400();
|
||||
|
||||
$current_member = $this->resource_server_context->getCurrentUser();
|
||||
if (is_null($current_member)) return $this->error403();
|
||||
|
||||
$data = Input::json();
|
||||
$data = $data->all();
|
||||
// Creates a Validator instance and validates the data.
|
||||
$validation = Validator::make($data,[
|
||||
'mux_token_id' => 'required|string',
|
||||
'mux_token_secret' => 'required|string',
|
||||
'email_to' => 'sometimes|email',
|
||||
]);
|
||||
|
||||
if ($validation->fails()) {
|
||||
$ex = new ValidationException;
|
||||
$ex->setMessages($validation->messages()->toArray());
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
VideoStreamUrlMUXProcessingForSummitJob::dispatch(
|
||||
$summit_id,
|
||||
$data['mux_token_id'],
|
||||
$data['mux_token_secret'],
|
||||
$data['email_to'] ?? null
|
||||
)->delay(now()->addMinutes(1));
|
||||
|
||||
return $this->ok();
|
||||
|
||||
} catch (EntityNotFoundException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error404(['message' => $ex1->getMessage()]);
|
||||
} catch (ValidationException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
|
@ -440,6 +440,8 @@ Route::group([
|
||||
Route::group(['prefix' => 'presentations'], function () {
|
||||
// opened without role CFP - valid selection plan on CFP status
|
||||
Route::post('', 'OAuth2PresentationApiController@submitPresentation');
|
||||
// import from mux
|
||||
Route::post('all/import/mux', 'OAuth2PresentationApiController@importAssetsFromMUX');
|
||||
|
||||
Route::group(['prefix' => '{presentation_id}'], function () {
|
||||
|
||||
|
89
app/Jobs/CreateVideosFromMUXAssetsForSummitJob.php
Normal file
89
app/Jobs/CreateVideosFromMUXAssetsForSummitJob.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php namespace App\Jobs;
|
||||
/**
|
||||
* Copyright 2021 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use App\Services\Apis\MuxCredentials;
|
||||
use App\Services\Model\IPresentationVideoMediaUploadProcessor;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
/**
|
||||
* Class CreateVideosFromMUXAssetsForSummitJob
|
||||
* @package App\Jobs
|
||||
*/
|
||||
class CreateVideosFromMUXAssetsForSummitJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $tries = 2;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $summit_id;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $email_to;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $mux_token_id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $mux_token_secret;
|
||||
|
||||
/**
|
||||
* CreateVideosFromMUXAssetsForSummit constructor.
|
||||
* @param int $summit_id
|
||||
* @param string $mux_token_id
|
||||
* @param string $mux_token_secret
|
||||
* @param string|null $email_to
|
||||
*/
|
||||
public function __construct(int $summit_id, string $mux_token_id, string $mux_token_secret, ?string $email_to)
|
||||
{
|
||||
$this->summit_id = $summit_id;
|
||||
$this->email_to = $email_to;
|
||||
$this->mux_token_id = $mux_token_id;
|
||||
$this->mux_token_secret = $mux_token_secret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IPresentationVideoMediaUploadProcessor $service
|
||||
*/
|
||||
public function handle(IPresentationVideoMediaUploadProcessor $service){
|
||||
|
||||
Log::debug(sprintf("CreateVideosFromMUXAssetsForSummit::handle summit %s", $this->summit_id));
|
||||
|
||||
try {
|
||||
$service->createVideosFromMUXAssets
|
||||
(
|
||||
$this->summit_id,
|
||||
new MuxCredentials(
|
||||
$this->mux_token_id,
|
||||
$this->mux_token_secret
|
||||
),
|
||||
$this->email_to
|
||||
);
|
||||
}
|
||||
catch (\Exception $ex){
|
||||
Log::error($ex);
|
||||
}
|
||||
}
|
||||
}
|
96
app/Jobs/VideoStreamUrlMUXProcessingForSummitJob.php
Normal file
96
app/Jobs/VideoStreamUrlMUXProcessingForSummitJob.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?php namespace App\Jobs;
|
||||
/**
|
||||
* Copyright 2021 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use App\Services\Apis\MuxCredentials;
|
||||
use App\Services\Model\IPresentationVideoMediaUploadProcessor;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class VideoStreamUrlMUXProcessingForSummitJob
|
||||
* @package App\Jobs
|
||||
*/
|
||||
class VideoStreamUrlMUXProcessingForSummitJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $tries = 2;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $summit_id;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $email_to;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $mux_token_id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $mux_token_secret;
|
||||
|
||||
|
||||
/**
|
||||
* VideoStreamUrlMUXProcessingForSummitJob constructor.
|
||||
* @param int $summit_id
|
||||
* @param string $mux_token_id
|
||||
* @param string $mux_token_secret
|
||||
* @param string|null $email_to
|
||||
*/
|
||||
public function __construct
|
||||
(
|
||||
int $summit_id,
|
||||
string $mux_token_id,
|
||||
string $mux_token_secret,
|
||||
?string $email_to
|
||||
)
|
||||
{
|
||||
$this->summit_id = $summit_id;
|
||||
$this->email_to = $email_to;
|
||||
$this->mux_token_id = $mux_token_id;
|
||||
$this->mux_token_secret = $mux_token_secret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IPresentationVideoMediaUploadProcessor $service
|
||||
*/
|
||||
public function handle(IPresentationVideoMediaUploadProcessor $service){
|
||||
|
||||
Log::debug(sprintf("VideoStreamUrlMUXProcessingForSummitJob::handle summit %s", $this->summit_id));
|
||||
|
||||
try {
|
||||
$service->processSummitEventsStreamURLs
|
||||
(
|
||||
$this->summit_id,
|
||||
new MuxCredentials(
|
||||
$this->mux_token_id,
|
||||
$this->mux_token_secret
|
||||
),
|
||||
$this->email_to
|
||||
);
|
||||
}
|
||||
catch (\Exception $ex){
|
||||
Log::error($ex);
|
||||
}
|
||||
}
|
||||
}
|
64
app/Mail/MUXExportExcerptMail.php
Normal file
64
app/Mail/MUXExportExcerptMail.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php namespace App\Mail;
|
||||
/**
|
||||
* Copyright 2015 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
/**
|
||||
* Class MUXExportExcerptMail
|
||||
* @package App\Mail
|
||||
*/
|
||||
class MUXExportExcerptMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 1;
|
||||
|
||||
private $mail_to;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $step;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $excerpt;
|
||||
|
||||
/**
|
||||
* MUXExportExcerptMail constructor.
|
||||
* @param $mail_to
|
||||
* @param string $step
|
||||
* @param string $excerpt
|
||||
*/
|
||||
public function __construct($mail_to, string $step, string $excerpt)
|
||||
{
|
||||
$this->mail_to = $mail_to;
|
||||
$this->step = $step;
|
||||
$this->excerpt = $excerpt;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
$subject = sprintf("[%s] Mux Export Process - %s", Config::get('app.tenant_name'), $this->step);
|
||||
Log::warning(sprintf("MUXExportExcerptMail::build to %s", $this->mail_to));
|
||||
return $this->from(Config::get("mail.from"))
|
||||
->to($this->mail_to)
|
||||
->subject($subject)
|
||||
->view('emails.mux_export_excerpt');
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Class PresentationVideoSerializer
|
||||
* @package ModelSerializers
|
||||
@ -20,6 +21,7 @@ final class PresentationVideoSerializer extends PresentationMaterialSerializer
|
||||
protected static $array_mappings =
|
||||
[
|
||||
'YouTubeID' => 'youtube_id:json_text',
|
||||
'ExternalUrl' => 'external_url:json_url',
|
||||
'DateUploaded' => 'data_uploaded:datetime_epoch',
|
||||
'Highlighted' => 'highlighted:json_boolean',
|
||||
'Views' => 'views:json_int',
|
||||
|
@ -36,6 +36,12 @@ class PresentationVideo extends PresentationMaterial
|
||||
*/
|
||||
private $youtube_id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="ExternalUrl", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $external_url;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@ -124,5 +130,22 @@ class PresentationVideo extends PresentationMaterial
|
||||
$this->highlighted = false;
|
||||
$this->views = 0;
|
||||
$this->date_uploaded = new \DateTime();
|
||||
$this->external_url = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getExternalUrl(): ?string
|
||||
{
|
||||
return $this->external_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $external_url
|
||||
*/
|
||||
public function setExternalUrl(?string $external_url): void
|
||||
{
|
||||
$this->external_url = $external_url;
|
||||
}
|
||||
}
|
@ -372,6 +372,12 @@ class Presentation extends SummitEvent
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getVideosWithExternalUrls(){
|
||||
return $this->materials->filter(function ($element) {
|
||||
return $element instanceof PresentationVideo && !empty($element->getExternalUrl());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
@ -34,8 +34,13 @@ final class PresentationVideoFactory
|
||||
public static function populate(PresentationVideo $video, array $data){
|
||||
|
||||
PresentationMaterialFactory::populate($video, $data);
|
||||
|
||||
if(isset($data['youtube_id']))
|
||||
$video->setYoutubeId(trim($data['youtube_id']));
|
||||
|
||||
if(isset($data['external_url']))
|
||||
$video->setExternalUrl(trim($data['external_url']));
|
||||
|
||||
if($video->getId() == 0)
|
||||
$video->setDateUploaded(new \DateTime());
|
||||
return $video;
|
||||
|
59
app/Services/Apis/MuxCredentials.php
Normal file
59
app/Services/Apis/MuxCredentials.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php namespace App\Services\Apis;
|
||||
/**
|
||||
* Copyright 2021 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
* @from https://dashboard.mux.com/organizations/<organization-id>/settings/access-tokens
|
||||
* Class MuxCredentials
|
||||
* @package App\Services\Apis
|
||||
*/
|
||||
final class MuxCredentials
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $token_id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $token_secret;
|
||||
|
||||
/**
|
||||
* MuxCredentials constructor.
|
||||
* @param string $token_id
|
||||
* @param string $token_secret
|
||||
*/
|
||||
public function __construct(string $token_id, string $token_secret)
|
||||
{
|
||||
$this->token_id = $token_id;
|
||||
$this->token_secret = $token_secret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTokenId(): string
|
||||
{
|
||||
return $this->token_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTokenSecret(): string
|
||||
{
|
||||
return $this->token_secret;
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use App\Services\Apis\MuxCredentials;
|
||||
|
||||
/**
|
||||
* Interface IPresentationVideoMediaUploadProcessor
|
||||
@ -21,20 +21,48 @@ interface IPresentationVideoMediaUploadProcessor
|
||||
{
|
||||
/**
|
||||
* @param int $summit_id
|
||||
* @param MuxCredentials $credentials
|
||||
* @param string|null $mountingFolder
|
||||
* @return int
|
||||
*/
|
||||
public function processPublishedPresentationFor(int $summit_id, ?string $mountingFolder = null):int;
|
||||
public function processPublishedPresentationFor(int $summit_id, MuxCredentials $credentials, ?string $mountingFolder = null):int;
|
||||
|
||||
/**
|
||||
* @param int $event_id
|
||||
* @param string|null $mountingFolder
|
||||
* @param MuxCredentials|null $credentials
|
||||
* @return bool
|
||||
*/
|
||||
public function processEvent(int $event_id, ?string $mountingFolder):bool;
|
||||
public function processEvent(int $event_id, ?string $mountingFolder, ?MuxCredentials $credentials = null):bool;
|
||||
|
||||
/**
|
||||
* @param int $event_id
|
||||
* @param MuxCredentials|null $credentials
|
||||
*/
|
||||
public function enableMP4Support(int $event_id):void;
|
||||
public function enableMP4Support(int $event_id, ?MuxCredentials $credentials = null):void;
|
||||
|
||||
/**
|
||||
* @param int $summit_id
|
||||
* @param MuxCredentials $credentials
|
||||
* @param string|null $mail_to
|
||||
* @return int
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function processSummitEventsStreamURLs
|
||||
(
|
||||
int $summit_id,
|
||||
MuxCredentials $credentials,
|
||||
?string $mail_to
|
||||
):int;
|
||||
|
||||
/**
|
||||
* @param int $summit_id
|
||||
* @param MuxCredentials $credentials
|
||||
* @param string|null $mail_to
|
||||
* @return int
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createVideosFromMUXAssets(int $summit_id,
|
||||
MuxCredentials $credentials,
|
||||
?string $mail_to):int;
|
||||
}
|
@ -12,18 +12,23 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use App\Jobs\CreateVideosFromMUXAssetsForSummitJob;
|
||||
use App\Mail\MUXExportExcerptMail;
|
||||
use App\Models\Foundation\Summit\Factories\PresentationVideoFactory;
|
||||
use App\Models\Utils\IStorageTypesConstants;
|
||||
use App\Services\Apis\MuxCredentials;
|
||||
use App\Services\Filesystem\FileDownloadStrategyFactory;
|
||||
use App\Services\Model\AbstractService;
|
||||
use App\Services\Model\IPresentationVideoMediaUploadProcessor;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use libs\utils\ITransactionService;
|
||||
use models\summit\ISummitEventRepository;
|
||||
use models\summit\ISummitRepository;
|
||||
use models\summit\Presentation;
|
||||
use MuxPhp\ApiException;
|
||||
use MuxPhp\Configuration as MuxConfig;
|
||||
use MuxPhp\Api\AssetsApi as MuxAssetApi;
|
||||
use MuxPhp\Api\PlaybackIDApi as MuxPlaybackIDApi;
|
||||
use GuzzleHttp\Client as GuzzleHttpClient;
|
||||
use MuxPhp\Models\InputSettings as MuxInputSettings;
|
||||
use MuxPhp\Models\CreateAssetRequest as MuxCreateAssetRequest;
|
||||
@ -38,11 +43,8 @@ final class PresentationVideoMediaUploadProcessor
|
||||
extends AbstractService
|
||||
implements IPresentationVideoMediaUploadProcessor
|
||||
{
|
||||
/**
|
||||
* @var ISummitRepository
|
||||
*/
|
||||
private $summit_repository;
|
||||
|
||||
const MUX_STREAM_REGEX = '/https\:\/\/stream\.mux\.com\/(.*)\.m3u8/';
|
||||
/**
|
||||
* @var ISummitEventRepository
|
||||
*/
|
||||
@ -53,47 +55,33 @@ final class PresentationVideoMediaUploadProcessor
|
||||
*/
|
||||
private $assets_api;
|
||||
|
||||
/**
|
||||
* @var MuxPlaybackIDApi
|
||||
*/
|
||||
private $playback_api;
|
||||
|
||||
public function __construct
|
||||
(
|
||||
ISummitRepository $summit_repository,
|
||||
ISummitEventRepository $event_repository,
|
||||
ITransactionService $tx_service
|
||||
)
|
||||
{
|
||||
parent::__construct($tx_service);
|
||||
$this->summit_repository = $summit_repository;
|
||||
$this->event_repository = $event_repository;
|
||||
|
||||
$mux_user = Config::get("mux.user", null);
|
||||
$mux_password = Config::get("mux.password", null);
|
||||
|
||||
if (empty($mux_user)) {
|
||||
throw new \InvalidArgumentException("missing setting mux.user");
|
||||
}
|
||||
if (empty($mux_password)) {
|
||||
throw new \InvalidArgumentException("missing setting mux.password");
|
||||
}
|
||||
|
||||
// Authentication Setup
|
||||
$config = MuxConfig::getDefaultConfiguration()
|
||||
->setUsername($mux_user)
|
||||
->setPassword($mux_password);
|
||||
|
||||
// API Client Initialization
|
||||
$this->assets_api = new MuxAssetApi(
|
||||
new GuzzleHttpClient,
|
||||
$config
|
||||
);
|
||||
$this->assets_api = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $summit_id
|
||||
* @param MuxCredentials $credentials
|
||||
* @param string|null $mountingFolder
|
||||
* @return int
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function processPublishedPresentationFor(int $summit_id, ?string $mountingFolder = null): int
|
||||
public function processPublishedPresentationFor(int $summit_id, MuxCredentials $credentials, ?string $mountingFolder = null): int
|
||||
{
|
||||
$this->_configMux($credentials);
|
||||
|
||||
Log::debug(sprintf("PresentationVideoMediaUploadProcessor::processPublishedPresentationFor summit id %s mountingFolder %s", $summit_id, $mountingFolder));
|
||||
$event_ids = $this->tx_service->transaction(function () use ($summit_id) {
|
||||
return $this->event_repository->getPublishedEventsIdsBySummit($summit_id);
|
||||
@ -110,11 +98,13 @@ final class PresentationVideoMediaUploadProcessor
|
||||
/**
|
||||
* @param int $event_id
|
||||
* @param string|null $mountingFolder
|
||||
* @param MuxCredentials|null $credentials
|
||||
* @return bool
|
||||
*/
|
||||
public function processEvent(int $event_id, ?string $mountingFolder): bool
|
||||
public function processEvent(int $event_id, ?string $mountingFolder, ?MuxCredentials $credentials = null): bool
|
||||
{
|
||||
try {
|
||||
$this->_configMux($credentials);
|
||||
return $this->tx_service->transaction(function () use ($event_id, $mountingFolder) {
|
||||
try {
|
||||
$event = $this->event_repository->getByIdExclusiveLock($event_id);
|
||||
@ -191,8 +181,9 @@ final class PresentationVideoMediaUploadProcessor
|
||||
* @param int $event_id
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function enableMP4Support(int $event_id): void
|
||||
public function enableMP4Support(int $event_id, ?MuxCredentials $credentials = null): void
|
||||
{
|
||||
$this->_configMux($credentials);
|
||||
$this->tx_service->transaction(function () use ($event_id) {
|
||||
$event = $this->event_repository->getByIdExclusiveLock($event_id);
|
||||
if (is_null($event) || !$event instanceof Presentation) {
|
||||
@ -212,10 +203,256 @@ final class PresentationVideoMediaUploadProcessor
|
||||
return;
|
||||
}
|
||||
|
||||
$request = new MuxUpdateAssetMP4SupportRequest(['mp4_support' => MuxUpdateAssetMP4SupportRequest::MP4_SUPPORT_STANDARD]);
|
||||
$result = $this->assets_api->updateAssetMp4Support($assetId, $request);
|
||||
|
||||
Log::debug(sprintf("PresentationVideoMediaUploadProcessor::enableMP4Support event %s enable mp4 support response %s", $event_id, json_encode($result)));
|
||||
$this->_enableMP4Support($assetId);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $assetId
|
||||
* @return \MuxPhp\Models\AssetResponse
|
||||
* @throws \MuxPhp\ApiException
|
||||
*/
|
||||
private function _enableMP4Support(string $assetId)
|
||||
{
|
||||
try {
|
||||
$request = new MuxUpdateAssetMP4SupportRequest(['mp4_support' => MuxUpdateAssetMP4SupportRequest::MP4_SUPPORT_STANDARD]);
|
||||
$result = $this->assets_api->updateAssetMp4Support($assetId, $request);
|
||||
$tracks = $result->getData()->getTracks();
|
||||
Log::debug
|
||||
(
|
||||
sprintf
|
||||
(
|
||||
"PresentationVideoMediaUploadProcessor::_enableMP4Support asset id %s enable mp4 support response %s",
|
||||
$assetId,
|
||||
json_encode($tracks)
|
||||
)
|
||||
);
|
||||
|
||||
return $tracks;
|
||||
}
|
||||
catch(ApiException $ex){
|
||||
Log::warning($ex);
|
||||
$response = json_decode($ex->getResponseBody());
|
||||
if(count($response->error->messages) > 0){
|
||||
if($response->error->messages[0] == "Download already exists"){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function _configMux(MuxCredentials $credentials)
|
||||
{
|
||||
if (!is_null($this->assets_api)) return;
|
||||
|
||||
// Authentication Setup
|
||||
$config = MuxConfig::getDefaultConfiguration()
|
||||
->setUsername($credentials->getTokenId())
|
||||
->setPassword($credentials->getTokenSecret());
|
||||
|
||||
// API Client Initialization
|
||||
$this->assets_api = new MuxAssetApi(
|
||||
new GuzzleHttpClient,
|
||||
$config
|
||||
);
|
||||
|
||||
$this->playback_api = new MuxPlaybackIDApi(
|
||||
new GuzzleHttpClient,
|
||||
$config
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $summit_id
|
||||
* @param MuxCredentials $credentials
|
||||
* @param string|null $mail_to
|
||||
* @return int
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function processSummitEventsStreamURLs
|
||||
(
|
||||
int $summit_id,
|
||||
MuxCredentials $credentials,
|
||||
?string $mail_to
|
||||
): int
|
||||
{
|
||||
$event_ids = $this->tx_service->transaction(function () use ($summit_id) {
|
||||
return $this->event_repository->getPublishedEventsIdsBySummit($summit_id);
|
||||
});
|
||||
|
||||
$this->_configMux($credentials);
|
||||
$excerpt = 'Starting MUX Assets Enabling MP4 Support Process.'.PHP_EOL;
|
||||
|
||||
foreach ($event_ids as $event_id) {
|
||||
Log::warning(sprintf("PresentationVideoMediaUploadProcessor::processMuxAssetsFromStreamUrl processing event %s", $event_id));
|
||||
try {
|
||||
$this->tx_service->transaction(function () use ($event_id, $credentials, &$excerpt) {
|
||||
try {
|
||||
|
||||
$event = $this->event_repository->getByIdExclusiveLock($event_id);
|
||||
if (is_null($event) || !$event instanceof Presentation) {
|
||||
Log::warning(sprintf("PresentationVideoMediaUploadProcessor::processMuxAssetsFromStreamUrl event %s not found", $event_id));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$event->isPublished()) {
|
||||
Log::warning(sprintf("PresentationVideoMediaUploadProcessor::processMuxAssetsFromStreamUrl event %s not published", $event_id));
|
||||
$excerpt .= sprintf("event %s not published", $event_id) . PHP_EOL;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($event->getMuxAssetId())) {
|
||||
$excerpt .= sprintf("event %s - mux asset id (%s) - already has enabled mp4 support.", $event_id, $event->getMuxAssetId()) . PHP_EOL;
|
||||
return false;
|
||||
}
|
||||
$stream_url = $event->getStreamingUrl();
|
||||
// test $stream_url
|
||||
if (!preg_match(self::MUX_STREAM_REGEX, $stream_url, $matches)) {
|
||||
Log::warning(sprintf("PresentationVideoMediaUploadProcessor::processMuxAssetsFromStreamUrl event %s stream url does not match mux format (%s)", $event_id, $stream_url));
|
||||
$excerpt .= sprintf("event %s stream url does not match mux format (%s)", $event_id, $stream_url) . PHP_EOL;
|
||||
}
|
||||
|
||||
$playback_id = $matches[1];
|
||||
$event->setMuxPlaybackId($playback_id);
|
||||
$playbackResponse = $this->playback_api->getAssetOrLivestreamId($playback_id);
|
||||
$asset_id = $playbackResponse->getData()->getObject()->getId();
|
||||
$event->setMuxAssetId($asset_id);
|
||||
$assetResponse = $this->assets_api->getAsset($asset_id);
|
||||
$staticRenditions = $assetResponse->getData()->getStaticRenditions();
|
||||
if(!is_null($staticRenditions)){
|
||||
$excerpt .= sprintf("event %s - mux asset id (%s) - has already enabled mp4 support.", $event_id, $asset_id) . PHP_EOL;
|
||||
return false;
|
||||
}
|
||||
$this->_enableMP4Support($asset_id);
|
||||
$excerpt .= sprintf("event %s - mux asset id (%s) - has been enabled mp4 support.", $event_id, $asset_id) . PHP_EOL;
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
$excerpt .= sprintf("event %s - error on enabling mp4 support.", $event_id) . PHP_EOL;
|
||||
Log::warning($ex);
|
||||
throw $ex;
|
||||
}
|
||||
});
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
}
|
||||
}
|
||||
|
||||
$excerpt .= sprintf("%s events processed.", count($event_ids)) . PHP_EOL;
|
||||
|
||||
if (!empty($mail_to))
|
||||
Mail::queue(new MUXExportExcerptMail($mail_to, "MUX Assets MP4 Enabling Process", $excerpt));
|
||||
|
||||
// fire exporting
|
||||
// @see https://docs.mux.com/guides/video/download-your-videos#download-videos
|
||||
CreateVideosFromMUXAssetsForSummitJob::dispatch(
|
||||
$summit_id,
|
||||
$credentials->getTokenId(),
|
||||
$credentials->getTokenSecret(),
|
||||
$mail_to
|
||||
)->delay(now()->addMinutes(30));
|
||||
|
||||
return count($event_ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $summit_id
|
||||
* @param MuxCredentials $credentials
|
||||
* @param string|null $mail_to
|
||||
* @return int
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createVideosFromMUXAssets(int $summit_id,
|
||||
MuxCredentials $credentials,
|
||||
?string $mail_to): int
|
||||
{
|
||||
|
||||
$event_ids = $this->tx_service->transaction(function () use ($summit_id) {
|
||||
return $this->event_repository->getPublishedEventsIdsBySummit($summit_id);
|
||||
});
|
||||
|
||||
$this->_configMux($credentials);
|
||||
$excerpt = 'Starting Create Videos From MUX Assets Process.'.PHP_EOL;
|
||||
|
||||
foreach ($event_ids as $event_id) {
|
||||
$this->tx_service->transaction(function () use ($event_id, $credentials, &$excerpt) {
|
||||
try {
|
||||
|
||||
$event = $this->event_repository->getByIdExclusiveLock($event_id);
|
||||
if (is_null($event) || !$event instanceof Presentation) {
|
||||
Log::warning(sprintf("PresentationVideoMediaUploadProcessor::createVideosFromMUXAssets event %s not found", $event_id));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$event->isPublished()) {
|
||||
Log::warning(sprintf("PresentationVideoMediaUploadProcessor::createVideosFromMUXAssets event %s not published", $event_id));
|
||||
$excerpt .= sprintf("event %s not published.", $event_id) . PHP_EOL;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($event->getVideosWithExternalUrls()->count() > 0) {
|
||||
$excerpt .= sprintf("event %s already processed.", $event_id) . PHP_EOL;
|
||||
return false;
|
||||
}
|
||||
|
||||
$assetId = $event->getMuxAssetId();
|
||||
if(empty($assetId)){
|
||||
$excerpt .= sprintf("event %s not processed.", $event_id) . PHP_EOL;
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = $this->assets_api->getAsset($assetId);
|
||||
$staticRenditions = $result->getData()->getStaticRenditions();
|
||||
|
||||
if(is_null($staticRenditions)){
|
||||
$excerpt .= sprintf("event %s - mp4 not enabled.", $event_id) . PHP_EOL;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($staticRenditions->getStatus() != 'ready') {
|
||||
$excerpt .= sprintf("event %s - transcoding not ready (%s)", $event_id, $staticRenditions->getStatus()) . PHP_EOL;
|
||||
return false;
|
||||
}
|
||||
|
||||
$bestFile = null;
|
||||
|
||||
$fileNames = [
|
||||
'low.mp4',
|
||||
'medium.mp4',
|
||||
'high.mp4',
|
||||
];
|
||||
|
||||
foreach ($staticRenditions->getFiles() as $file) {
|
||||
if (is_null($bestFile)) $bestFile = $file;
|
||||
if (array_search($bestFile->getName(), $fileNames) < array_search($file->getName(), $fileNames)) {
|
||||
$bestFile = $file;
|
||||
}
|
||||
}
|
||||
if (is_null($bestFile)) {
|
||||
$excerpt .= sprintf("event %s - transcoding not ready (%s).", $event_id, $staticRenditions->getStatus()) . PHP_EOL;
|
||||
return 0;
|
||||
};
|
||||
$newVideo = PresentationVideoFactory::build([
|
||||
'name' => $event->getTitle(),
|
||||
'external_url' => sprintf("https://stream.mux.com/%s/%s", $event->getMuxPlaybackId(), $bestFile->getName())
|
||||
]);
|
||||
|
||||
$event->addVideo($newVideo);
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
$excerpt .= sprintf("event %s - error on exporting mux asset.", $event_id) . PHP_EOL;
|
||||
Log::warning($ex);
|
||||
throw $ex;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$excerpt .= sprintf("%s events processed.", count($event_ids)) . PHP_EOL;
|
||||
|
||||
if (!empty($mail_to))
|
||||
Mail::queue(new MUXExportExcerptMail($mail_to, "Videos Creation Process", $excerpt));
|
||||
|
||||
return count($event_ids);
|
||||
}
|
||||
}
|
@ -27,7 +27,7 @@
|
||||
"fideloper/proxy": "^4.0",
|
||||
"glenscott/url-normalizer": "^1.4",
|
||||
"google/apiclient": "^2.2",
|
||||
"guzzlehttp/guzzle": "^6.3",
|
||||
"guzzlehttp/guzzle": "^7",
|
||||
"laravel-doctrine/extensions": "1.0.*",
|
||||
"laravel-doctrine/migrations": "^1.2",
|
||||
"laravel-doctrine/orm": "1.4.*",
|
||||
@ -35,15 +35,13 @@
|
||||
"laravel/tinker": "^1.0",
|
||||
"league/csv": "^9.6",
|
||||
"league/oauth2-client": "^2.4",
|
||||
"muxinc/mux-php": "^0.5.0",
|
||||
"muxinc/mux-php": "^0.9.0",
|
||||
"php-amqplib/php-amqplib": "^2.11",
|
||||
"php-opencloud/openstack": "dev-master",
|
||||
"pion/laravel-chunk-upload": "^1.4",
|
||||
"predis/predis": "1.0.*",
|
||||
"s-ichikawa/laravel-sendgrid-driver": "^2.0",
|
||||
"simplesoftwareio/simple-qrcode": "^2.0",
|
||||
"smarcet/caldavclient": "1.1.6",
|
||||
"smarcet/outlook-rest-client": "dev-master",
|
||||
"sokil/php-isocodes": "^3.0",
|
||||
"spatie/flysystem-dropbox": "^1.2",
|
||||
"spatie/laravel-cors": "^1.6",
|
||||
|
1697
composer.lock
generated
1697
composer.lock
generated
File diff suppressed because it is too large
Load Diff
51
database/migrations/model/Version20210601152355.php
Normal file
51
database/migrations/model/Version20210601152355.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php namespace Database\Migrations\Model;
|
||||
/**
|
||||
* Copyright 2021 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema as Schema;
|
||||
use LaravelDoctrine\Migrations\Schema\Builder;
|
||||
use LaravelDoctrine\Migrations\Schema\Table;
|
||||
/**
|
||||
* Class Version20210601152355
|
||||
* @package Database\Migrations\Model
|
||||
*/
|
||||
class Version20210601152355 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema):void
|
||||
{
|
||||
$builder = new Builder($schema);
|
||||
|
||||
if ($builder->hasTable("PresentationVideo") && !$builder->hasColumn("PresentationVideo", "ExternalUrl")) {
|
||||
$builder->table("PresentationVideo", function (Table $table) {
|
||||
$table->string('ExternalUrl')->setNotnull(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema):void
|
||||
{
|
||||
$builder = new Builder($schema);
|
||||
|
||||
if ($builder->hasTable("PresentationVideo") && $builder->hasColumn("PresentationVideo", "ExternalUrl")) {
|
||||
$builder->table("PresentationVideo", function (Table $table) {
|
||||
$table->dropColumn('ExternalUrl');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -4318,6 +4318,16 @@ class ApiEndpointsSeeder extends Seeder
|
||||
'http_method' => 'POST',
|
||||
'scopes' => [sprintf('%s/summits/confirm-external-orders', $current_realm)],
|
||||
),
|
||||
[
|
||||
'name' => 'import-assets-from-mux',
|
||||
'route' => '/api/v1/summits/{id}/presentations/all/import/mux',
|
||||
'http_method' => 'POST',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WriteSummitData, $current_realm),
|
||||
sprintf(SummitScopes::WriteEventData, $current_realm),
|
||||
sprintf(SummitScopes::WritePresentationData, $current_realm)
|
||||
],
|
||||
],
|
||||
// presentation submissions
|
||||
[
|
||||
'name' => 'submit-presentation',
|
||||
|
13
resources/views/emails/mux_export_excerpt.blade.php
Normal file
13
resources/views/emails/mux_export_excerpt.blade.php
Normal file
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<h2>MUX EXPORT RESULTS - {!! $step !!}</h2>
|
||||
<p>{!! $excerpt !!}</p>
|
||||
<br/>
|
||||
<br/>
|
||||
<p>Cheers,<br/>Your {!! Config::get('app.tenant_name') !!} Support Team</p>
|
||||
</body>
|
||||
</html>
|
102
tests/MuxImportTest.php
Normal file
102
tests/MuxImportTest.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php namespace Tests;
|
||||
/**
|
||||
* Copyright 2021 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use App\Services\Apis\MuxCredentials;
|
||||
use App\Services\Model\IPresentationVideoMediaUploadProcessor;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use DateInterval;
|
||||
/**
|
||||
* Class MuxImportTest
|
||||
* @package Tests
|
||||
*/
|
||||
final class MuxImportTest extends TestCase
|
||||
{
|
||||
use \InsertSummitTestData;
|
||||
|
||||
protected function tearDown():void
|
||||
{
|
||||
self::clearTestData();
|
||||
parent::tearDown();
|
||||
\Mockery::close();
|
||||
}
|
||||
|
||||
protected function setUp():void
|
||||
{
|
||||
parent::setUp();
|
||||
self::insertTestData();
|
||||
$time_zone = self::$summit->getTimeZone();
|
||||
self::$presentations[0]->setStreamingUrl(env("MUX_STREAM_URL1"));
|
||||
$begin_date = new \DateTime("now", $time_zone);
|
||||
self::$presentations[0]->setStartDate($begin_date);
|
||||
self::$presentations[0]->setEndDate((clone $begin_date)->add(new DateInterval("P1D")));
|
||||
self::$presentations[0]->publish();
|
||||
self::$presentations[1]->setStreamingUrl(env("MUX_STREAM_URL2"));
|
||||
self::$presentations[1]->setStartDate($begin_date);
|
||||
self::$presentations[1]->setEndDate((clone $begin_date)->add(new DateInterval("P1D")));
|
||||
self::$presentations[1]->publish();
|
||||
self::$em->persist(self::$presentations[0]);
|
||||
self::$em->persist(self::$presentations[1]);
|
||||
self::$em->flush();
|
||||
}
|
||||
|
||||
public function testEnableMP4(){
|
||||
|
||||
$service = App::make(IPresentationVideoMediaUploadProcessor::class);
|
||||
|
||||
$res = $service->processSummitEventsStreamURLs
|
||||
(
|
||||
self::$summit->getId(),
|
||||
new MuxCredentials
|
||||
(
|
||||
env('MUX_TOKEN_ID'),
|
||||
env('MUX_TOKEN_SECRET')
|
||||
),
|
||||
env('MUX_EMAIL_TO')
|
||||
);
|
||||
|
||||
$this->assertTrue($res == 2);
|
||||
}
|
||||
|
||||
public function testEnableMP4AndProcess(){
|
||||
|
||||
$service = App::make(IPresentationVideoMediaUploadProcessor::class);
|
||||
|
||||
$res = $service->processSummitEventsStreamURLs
|
||||
(
|
||||
self::$summit->getId(),
|
||||
new MuxCredentials
|
||||
(
|
||||
env('MUX_TOKEN_ID'),
|
||||
env('MUX_TOKEN_SECRET')
|
||||
),
|
||||
env('MUX_EMAIL_TO')
|
||||
);
|
||||
|
||||
$this->assertTrue($res == 2);
|
||||
|
||||
$res = $service->createVideosFromMUXAssets
|
||||
(
|
||||
self::$summit->getId(),
|
||||
new MuxCredentials
|
||||
(
|
||||
env('MUX_TOKEN_ID'),
|
||||
env('MUX_TOKEN_SECRET')
|
||||
),
|
||||
env('MUX_EMAIL_TO')
|
||||
);
|
||||
|
||||
$this->assertTrue($res == 2);
|
||||
$this->assertTrue(self::$presentations[0]->getVideosWithExternalUrls()->count() > 0);
|
||||
$this->assertTrue(self::$presentations[1]->getVideosWithExternalUrls()->count() > 0);
|
||||
}
|
||||
}
|
@ -119,4 +119,35 @@ class OAuth2PresentationSubmissionTest extends ProtectedApiTest
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(204);
|
||||
}
|
||||
|
||||
public function testImportAssetsFromMUX(){
|
||||
$params = [
|
||||
'id' => self::$summit->getId(),
|
||||
];
|
||||
|
||||
$data = [
|
||||
'mux_token_id' => "TOKEN",
|
||||
'mux_token_secret' => "SECRET",
|
||||
"email_to" => "test@test.com"
|
||||
];
|
||||
|
||||
$headers = [
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
];
|
||||
|
||||
$response = $this->action(
|
||||
"POST",
|
||||
"OAuth2PresentationApiController@importAssetsFromMUX",
|
||||
$params,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
$headers,
|
||||
json_encode($data)
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user