friendica-addons/twitter/twitter_sync.php
2023-01-13 21:16:09 -05:00

32 lines
652 B
PHP

<?php
use Friendica\Core\Logger;
use Friendica\DI;
function twitter_sync_run($argv, $argc)
{
require_once 'addon/twitter/twitter.php';
if (function_exists('sys_getloadavg')) {
$load = sys_getloadavg();
$maxload = DI::config()->get('system', 'maxloadavg', 50);
if (intval($load[0]) > $maxload) {
Logger::notice('load too high. Twitter sync deferred to next scheduled run.', ['current' => $load[0], 'max' => $maxload]);
return;
}
}
if ($argc < 3) {
return;
}
$mode = intval($argv[1]);
$uid = intval($argv[2]);
if ($mode == 1) {
twitter_fetchtimeline($uid);
} elseif ($mode == 2) {
twitter_fetchhometimeline($uid);
}
}