Exemplo n.º 1
0
 public static function get($room)
 {
     //get all servers meeting existed and check for recordings
     $bbb_servers = $room->meetings()->groupBy('bbb_server')->get(['bbb_server']);
     $recordings = array();
     foreach ($bbb_servers as $bbb_server) {
         $bbb = new BigBlueButton($bbb_server->bbb_server);
         //if server is not up do not bring recordings and continue to next server
         if (!$bbb->isUp()) {
             continue;
         }
         $recordingsParams = array('meetingId' => $room->bbb_meeting_id);
         $result = $bbb->getRecordingsWithXmlResponseArray($recordingsParams);
         $isOwner = roomController::checkOwner($room);
         foreach ($result as $recording) {
             if ($recording['playbackFormatUrl'] != null) {
                 $duration_sec = $recording['endTime'] - $recording['startTime'];
                 //create download url
                 $parse_url = parse_url($recording['playbackFormatUrl']);
                 $download_url = 'http://' . $parse_url['host'] . '/playback/presentation/download/' . $recording['recordId'] . '.zip';
                 $duration = gmdate("H:i:s", substr($duration_sec, 0, -3));
                 //find if we know recording
                 $rec_query = Recording::where('rid', $recording['recordId'])->first();
                 //if we dont just save
                 if (!$rec_query) {
                     $rec_ins = new Recording();
                     $rec_ins->rid = $recording['recordId'];
                     $rec_ins->published = 0;
                     $rec_ins->keep = 0;
                     $rec_ins->bbb_server_id = $bbb->id;
                     $rec_ins->owner = $room->owner;
                     $rec_ins->save();
                     //new recording show only to owner
                     if ($isOwner) {
                         $recordings[] = array('id' => $recording['recordId'], 'url' => $recording['playbackFormatUrl'], 'time' => date('d/m/Y H:i', substr($recording['startTime'], 0, -3)), 'duration' => $duration, 'time_real' => $recording['startTime'], 'download_url' => $download_url, 'server_id' => $bbb->id, 'keep' => false, 'portal_id' => $rec_ins->id, 'published' => false);
                     }
                 } else {
                     if ($rec_query->published || $isOwner) {
                         $recordings[] = array('id' => $recording['recordId'], 'url' => $recording['playbackFormatUrl'], 'time' => date('d/m/Y H:i', substr($recording['startTime'], 0, -3)), 'duration' => $duration, 'time_real' => $recording['startTime'], 'download_url' => $download_url, 'server_id' => $bbb->id, 'keep' => $rec_query->keep, 'portal_id' => $rec_query->id, 'published' => $rec_query->published);
                     }
                 }
             }
         }
     }
     if (!empty($recordings)) {
         usort($recordings, function ($a, $b) {
             return $b['time_real'] - $a['time_real'];
         });
         return $recordings;
     } else {
         return null;
     }
 }
 public function testIndex()
 {
     // Given
     $fakeNumber = '+15558884441';
     $fakeRecording = 'http://help-pls.mp3';
     $fakeTranscription = 'Help me I am trapped in a phone exchange';
     $newAgent = new Agent(['extension' => 'Alderaan', 'phone_number' => '+15559997771']);
     $newAgent->save();
     $newRecording = new Recording(['caller_number' => $fakeNumber, 'transcription' => $fakeTranscription, 'recording_url' => $fakeRecording, 'agent_id' => $newAgent->id]);
     $newRecording->save();
     // When
     $response = $this->call('GET', route('agent-recordings') . '?agentNumber=15559997771');
     $responseContext = $response->getOriginalContent();
     // Then
     $this->assertCount(1, $responseContext['recordings']);
     $recordings = $responseContext['recordings'];
     $this->assertEquals($fakeNumber, $recordings[0]->caller_number);
     $this->assertEquals($fakeTranscription, $recordings[0]->transcription);
     $this->assertEquals($fakeRecording, $recordings[0]->recording_url);
     $this->assertEquals($newAgent->id, $recordings[0]->agent_id);
 }
 /**
  * Store a new recording from callback
  *
  * @return \Illuminate\Http\Response
  */
 public function storeRecording(Request $request, $agentId)
 {
     $newRecording = new Recording(['caller_number' => $request->input('Caller'), 'transcription' => $request->input('TranscriptionText'), 'recording_url' => $request->input('RecordingUrl'), 'agent_id' => $agentId]);
     $newRecording->save();
     return "Recording saved";
 }