Merge pull request #839 from annando/replace-queue

Replace the "Queue" mechanism with deferred workers
pull/841/head
Hypolite Petovan 2019-04-04 10:46:04 -04:00 committed by GitHub
commit 5d0760f285
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 38 deletions

View File

@ -18,6 +18,7 @@ use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
use Friendica\Database\DBA;
use Friendica\Model\Queue;
use Friendica\Core\Worker;
function diaspora_install()
{
@ -396,14 +397,7 @@ function diaspora_send(App $a, array &$b)
Logger::log('diaspora_send: requeueing '.$b['uid'], Logger::DEBUG);
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", $b['uid']);
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);
Worker::defer();
}
}
}

View File

@ -609,16 +609,7 @@ function pumpio_send(App $a, array &$b)
}
} else {
Logger::log('pumpio_send '.$username.': '.$url.' general error: ' . print_r($user, true));
$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);
Worker::defer();
}
}
}
@ -686,16 +677,7 @@ function pumpio_action(App $a, $uid, $uri, $action, $content = "")
Logger::log('pumpio_action '.$username.' '.$action.': success '.$uri);
} else {
Logger::log('pumpio_action '.$username.' '.$action.': general error: '.$uri.' '.print_r($user, true));
$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);
Worker::defer();
}
}

View File

@ -684,16 +684,7 @@ function twitter_post_hook(App $a, array &$b)
if (!empty($result->errors)) {
Logger::log('Send to Twitter failed: "' . print_r($result->errors, true) . '"');
$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);
Worker::defer();
} elseif ($iscomment) {
Logger::log('twitter_post: Update extid ' . $result->id_str . " for post id " . $b['id']);
Item::update(['extid' => "twitter::" . $result->id_str], ['id' => $b['id']]);