-
Notifications
You must be signed in to change notification settings - Fork 1
/
NotifyController.php
39 lines (32 loc) · 1.4 KB
/
NotifyController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace Coshi\Bundle\TranscodeBundle\Controller;
use Coshi\Bundle\TranscodeBundle\Event\TranscodeEvent;
use Coshi\Bundle\TranscodeBundle\Event\TranscodeEvents;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Coshi\Bundle\TranscodeBundle\Transcoder\Transcoder;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class NotifyController extends Controller
{
public function notifyAction(Request $request)
{
$logger = $this->get('logger');
$postBody = file_get_contents('php://input');
$notification = json_decode($postBody, true);
if (!$notification) {
return new Response();
}
if ($notification['Type'] == 'SubscriptionConfirmation') {
$logger->info('sns_subscribe_url: ' . $notification['SubscribeURL']);
} else {
$message = json_decode($notification['Message'], true);
$filename = basename($message['input']['key']);
$amazonVideo = $this->get('coshi.amazon_transcoder.transcoder');
$amazonVideo->setVideo($filename);
$amazonVideo->complete($message);
$logger->info('sns_transcode_complete: ' . $message['jobId']);
$this->get('event_dispatcher')->dispatch(TranscodeEvents::TRANSCODE_COMPLETED, new TranscodeEvent($amazonVideo->getVideo()));
}
return new Response();
}
}