[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [friendsofphp/php-cs-fixer](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer) | `<3.45.1` -> `<3.46.1` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>PHP-CS-Fixer/PHP-CS-Fixer (friendsofphp/php-cs-fixer)</summary> ### [`v3.46.0`](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/HEAD/CHANGELOG.md#Changelog-for-v3460) [Compare Source](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/compare/v3.45.0...v3.46.0) - chore: fix internal typehints in Tokens ([#​7656](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7656)) - chore: reduce PHPStan baseline ([#​7643](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7643)) - docs: Show class with unit tests and BC promise info ([#​7667](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7667)) - feat: change default ruleset to `@PER-CS` (only behind PHP_CS_FIXER_FUTURE_MODE=1) ([#​7650](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7650)) - feat: Support new/instanceof/use trait in `fully_qualified_strict_types` ([#​7653](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7653)) - fix: FQCN parse phpdoc using full grammar regex ([#​7649](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7649)) - fix: Handle FQCN properly with `leading_backslash_in_global_namespace` option enabled ([#​7654](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7654)) - fix: PhpdocToParamTypeFixerTest - support for arrow functions ([#​7647](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7647)) - fix: PHP_CS_FIXER_FUTURE_MODE - proper boolean validation ([#​7651](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7651)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/libretime/libretime). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMDMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjEwMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: jo <ljonas@riseup.net>
156 lines
4.8 KiB
PHP
156 lines
4.8 KiB
PHP
<?php
|
|
|
|
use PhpAmqpLib\Connection\AMQPStreamConnection;
|
|
use PhpAmqpLib\Message\AMQPMessage;
|
|
|
|
class Application_Model_RabbitMq
|
|
{
|
|
public static $doPush = false;
|
|
|
|
/**
|
|
* Sets a flag to push the schedule at the end of the request.
|
|
*/
|
|
public static function PushSchedule()
|
|
{
|
|
self::$doPush = true;
|
|
}
|
|
|
|
private static function sendMessage($exchange, $exchangeType, $autoDeleteExchange, $data, $queue = '')
|
|
{
|
|
$CC_CONFIG = Config::getConfig();
|
|
|
|
$conn = new AMQPStreamConnection(
|
|
$CC_CONFIG['rabbitmq']['host'],
|
|
$CC_CONFIG['rabbitmq']['port'],
|
|
$CC_CONFIG['rabbitmq']['user'],
|
|
$CC_CONFIG['rabbitmq']['password'],
|
|
$CC_CONFIG['rabbitmq']['vhost']
|
|
);
|
|
|
|
if (!isset($conn)) {
|
|
throw new Exception('Cannot connect to RabbitMQ server');
|
|
}
|
|
|
|
$channel = $conn->channel();
|
|
$channel->access_request(
|
|
$CC_CONFIG['rabbitmq']['vhost'],
|
|
false,
|
|
false,
|
|
true,
|
|
true
|
|
);
|
|
|
|
// I'm pretty sure we DON'T want to autodelete ANY exchanges but I'm keeping the code
|
|
// the way it is just so I don't accidentally break anything when I add the Analyzer code in. -- Albert, March 13, 2014
|
|
$channel->exchange_declare($exchange, $exchangeType, false, true, $autoDeleteExchange);
|
|
|
|
$msg = new AMQPMessage($data, ['content_type' => 'text/plain']);
|
|
|
|
$channel->basic_publish($msg, $exchange);
|
|
$channel->close();
|
|
$conn->close();
|
|
}
|
|
|
|
public static function SendMessageToPypo($event_type, $md)
|
|
{
|
|
$md['event_type'] = $event_type;
|
|
|
|
$exchange = 'airtime-pypo';
|
|
$data = json_encode($md, JSON_FORCE_OBJECT);
|
|
self::sendMessage($exchange, 'direct', true, $data);
|
|
}
|
|
|
|
public static function SendMessageToMediaMonitor($event_type, $md)
|
|
{
|
|
$md['event_type'] = $event_type;
|
|
|
|
$exchange = 'airtime-analyzer';
|
|
$data = json_encode($md);
|
|
self::sendMessage($exchange, 'direct', true, $data);
|
|
}
|
|
|
|
public static function SendMessageToShowRecorder($event_type)
|
|
{
|
|
$exchange = 'airtime-pypo';
|
|
|
|
$now = new DateTime('@' . time()); // in UTC timezone
|
|
$end_timestamp = new DateTime('@' . (time() + 3600 * 2)); // in UTC timezone
|
|
|
|
$temp = [];
|
|
$temp['event_type'] = $event_type;
|
|
$temp['server_timezone'] = Application_Model_Preference::GetTimezone();
|
|
if ($event_type == 'update_recorder_schedule') {
|
|
$temp['shows'] = Application_Model_Show::getShows(
|
|
$now,
|
|
$end_timestamp,
|
|
$onlyRecord = true
|
|
);
|
|
}
|
|
$data = json_encode($temp);
|
|
|
|
self::sendMessage($exchange, 'direct', true, $data);
|
|
}
|
|
|
|
public static function SendMessageToAnalyzer(
|
|
$tmpFilePath,
|
|
$importedStorageDirectory,
|
|
$originalFilename,
|
|
$fileId,
|
|
$fileTrackTypeId
|
|
) {
|
|
$config = Config::getConfig();
|
|
|
|
$conn = new AMQPStreamConnection(
|
|
$config['rabbitmq']['host'],
|
|
$config['rabbitmq']['port'],
|
|
$config['rabbitmq']['user'],
|
|
$config['rabbitmq']['password'],
|
|
$config['rabbitmq']['vhost']
|
|
);
|
|
|
|
$exchange = 'airtime-uploads';
|
|
$exchangeType = 'topic';
|
|
$queue = 'airtime-uploads';
|
|
$autoDeleteExchange = false;
|
|
|
|
$data['file_id'] = $fileId;
|
|
$data['tmp_file_path'] = $tmpFilePath;
|
|
$data['import_directory'] = $importedStorageDirectory;
|
|
$data['original_filename'] = $originalFilename;
|
|
|
|
$options = new stdClass();
|
|
|
|
if ($fileTrackTypeId) {
|
|
$fileTrackType = new Application_Model_Tracktype($fileTrackTypeId);
|
|
$options->analyze_cue_points = $fileTrackType->getAnalyzeCuePoints();
|
|
}
|
|
|
|
$data['options'] = $options;
|
|
|
|
$jsonData = json_encode($data);
|
|
// self::sendMessage($exchange, 'topic', false, $jsonData, 'airtime-uploads');
|
|
|
|
if (!isset($conn)) {
|
|
throw new Exception('Cannot connect to RabbitMQ server');
|
|
}
|
|
|
|
$channel = $conn->channel();
|
|
$channel->access_request(
|
|
$config['rabbitmq']['vhost'],
|
|
false,
|
|
false,
|
|
true,
|
|
true
|
|
);
|
|
|
|
// I'm pretty sure we DON'T want to autodelete ANY exchanges but I'm keeping the code
|
|
// the way it is just so I don't accidentally break anything when I add the Analyzer code in. -- Albert, March 13, 2014
|
|
$channel->exchange_declare($exchange, $exchangeType, false, true, $autoDeleteExchange);
|
|
|
|
$msg = new AMQPMessage($jsonData, ['content_type' => 'text/plain']);
|
|
|
|
$channel->basic_publish($msg, $exchange);
|
|
$channel->close();
|
|
$conn->close();
|
|
}
|
|
}
|