+ * @param integer $protocol
+ * @return bool
+ * @throws \Exception
+ */
+ public static function incrementQueueDone($item_id, $protocol = 0)
+ {
+ $sql = '';
+
+ switch ($protocol) {
+ case self::ACTIVITYPUB:
+ $sql = ", `activitypub` = `activitypub` + 1";
+ break;
+ case self::DFRN:
+ $sql = ", `dfrn` = `dfrn` + 1";
+ break;
+ case self::LEGACY_DFRN:
+ $sql = ", `legacy_dfrn` = `legacy_dfrn` + 1";
+ break;
+ case self::DIASPORA:
+ $sql = ", `diaspora` = `diaspora` + 1";
+ break;
+ case self::OSTATUS:
+ $sql = ", `ostatus` = `ostatus` + 1";
+ break;
+ }
+
+ return DBA::e('UPDATE `item-delivery-data` SET `queue_done` = `queue_done` + 1' . $sql . ' WHERE `iid` = ?', $item_id);
+ }
+
+ /**
+ * Increments the queue_failed for the given item ID.
+ *
+ * Avoids racing condition between multiple delivery threads.
+ *
+ * @param integer $item_id
+ * @return bool
+ * @throws \Exception
+ */
+ public static function incrementQueueFailed($item_id)
+ {
+ return DBA::e('UPDATE `item-delivery-data` SET `queue_failed` = `queue_failed` + 1 WHERE `iid` = ?', $item_id);
+ }
+
+ /**
+ * Increments the queue_count for the given item ID.
+ *
+ * @param integer $item_id
+ * @param integer $increment