-- ------------------------------------------
-- Friendica 2022.05-rc (Siberian Iris)
--- DB_UPDATE_VERSION 1461
+-- DB_UPDATE_VERSION 1462
-- ------------------------------------------
`uid` mediumint unsigned COMMENT 'Delivering user',
`created` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
`command` varbinary(32) COMMENT '',
+ `failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
PRIMARY KEY(`uri-id`,`inbox-id`),
INDEX `inbox-id_created` (`inbox-id`,`created`),
INDEX `uid` (`uid`),
| uid | Delivering user | mediumint unsigned | YES | | NULL | |
| created | | datetime | YES | | 0001-01-01 00:00:00 | |
| command | | varbinary(32) | YES | | NULL | |
+| failed | Number of times the delivery has failed | tinyint | YES | | 0 | |
Indexes
------------
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)
{
- 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']]);
}
}
$data = ActivityPub\Transmitter::createCachedActivityFromItem($item_id);
if (!empty($data)) {
$success = HTTPSignature::transmit($data, $inbox, $uid);
- if ($success && $uri_id) {
- Post\Delivery::remove($uri_id, $inbox);
+ if ($uri_id) {
+ if ($success) {
+ Post\Delivery::remove($uri_id, $inbox);
+ } else {
+ Post\Delivery::incrementFailed($uri_id, $inbox);
+ }
}
}
}
use Friendica\Database\DBA;
if (!defined('DB_UPDATE_VERSION')) {
- define('DB_UPDATE_VERSION', 1461);
+ define('DB_UPDATE_VERSION', 1462);
}
return [
"uid" => ["type" => "mediumint unsigned", "foreign" => ["user" => "uid"], "comment" => "Delivering user"],
"created" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => ""],
"command" => ["type" => "varbinary(32)", "comment" => ""],
+ "failed" => ["type" => "tinyint", "default" => 0, "comment" => "Number of times the delivery has failed"],
],
"indexes" => [
"PRIMARY" => ["uri-id", "inbox-id"],