2016-05-02 04:03:21 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Pheanstalk\Pheanstalk;
|
2016-08-25 03:17:58 +02:00
|
|
|
use Miniflux\Model;
|
2016-05-02 04:03:21 +02:00
|
|
|
|
2016-08-19 03:02:49 +02:00
|
|
|
require __DIR__.'/app/common.php';
|
2016-05-02 04:03:21 +02:00
|
|
|
|
2016-05-02 04:15:31 +02:00
|
|
|
if (php_sapi_name() !== 'cli') {
|
|
|
|
die('This script can run only from the command line.'.PHP_EOL);
|
|
|
|
}
|
|
|
|
|
2016-05-02 04:32:50 +02:00
|
|
|
$options = getopt('', array(
|
|
|
|
'limit::',
|
2017-01-15 23:48:13 +01:00
|
|
|
'user::',
|
2016-05-02 04:32:50 +02:00
|
|
|
));
|
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
$limit = get_cli_option('limit', $options);
|
2017-01-15 23:48:13 +01:00
|
|
|
$user_id = get_cli_option('user', $options);
|
2016-05-02 04:03:21 +02:00
|
|
|
$connection = new Pheanstalk(BEANSTALKD_HOST);
|
|
|
|
|
2017-01-15 23:48:13 +01:00
|
|
|
if ($user_id) {
|
|
|
|
$user_ids = array($user_id);
|
|
|
|
} else {
|
|
|
|
$user_ids = Model\User\get_all_user_ids();
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($user_ids as $user_id) {
|
|
|
|
foreach (Model\Feed\get_feed_ids_to_refresh($user_id, $limit) as $feed_id) {
|
2016-12-26 15:44:53 +01:00
|
|
|
$payload = serialize(array(
|
|
|
|
'feed_id' => $feed_id,
|
2017-01-15 23:48:13 +01:00
|
|
|
'user_id' => $user_id,
|
2016-12-26 15:44:53 +01:00
|
|
|
));
|
|
|
|
|
|
|
|
$connection
|
|
|
|
->useTube(BEANSTALKD_QUEUE)
|
|
|
|
->put($payload, Pheanstalk::DEFAULT_PRIORITY, Pheanstalk::DEFAULT_DELAY, BEANSTALKD_TTL);
|
|
|
|
}
|
2016-05-02 04:03:21 +02:00
|
|
|
}
|
2016-12-26 15:44:53 +01:00
|
|
|
|