Remove failing posts
This commit is contained in:
parent
a943dbb420
commit
b0b67f1fde
2 changed files with 16 additions and 6 deletions
|
@ -24,6 +24,7 @@ namespace Friendica\Model\Post;
|
|||
use Friendica\Database\DBA;
|
||||
use BadMethodCallException;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\ItemURI;
|
||||
|
||||
class Delivery
|
||||
|
@ -57,6 +58,16 @@ class Delivery
|
|||
DBA::delete('post-delivery', ['uri-id' => $uri_id, 'inbox-id' => ItemURI::getIdByURI($inbox)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove failed posts for an inbox
|
||||
*
|
||||
* @param string $inbox
|
||||
*/
|
||||
public static function removeFailed(string $inbox)
|
||||
{
|
||||
DBA::delete('post-delivery', ["`inbox-id` = ? AND `failed` >= ?", ItemURI::getIdByURI($inbox), DI::config()->get('system', 'worker_defer_limit')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment "failed" counter for the given inbox and post
|
||||
*
|
||||
|
@ -70,6 +81,6 @@ class Delivery
|
|||
|
||||
public static function selectForInbox(string $inbox)
|
||||
{
|
||||
return DBA::selectToArray('post-delivery', [], ["`inbox-id` = ? AND `failed` < ?", ItemURI::getIdByURI($inbox), 15], ['order' => ['created']]);
|
||||
return DBA::selectToArray('post-delivery', [], ['inbox-id' => ItemURI::getIdByURI($inbox)], ['order' => ['created']]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,19 +76,18 @@ class APDelivery
|
|||
|
||||
private static function deliver(string $inbox)
|
||||
{
|
||||
Post\Delivery::removeFailed($inbox);
|
||||
|
||||
$uri_ids = [];
|
||||
$posts = Post\Delivery::selectForInbox($inbox);
|
||||
$success = empty($posts);
|
||||
|
||||
foreach ($posts as $post) {
|
||||
if (self::deliverToInbox($post['command'], 0, $inbox, $post['uid'], [], $post['uri-id'])) {
|
||||
$success = true;
|
||||
} else {
|
||||
if (!self::deliverToInbox($post['command'], 0, $inbox, $post['uid'], [], $post['uri-id'])) {
|
||||
$uri_ids[] = $post['uri-id'];
|
||||
}
|
||||
}
|
||||
|
||||
return ['success' => $success, 'uri_ids' => $uri_ids];
|
||||
return ['success' => empty($uri_ids), 'uri_ids' => $uri_ids];
|
||||
}
|
||||
|
||||
private static function deliverToInbox(string $cmd, int $item_id, string $inbox, int $uid, array $receivers, int $uri_id)
|
||||
|
|
Loading…
Reference in a new issue