Introducing the "failed" counter
This commit is contained in:
parent
d5d2892f59
commit
a943dbb420
5 changed files with 23 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
-- Friendica 2022.05-rc (Siberian Iris)
|
-- Friendica 2022.05-rc (Siberian Iris)
|
||||||
-- DB_UPDATE_VERSION 1461
|
-- DB_UPDATE_VERSION 1462
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -1126,6 +1126,7 @@ CREATE TABLE IF NOT EXISTS `post-delivery` (
|
||||||
`uid` mediumint unsigned COMMENT 'Delivering user',
|
`uid` mediumint unsigned COMMENT 'Delivering user',
|
||||||
`created` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
|
`created` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
|
||||||
`command` varbinary(32) COMMENT '',
|
`command` varbinary(32) COMMENT '',
|
||||||
|
`failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
|
||||||
PRIMARY KEY(`uri-id`,`inbox-id`),
|
PRIMARY KEY(`uri-id`,`inbox-id`),
|
||||||
INDEX `inbox-id_created` (`inbox-id`,`created`),
|
INDEX `inbox-id_created` (`inbox-id`,`created`),
|
||||||
INDEX `uid` (`uid`),
|
INDEX `uid` (`uid`),
|
||||||
|
|
|
@ -13,6 +13,7 @@ Fields
|
||||||
| uid | Delivering user | mediumint unsigned | YES | | NULL | |
|
| uid | Delivering user | mediumint unsigned | YES | | NULL | |
|
||||||
| created | | datetime | YES | | 0001-01-01 00:00:00 | |
|
| created | | datetime | YES | | 0001-01-01 00:00:00 | |
|
||||||
| command | | varbinary(32) | YES | | NULL | |
|
| command | | varbinary(32) | YES | | NULL | |
|
||||||
|
| failed | Number of times the delivery has failed | tinyint | YES | | 0 | |
|
||||||
|
|
||||||
Indexes
|
Indexes
|
||||||
------------
|
------------
|
||||||
|
|
|
@ -57,8 +57,19 @@ class Delivery
|
||||||
DBA::delete('post-delivery', ['uri-id' => $uri_id, 'inbox-id' => ItemURI::getIdByURI($inbox)]);
|
DBA::delete('post-delivery', ['uri-id' => $uri_id, 'inbox-id' => ItemURI::getIdByURI($inbox)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Increment "failed" counter for the given inbox and post
|
||||||
|
*
|
||||||
|
* @param integer $uri_id
|
||||||
|
* @param string $inbox
|
||||||
|
*/
|
||||||
|
public static function incrementFailed(int $uri_id, string $inbox)
|
||||||
|
{
|
||||||
|
return DBA::e('UPDATE `post-delivery` SET `failed` = `failed` + 1 WHERE `uri-id` = ? AND `inbox-id` = ?', $uri_id, ItemURI::getIdByURI($inbox));
|
||||||
|
}
|
||||||
|
|
||||||
public static function selectForInbox(string $inbox)
|
public static function selectForInbox(string $inbox)
|
||||||
{
|
{
|
||||||
return DBA::selectToArray('post-delivery', [], ['inbox-id' => ItemURI::getIdByURI($inbox)], ['order' => ['created']]);
|
return DBA::selectToArray('post-delivery', [], ["`inbox-id` = ? AND `failed` < ?", ItemURI::getIdByURI($inbox), 15], ['order' => ['created']]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,8 +131,12 @@ class APDelivery
|
||||||
$data = ActivityPub\Transmitter::createCachedActivityFromItem($item_id);
|
$data = ActivityPub\Transmitter::createCachedActivityFromItem($item_id);
|
||||||
if (!empty($data)) {
|
if (!empty($data)) {
|
||||||
$success = HTTPSignature::transmit($data, $inbox, $uid);
|
$success = HTTPSignature::transmit($data, $inbox, $uid);
|
||||||
if ($success && $uri_id) {
|
if ($uri_id) {
|
||||||
Post\Delivery::remove($uri_id, $inbox);
|
if ($success) {
|
||||||
|
Post\Delivery::remove($uri_id, $inbox);
|
||||||
|
} else {
|
||||||
|
Post\Delivery::incrementFailed($uri_id, $inbox);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
|
||||||
if (!defined('DB_UPDATE_VERSION')) {
|
if (!defined('DB_UPDATE_VERSION')) {
|
||||||
define('DB_UPDATE_VERSION', 1461);
|
define('DB_UPDATE_VERSION', 1462);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -1165,6 +1165,7 @@ return [
|
||||||
"uid" => ["type" => "mediumint unsigned", "foreign" => ["user" => "uid"], "comment" => "Delivering user"],
|
"uid" => ["type" => "mediumint unsigned", "foreign" => ["user" => "uid"], "comment" => "Delivering user"],
|
||||||
"created" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => ""],
|
"created" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => ""],
|
||||||
"command" => ["type" => "varbinary(32)", "comment" => ""],
|
"command" => ["type" => "varbinary(32)", "comment" => ""],
|
||||||
|
"failed" => ["type" => "tinyint", "default" => 0, "comment" => "Number of times the delivery has failed"],
|
||||||
],
|
],
|
||||||
"indexes" => [
|
"indexes" => [
|
||||||
"PRIMARY" => ["uri-id", "inbox-id"],
|
"PRIMARY" => ["uri-id", "inbox-id"],
|
||||||
|
|
Loading…
Reference in a new issue