// New delivery fields with virtual field name in item fields
'queue_count' => 'delivery_queue_count',
'queue_done' => 'delivery_queue_done',
+ 'queue_failed' => 'delivery_queue_failed',
];
const ACTIVITYPUB = 1;
const LEGACY_DFRN = 3;
const DIASPORA = 4;
const OSTATUS = 5;
+ const MAIL = 6;
/**
* Extract delivery data from the provided item fields
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
+ * @return bool
+ * @throws \Exception
+ */
+ public static function incrementQueueCount(int $item_id, int $increment = 1)
+ {
+ return DBA::e('UPDATE `item-delivery-data` SET `queue_count` = `queue_count` + ? WHERE `iid` = ?', $increment, $item_id);
+ }
+
/**
* Insert a new item delivery data entry
*