feat(analyzer): load callback details from config and file_id (#1993)

This commit is contained in:
Jonas L 2022-07-26 14:19:22 +02:00 committed by GitHub
parent d93731807c
commit 067b35e9bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 45 additions and 97 deletions

View file

@ -92,10 +92,7 @@ class Application_Model_RabbitMq
$tmpFilePath,
$importedStorageDirectory,
$originalFilename,
$callbackUrl,
$apiKey,
$storageBackend,
$filePrefix
$fileId
) {
$config = Config::getConfig();
@ -111,19 +108,11 @@ class Application_Model_RabbitMq
$exchangeType = 'topic';
$queue = 'airtime-uploads';
$autoDeleteExchange = false;
$data['file_id'] = $fileId;
$data['tmp_file_path'] = $tmpFilePath;
$data['storage_backend'] = $storageBackend;
$data['import_directory'] = $importedStorageDirectory;
$data['original_filename'] = $originalFilename;
$data['callback_url'] = $callbackUrl;
$data['api_key'] = $apiKey;
// We add a prefix to the resource name so files are not all placed
// under the root folder. We do this in case we need to restore a
// customer's file/s; File restoration is done via the S3 Browser
// client. The client will hang if there are too many files under the
// same folder.
$data['file_prefix'] = $filePrefix;
$jsonData = json_encode($data);
// self::sendMessage($exchange, 'topic', false, $jsonData, 'airtime-uploads');

View file

@ -168,10 +168,8 @@ class CcFiles extends BaseCcFiles
$file->setDbHidden(true);
$file->save();
$callbackUrl = Config::getPublicUrl() . 'rest/media/' . $file->getPrimaryKey();
Application_Service_MediaService::importFileToLibrary(
$callbackUrl,
$file->getPrimaryKey(),
$filePath,
$originalFilename,
self::getOwnerId(),

View file

@ -13,7 +13,7 @@ class Application_Service_MediaService
/** Move (or copy) a file to the stor/organize directory and send it off to the
* analyzer to be processed.
*
* @param $callbackUrl
* @param $fileId
* @param $filePath string Path to the local file to import to the library
* @param $originalFilename string The original filename, if you want it to be preserved after import
* @param $ownerId string The ID of the user that will own the file inside Airtime
@ -23,11 +23,8 @@ class Application_Service_MediaService
*
* @return Ambigous
*/
public static function importFileToLibrary($callbackUrl, $filePath, $originalFilename, $ownerId, $copyFile)
public static function importFileToLibrary($fileId, $filePath, $originalFilename, $ownerId, $copyFile)
{
$CC_CONFIG = Config::getConfig();
$apiKey = $CC_CONFIG['apiKey'][0];
$importedStorageDirectory = Config::getStoragePath() . '/imported/' . $ownerId;
// Copy the temporary file over to the "organize" folder so that it's off our webserver
@ -40,10 +37,7 @@ class Application_Service_MediaService
$newTempFilePath,
$importedStorageDirectory,
basename($originalFilename),
$callbackUrl,
$apiKey,
'',
'',
$fileId,
);
return $newTempFilePath;