The priority is now a class constant

pull/1287/head
Michael 2022-10-17 05:50:23 +00:00
parent 408a62a9a1
commit e5842e83c7
4 changed files with 13 additions and 12 deletions

View File

@ -12,6 +12,7 @@ use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Worker;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Item; use Friendica\Model\Item;
@ -183,5 +184,5 @@ function ifttt_message($uid, $item)
$link = hash('ripemd128', $item['msg']); $link = hash('ripemd128', $item['msg']);
} }
Post\Delayed::add($link, $post, PRIORITY_MEDIUM, Post\Delayed::UNPREPARED); Post\Delayed::add($link, $post, Worker::PRIORITY_MEDIUM, Post\Delayed::UNPREPARED);
} }

View File

@ -53,7 +53,7 @@ function mailstream_check_version()
'addon/mailstream/mailstream.php', 'addon/mailstream/mailstream.php',
'mailstream_convert_table_entries' 'mailstream_convert_table_entries'
); );
Hook::fork(PRIORITY_LOW, 'mailstream_convert_table_entries'); Hook::fork(Worker::PRIORITY_LOW, 'mailstream_convert_table_entries');
} }
} }
@ -183,7 +183,7 @@ function mailstream_post_hook(App $a, array &$item)
'message_id' => $message_id, 'message_id' => $message_id,
'tries' => 0, 'tries' => 0,
]; ];
Hook::fork(PRIORITY_LOW, 'mailstream_send_hook', $send_hook_data); Hook::fork(Worker::PRIORITY_LOW, 'mailstream_send_hook', $send_hook_data);
} }
/** /**
@ -197,7 +197,7 @@ function mailstream_post_hook(App $a, array &$item)
* *
* @return array new value of the attachments table (results are also stored in the reference parameter) * @return array new value of the attachments table (results are also stored in the reference parameter)
*/ */
function mailstream_do_images(arrat &$item, array &$attachments) function mailstream_do_images(array &$item, array &$attachments)
{ {
if (!DI::pConfig()->get($item['uid'], 'mailstream', 'attachimg')) { if (!DI::pConfig()->get($item['uid'], 'mailstream', 'attachimg')) {
return; return;
@ -439,7 +439,7 @@ function mailstream_send(string $message_id, array $item, array $user): bool
* *
* @param string $text text to word wrap - modified in-place * @param string $text text to word wrap - modified in-place
*/ */
function mailstream_html_wrap(string &$text): string function mailstream_html_wrap(string &$text)
{ {
$lines = str_split($text, 200); $lines = str_split($text, 200);
for ($i = 0; $i < count($lines); $i++) { for ($i = 0; $i < count($lines); $i++) {
@ -467,7 +467,7 @@ function mailstream_convert_table_entries()
continue; continue;
} }
Logger::info('mailstream_convert_table_entries: convert item to workerqueue', $send_hook_data); Logger::info('mailstream_convert_table_entries: convert item to workerqueue', $send_hook_data);
Hook::fork(PRIORITY_LOW, 'mailstream_send_hook', $send_hook_data); Hook::fork(Worker::PRIORITY_LOW, 'mailstream_send_hook', $send_hook_data);
} }
DBA::e('DROP TABLE `mailstream_item`'); DBA::e('DROP TABLE `mailstream_item`');
} }

View File

@ -694,7 +694,7 @@ function pumpio_sync(App $a)
function pumpio_cron(App $a, $b) function pumpio_cron(App $a, $b)
{ {
Worker::add(PRIORITY_MEDIUM, 'addon/pumpio/pumpio_sync.php'); Worker::add(Worker::PRIORITY_MEDIUM, 'addon/pumpio/pumpio_sync.php');
} }
function pumpio_fetchtimeline(App $a, int $uid) function pumpio_fetchtimeline(App $a, int $uid)
@ -1506,7 +1506,7 @@ function pumpio_fetchallcomments(App $a, $uid, $id)
$post->object = $item; $post->object = $item;
Logger::notice('pumpio_fetchallcomments: posting comment ' . $post->object->id . ' ', $post); Logger::notice('pumpio_fetchallcomments: posting comment ' . $post->object->id . ' ', json_decode(json_encode($post), true));
pumpio_dopost($a, $client, $uid, $self, $post, $own_id, false); pumpio_dopost($a, $client, $uid, $self, $post, $own_id, false);
} }
} }

View File

@ -986,7 +986,7 @@ function twitter_cron(App $a)
$pconfigs = DBA::selectToArray('pconfig', [], ['cat' => 'twitter', 'k' => 'mirror_posts', 'v' => true]); $pconfigs = DBA::selectToArray('pconfig', [], ['cat' => 'twitter', 'k' => 'mirror_posts', 'v' => true]);
foreach ($pconfigs as $rr) { foreach ($pconfigs as $rr) {
Logger::notice('Fetching', ['user' => $rr['uid']]); Logger::notice('Fetching', ['user' => $rr['uid']]);
Worker::add(['priority' => PRIORITY_MEDIUM, 'force_priority' => true], 'addon/twitter/twitter_sync.php', 1, (int) $rr['uid']); Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], 'addon/twitter/twitter_sync.php', 1, (int) $rr['uid']);
} }
$abandon_days = intval(DI::config()->get('system', 'account_abandon_days')); $abandon_days = intval(DI::config()->get('system', 'account_abandon_days'));
@ -1006,7 +1006,7 @@ function twitter_cron(App $a)
} }
Logger::notice('importing timeline', ['user' => $rr['uid']]); Logger::notice('importing timeline', ['user' => $rr['uid']]);
Worker::add(['priority' => PRIORITY_MEDIUM, 'force_priority' => true], 'addon/twitter/twitter_sync.php', 2, (int) $rr['uid']); Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], 'addon/twitter/twitter_sync.php', 2, (int) $rr['uid']);
/* /*
// To-Do // To-Do
// check for new contacts once a day // check for new contacts once a day
@ -1333,7 +1333,7 @@ function twitter_fetchtimeline(App $a, int $uid): void
Logger::info('Posting mirror post', ['twitter-id' => $post->id_str, 'uid' => $uid]); Logger::info('Posting mirror post', ['twitter-id' => $post->id_str, 'uid' => $uid]);
Post\Delayed::add($mirrorpost['extid'], $mirrorpost, PRIORITY_MEDIUM, Post\Delayed::UNPREPARED); Post\Delayed::add($mirrorpost['extid'], $mirrorpost, Worker::PRIORITY_MEDIUM, Post\Delayed::UNPREPARED);
} }
} }
DI::pConfig()->set($uid, 'twitter', 'lastid', $lastid); DI::pConfig()->set($uid, 'twitter', 'lastid', $lastid);
@ -2191,7 +2191,7 @@ function twitter_fetchhometimeline(App $a, int $uid): void
if (empty($postarray['thr-parent'])) { if (empty($postarray['thr-parent'])) {
$contact = DBA::selectFirst('contact', [], ['id' => $postarray['contact-id'], 'self' => false]); $contact = DBA::selectFirst('contact', [], ['id' => $postarray['contact-id'], 'self' => false]);
if (DBA::isResult($contact) && Item::isRemoteSelf($contact, $postarray)) { if (DBA::isResult($contact) && Item::isRemoteSelf($contact, $postarray)) {
$notify = PRIORITY_MEDIUM; $notify = Worker::PRIORITY_MEDIUM;
} }
} }