Merge pull request #839 from annando/replace-queue
Replace the "Queue" mechanism with deferred workers
This commit is contained in:
commit
5d0760f285
3 changed files with 5 additions and 38 deletions
|
@ -18,6 +18,7 @@ use Friendica\Core\PConfig;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Queue;
|
use Friendica\Model\Queue;
|
||||||
|
use Friendica\Core\Worker;
|
||||||
|
|
||||||
function diaspora_install()
|
function diaspora_install()
|
||||||
{
|
{
|
||||||
|
@ -396,14 +397,7 @@ function diaspora_send(App $a, array &$b)
|
||||||
|
|
||||||
Logger::log('diaspora_send: requeueing '.$b['uid'], Logger::DEBUG);
|
Logger::log('diaspora_send: requeueing '.$b['uid'], Logger::DEBUG);
|
||||||
|
|
||||||
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", $b['uid']);
|
Worker::defer();
|
||||||
if (count($r))
|
|
||||||
$a->contact = $r[0]["id"];
|
|
||||||
|
|
||||||
$s = serialize(['url' => $url, 'item' => $b['id'], 'post' => $body]);
|
|
||||||
|
|
||||||
Queue::add($a->contact, Protocol::DIASPORA2, $s);
|
|
||||||
notice(L10n::t('Diaspora post failed. Queued for retry.').EOL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -609,16 +609,7 @@ function pumpio_send(App $a, array &$b)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Logger::log('pumpio_send '.$username.': '.$url.' general error: ' . print_r($user, true));
|
Logger::log('pumpio_send '.$username.': '.$url.' general error: ' . print_r($user, true));
|
||||||
|
Worker::defer();
|
||||||
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", $b['uid']);
|
|
||||||
if (DBA::isResult($r)) {
|
|
||||||
$a->contact = $r[0]["id"];
|
|
||||||
}
|
|
||||||
|
|
||||||
$s = serialize(['url' => $url, 'item' => $b['id'], 'post' => $params]);
|
|
||||||
|
|
||||||
Queue::add($a->contact, Protocol::PUMPIO, $s);
|
|
||||||
notice(L10n::t('Pump.io post failed. Queued for retry.').EOL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -686,16 +677,7 @@ function pumpio_action(App $a, $uid, $uri, $action, $content = "")
|
||||||
Logger::log('pumpio_action '.$username.' '.$action.': success '.$uri);
|
Logger::log('pumpio_action '.$username.' '.$action.': success '.$uri);
|
||||||
} else {
|
} else {
|
||||||
Logger::log('pumpio_action '.$username.' '.$action.': general error: '.$uri.' '.print_r($user, true));
|
Logger::log('pumpio_action '.$username.' '.$action.': general error: '.$uri.' '.print_r($user, true));
|
||||||
|
Worker::defer();
|
||||||
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", $uid);
|
|
||||||
if (DBA::isResult($r)) {
|
|
||||||
$a->contact = $r[0]["id"];
|
|
||||||
}
|
|
||||||
|
|
||||||
$s = serialize(['url' => $url, 'item' => $orig_post["id"], 'post' => $params]);
|
|
||||||
|
|
||||||
Queue::add($a->contact, Protocol::PUMPIO, $s);
|
|
||||||
notice(L10n::t('Pump.io like failed. Queued for retry.').EOL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -684,16 +684,7 @@ function twitter_post_hook(App $a, array &$b)
|
||||||
|
|
||||||
if (!empty($result->errors)) {
|
if (!empty($result->errors)) {
|
||||||
Logger::log('Send to Twitter failed: "' . print_r($result->errors, true) . '"');
|
Logger::log('Send to Twitter failed: "' . print_r($result->errors, true) . '"');
|
||||||
|
Worker::defer();
|
||||||
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", intval($b['uid']));
|
|
||||||
if (DBA::isResult($r)) {
|
|
||||||
$a->contact = $r[0]["id"];
|
|
||||||
}
|
|
||||||
|
|
||||||
$s = serialize(['url' => $url, 'item' => $b['id'], 'post' => $post]);
|
|
||||||
|
|
||||||
Queue::add($a->contact, Protocol::TWITTER, $s);
|
|
||||||
notice(L10n::t('Twitter post failed. Queued for retry.') . EOL);
|
|
||||||
} elseif ($iscomment) {
|
} elseif ($iscomment) {
|
||||||
Logger::log('twitter_post: Update extid ' . $result->id_str . " for post id " . $b['id']);
|
Logger::log('twitter_post: Update extid ' . $result->id_str . " for post id " . $b['id']);
|
||||||
Item::update(['extid' => "twitter::" . $result->id_str], ['id' => $b['id']]);
|
Item::update(['extid' => "twitter::" . $result->id_str], ['id' => $b['id']]);
|
||||||
|
|
Loading…
Reference in a new issue