-- ------------------------------------------
-- Friendica 2020.06-dev (Red Hot Poker)
--- DB_UPDATE_VERSION 1341
+-- DB_UPDATE_VERSION 1343
-- ------------------------------------------
INDEX `uid_eventid` (`uid`,`event-id`),
INDEX `icid` (`icid`),
INDEX `iaid` (`iaid`),
- INDEX `psid_wall` (`psid`,`wall`)
+ INDEX `psid_wall` (`psid`,`wall`),
+ INDEX `uri-id` (`uri-id`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
--
INDEX `uri-id` (`uri-id`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
---
--- TABLE item-delivery-data
---
-CREATE TABLE IF NOT EXISTS `item-delivery-data` (
- `iid` int unsigned NOT NULL COMMENT 'Item id',
- `postopts` text COMMENT 'External post connectors add their network name to this comma-separated string to identify that they should be delivered to these networks during delivery',
- `inform` mediumtext COMMENT 'Additional receivers of the linked item',
- `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
- `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
- `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
- `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
- `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
- `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
- `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
- `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
- PRIMARY KEY(`iid`)
-) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
-
--
-- TABLE item-uri
--
INDEX `url` (`url`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
+--
+-- TABLE post-delivery-data
+--
+CREATE TABLE IF NOT EXISTS `post-delivery-data` (
+ `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
+ `postopts` text COMMENT 'External post connectors add their network name to this comma-separated string to identify that they should be delivered to these networks during delivery',
+ `inform` mediumtext COMMENT 'Additional receivers of the linked item',
+ `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
+ `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
+ `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
+ `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
+ `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
+ `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
+ `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
+ `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
+ PRIMARY KEY(`uri-id`)
+) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
+
--
-- TABLE post-tag
--
INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
+--
+-- VIEW tag-search-view
+--
+DROP VIEW IF EXISTS `tag-search-view`;
+CREATE VIEW `tag-search-view` AS SELECT
+ `post-tag`.`uri-id` AS `uri-id`,
+ `item`.`id` AS `iid`,
+ `item`.`uri` AS `uri`,
+ `item`.`guid` AS `guid`,
+ `item`.`uid` AS `uid`,
+ `item`.`private` AS `private`,
+ `item`.`wall` AS `wall`,
+ `item`.`origin` AS `origin`,
+ `item`.`gravity` AS `gravity`,
+ `item`.`received` AS `received`,
+ `tag`.`name` AS `name`
+ FROM `post-tag`
+ INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
+ INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
+ WHERE `post-tag`.`type` = 1;
+
--
-- VIEW workerqueue-view
--
// Fetch data from the item-content table whenever there is content there
if (self::isLegacyMode()) {
- $legacy_fields = array_merge(ItemDeliveryData::LEGACY_FIELD_LIST, self::MIXED_CONTENT_FIELDLIST);
+ $legacy_fields = array_merge(Post\DeliveryData::LEGACY_FIELD_LIST, self::MIXED_CONTENT_FIELDLIST);
foreach ($legacy_fields as $field) {
if (empty($row[$field]) && !empty($row['internal-item-' . $field])) {
$row[$field] = $row['internal-item-' . $field];
$fields['item-content'] = array_merge(self::CONTENT_FIELDLIST, self::MIXED_CONTENT_FIELDLIST);
- $fields['item-delivery-data'] = array_merge(ItemDeliveryData::LEGACY_FIELD_LIST, ItemDeliveryData::FIELD_LIST);
+ $fields['post-delivery-data'] = array_merge(Post\DeliveryData::LEGACY_FIELD_LIST, Post\DeliveryData::FIELD_LIST);
$fields['permissionset'] = ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
$joins .= " LEFT JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id`";
}
- if (strpos($sql_commands, "`item-delivery-data`.") !== false) {
- $joins .= " LEFT JOIN `item-delivery-data` ON `item-delivery-data`.`iid` = `item`.`id`";
+ if (strpos($sql_commands, "`post-delivery-data`.") !== false) {
+ $joins .= " LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `item`.`uri-id` AND `item`.`origin`";
}
if (strpos($sql_commands, "`permissionset`.") !== false) {
$selected[] = 'internal-user-ignored';
}
- $legacy_fields = array_merge(ItemDeliveryData::LEGACY_FIELD_LIST, self::MIXED_CONTENT_FIELDLIST);
+ $legacy_fields = array_merge(Post\DeliveryData::LEGACY_FIELD_LIST, self::MIXED_CONTENT_FIELDLIST);
$selection = [];
foreach ($fields as $table => $table_fields) {
}
}
- $delivery_data = ItemDeliveryData::extractFields($fields);
+ $delivery_data = Post\DeliveryData::extractFields($fields);
$clear_fields = ['bookmark', 'type', 'author-name', 'author-avatar', 'author-link', 'owner-name', 'owner-avatar', 'owner-link', 'postopts', 'inform'];
foreach ($clear_fields as $field) {
}
}
- ItemDeliveryData::update($item['id'], $delivery_data);
+ Post\DeliveryData::update($item['uri-id'], $delivery_data);
self::updateThread($item['id']);
{
Logger::info('Mark item for deletion by id', ['id' => $item_id, 'callstack' => System::callstack()]);
// locate item to be deleted
- $fields = ['id', 'uri', 'uid', 'parent', 'parent-uri', 'origin',
+ $fields = ['id', 'uri', 'uri-id', 'uid', 'parent', 'parent-uri', 'origin',
'deleted', 'file', 'resource-id', 'event-id', 'attach',
'verb', 'object-type', 'object', 'target', 'contact-id',
'icid', 'iaid', 'psid'];
self::markForDeletion(['uri' => $item['uri'], 'uid' => 0, 'deleted' => false], $priority);
}
- ItemDeliveryData::delete($item['id']);
+ Post\DeliveryData::delete($item['uri-id']);
// We don't delete the item-activity here, since we need some of the data for ActivityPub
self::insertContent($item);
}
- $delivery_data = ItemDeliveryData::extractFields($item);
+ $postfields = $item;
+ $delivery_data = Post\DeliveryData::extractFields($postfields);
unset($item['postopts']);
unset($item['inform']);
}
if (!empty($item['origin']) || !empty($item['wall']) || !empty($delivery_data['postopts']) || !empty($delivery_data['inform'])) {
- ItemDeliveryData::insert($current_post, $delivery_data);
+ Post\DeliveryData::insert($item['uri-id'], $delivery_data);
}
DBA::commit();
+++ /dev/null
-<?php
-/**
- * @copyright Copyright (C) 2020, Friendica
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- */
-
-namespace Friendica\Model;
-
-use Friendica\Database\DBA;
-use \BadMethodCallException;
-
-class ItemDeliveryData
-{
- const LEGACY_FIELD_LIST = [
- // Legacy fields moved from item table
- 'postopts',
- 'inform',
- ];
-
- const FIELD_LIST = [
- // 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 DFRN = 2;
- const LEGACY_DFRN = 3;
- const DIASPORA = 4;
- const OSTATUS = 5;
- const MAIL = 6;
-
- /**
- * Extract delivery data from the provided item fields
- *
- * @param array $fields
- * @return array
- */
- public static function extractFields(array &$fields)
- {
- $delivery_data = [];
- foreach (array_merge(ItemDeliveryData::FIELD_LIST, ItemDeliveryData::LEGACY_FIELD_LIST) as $key => $field) {
- if (is_int($key) && isset($fields[$field])) {
- // Legacy field moved from item table
- $delivery_data[$field] = $fields[$field];
- $fields[$field] = null;
- } elseif (isset($fields[$field])) {
- // New delivery field with virtual field name in item fields
- $delivery_data[$key] = $fields[$field];
- unset($fields[$field]);
- }
- }
-
- return $delivery_data;
- }
-
- /**
- * Increments the queue_done for the given item ID.
- *
- * Avoids racing condition between multiple delivery threads.
- *
- * @param integer $item_id
- * @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
- * @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
- *
- * @param integer $item_id
- * @param array $fields
- * @return bool
- * @throws \Exception
- */
- public static function insert($item_id, array $fields)
- {
- if (empty($item_id)) {
- throw new BadMethodCallException('Empty item_id');
- }
-
- $fields['iid'] = $item_id;
-
- return DBA::insert('item-delivery-data', $fields);
- }
-
- /**
- * Update/Insert item delivery data
- *
- * If you want to update queue_done, please use incrementQueueDone instead.
- *
- * @param integer $item_id
- * @param array $fields
- * @return bool
- * @throws \Exception
- */
- public static function update($item_id, array $fields)
- {
- if (empty($item_id)) {
- throw new BadMethodCallException('Empty item_id');
- }
-
- if (empty($fields)) {
- // Nothing to do, update successful
- return true;
- }
-
- return DBA::update('item-delivery-data', $fields, ['iid' => $item_id], true);
- }
-
- /**
- * Delete item delivery data
- *
- * @param integer $item_id
- * @return bool
- * @throws \Exception
- */
- public static function delete($item_id)
- {
- if (empty($item_id)) {
- throw new BadMethodCallException('Empty item_id');
- }
-
- return DBA::delete('item-delivery-data', ['iid' => $item_id]);
- }
-}
--- /dev/null
+<?php
+/**
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Friendica\Model\Post;
+
+use Friendica\Database\DBA;
+use \BadMethodCallException;
+
+class DeliveryData
+{
+ const LEGACY_FIELD_LIST = [
+ // Legacy fields moved from item table
+ 'postopts',
+ 'inform',
+ ];
+
+ const FIELD_LIST = [
+ // 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 DFRN = 2;
+ const LEGACY_DFRN = 3;
+ const DIASPORA = 4;
+ const OSTATUS = 5;
+ const MAIL = 6;
+
+ /**
+ * Extract delivery data from the provided item fields
+ *
+ * @param array $fields
+ * @return array
+ */
+ public static function extractFields(array &$fields)
+ {
+ $delivery_data = [];
+ foreach (array_merge(self::FIELD_LIST, self::LEGACY_FIELD_LIST) as $key => $field) {
+ if (is_int($key) && isset($fields[$field])) {
+ // Legacy field moved from item table
+ $delivery_data[$field] = $fields[$field];
+ $fields[$field] = null;
+ } elseif (isset($fields[$field])) {
+ // New delivery field with virtual field name in item fields
+ $delivery_data[$key] = $fields[$field];
+ unset($fields[$field]);
+ }
+ }
+
+ return $delivery_data;
+ }
+
+ /**
+ * Increments the queue_done for the given URI ID.
+ *
+ * Avoids racing condition between multiple delivery threads.
+ *
+ * @param integer $uri_id
+ * @param integer $protocol
+ * @return bool
+ * @throws \Exception
+ */
+ public static function incrementQueueDone(int $uri_id, int $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 `post-delivery-data` SET `queue_done` = `queue_done` + 1' . $sql . ' WHERE `uri-id` = ?', $uri_id);
+ }
+
+ /**
+ * Increments the queue_failed for the given URI ID.
+ *
+ * Avoids racing condition between multiple delivery threads.
+ *
+ * @param integer $uri_id
+ * @return bool
+ * @throws \Exception
+ */
+ public static function incrementQueueFailed(int $uri_id)
+ {
+ return DBA::e('UPDATE `post-delivery-data` SET `queue_failed` = `queue_failed` + 1 WHERE `uri-id` = ?', $uri_id);
+ }
+
+ /**
+ * Increments the queue_count for the given URI ID.
+ *
+ * @param integer $uri_id
+ * @param integer $increment
+ * @return bool
+ * @throws \Exception
+ */
+ public static function incrementQueueCount(int $uri_id, int $increment = 1)
+ {
+ return DBA::e('UPDATE `post-delivery-data` SET `queue_count` = `queue_count` + ? WHERE `uri-id` = ?', $increment, $uri_id);
+ }
+
+ /**
+ * Insert a new URI delivery data entry
+ *
+ * @param integer $uri_id
+ * @param array $fields
+ * @return bool
+ * @throws \Exception
+ */
+ public static function insert(int $uri_id, array $fields)
+ {
+ if (empty($uri_id)) {
+ throw new BadMethodCallException('Empty URI_id');
+ }
+
+ $fields['uri-id'] = $uri_id;
+
+ return DBA::insert('post-delivery-data', $fields);
+ }
+
+ /**
+ * Update/Insert URI delivery data
+ *
+ * If you want to update queue_done, please use incrementQueueDone instead.
+ *
+ * @param integer $uri_id
+ * @param array $fields
+ * @return bool
+ * @throws \Exception
+ */
+ public static function update(int $uri_id, array $fields)
+ {
+ if (empty($uri_id)) {
+ throw new BadMethodCallException('Empty URI_id');
+ }
+
+ if (empty($fields)) {
+ // Nothing to do, update successful
+ return true;
+ }
+
+ return DBA::update('post-delivery-data', $fields, ['uri-id' => $uri_id], true);
+ }
+
+ /**
+ * Delete URI delivery data
+ *
+ * @param integer $uri_id
+ * @return bool
+ * @throws \Exception
+ */
+ public static function delete(int $uri_id)
+ {
+ if (empty($uri_id)) {
+ throw new BadMethodCallException('Empty URI_id');
+ }
+
+ return DBA::delete('post-delivery-data', ['uri-id' => $uri_id]);
+ }
+}
use Friendica\Model\GContact;
use Friendica\Model\Item;
use Friendica\Model\ItemURI;
-use Friendica\Model\ItemDeliveryData;
use Friendica\Model\Mail;
+use Friendica\Model\Post;
use Friendica\Model\Tag;
use Friendica\Model\User;
use Friendica\Network\Probe;
}
// Send all existing comments and likes to the requesting server
- $comments = Item::select(['id', 'parent', 'verb', 'self'], ['parent' => $item['id']]);
+ $comments = Item::select(['id', 'uri-id', 'parent', 'verb', 'self'], ['parent' => $item['id']]);
while ($comment = Item::fetch($comments)) {
if ($comment['id'] == $comment['parent']) {
continue;
Logger::info('Deliver participation', ['item' => $comment['id'], 'contact' => $contact_id]);
if (Worker::add(PRIORITY_HIGH, 'Delivery', Delivery::POST, $comment['id'], $contact_id)) {
- ItemDeliveryData::incrementQueueCount($comment['id'], 1);
+ Post\DeliveryData::incrementQueueCount($comment['uri-id'], 1);
}
}
DBA::close($comments);
use Friendica\Core\Logger;
use Friendica\Core\Worker;
-use Friendica\Model\ItemDeliveryData;
+use Friendica\Model\Item;
+use Friendica\Model\Post;
use Friendica\Protocol\ActivityPub;
use Friendica\Util\HTTPSignature;
}
}
+ // This should never fail and is temporariy (until the move to )
+ $item = Item::selectFirst(['uri-id'], ['id' => $target_id]);
+
if (!$success && !Worker::defer() && in_array($cmd, [Delivery::POST])) {
- ItemDeliveryData::incrementQueueFailed($target_id);
+ Post\DeliveryData::incrementQueueFailed($item['uri-id']);
} elseif ($success && in_array($cmd, [Delivery::POST])) {
- ItemDeliveryData::incrementQueueDone($target_id, ItemDeliveryData::ACTIVITYPUB);
+ Post\DeliveryData::incrementQueueDone($item['uri-id'], Post\DeliveryData::ACTIVITYPUB);
}
}
}
if ($cmd == self::MAIL) {
$target_item = DBA::selectFirst('mail', [], ['id' => $target_id]);
if (!DBA::isResult($target_item)) {
- self::setFailedQueue($cmd, $target_id);
+ self::setFailedQueue($cmd, $target_item);
return;
}
$uid = $target_item['uid'];
} elseif ($cmd == self::SUGGESTION) {
$target_item = DBA::selectFirst('fsuggest', [], ['id' => $target_id]);
if (!DBA::isResult($target_item)) {
- self::setFailedQueue($cmd, $target_id);
+ self::setFailedQueue($cmd, $target_item);
return;
}
$uid = $target_item['uid'];
} else {
$item = Model\Item::selectFirst(['parent'], ['id' => $target_id]);
if (!DBA::isResult($item) || empty($item['parent'])) {
- self::setFailedQueue($cmd, $target_id);
+ self::setFailedQueue($cmd, $target_item);
return;
}
$parent_id = intval($item['parent']);
if (empty($target_item)) {
Logger::log('Item ' . $target_id . "wasn't found. Quitting here.");
- self::setFailedQueue($cmd, $target_id);
+ self::setFailedQueue($cmd, $target_item);
return;
}
if (empty($parent)) {
Logger::log('Parent ' . $parent_id . ' for item ' . $target_id . "wasn't found. Quitting here.");
- self::setFailedQueue($cmd, $target_id);
+ self::setFailedQueue($cmd, $target_item);
return;
}
$uid = $target_item['uid'];
} else {
Logger::log('Only public users for item ' . $target_id, Logger::DEBUG);
- self::setFailedQueue($cmd, $target_id);
+ self::setFailedQueue($cmd, $target_item);
return;
}
if (!empty($contact_id) && Model\Contact::isArchived($contact_id)) {
Logger::info('Contact is archived', ['id' => $contact_id, 'cmd' => $cmd, 'item' => $target_item['id']]);
- self::setFailedQueue($cmd, $target_id);
+ self::setFailedQueue($cmd, $target_item);
return;
}
$owner = Model\User::getOwnerDataById($uid);
if (!DBA::isResult($owner)) {
- self::setFailedQueue($cmd, $target_id);
+ self::setFailedQueue($cmd, $target_item);
return;
}
['id' => $contact_id, 'blocked' => false, 'pending' => false, 'self' => false]
);
if (!DBA::isResult($contact)) {
- self::setFailedQueue($cmd, $target_id);
+ self::setFailedQueue($cmd, $target_item);
return;
}
if (Network::isUrlBlocked($contact['url'])) {
- self::setFailedQueue($cmd, $target_id);
+ self::setFailedQueue($cmd, $target_item);
return;
}
/**
* Increased the "failed" counter in the item delivery data
*
- * @param string $cmd Command
- * @param integer $id Item id
+ * @param string $cmd Command
+ * @param array $item Item array
*/
- private static function setFailedQueue(string $cmd, int $id)
+ private static function setFailedQueue(string $cmd, array $item)
{
if (!in_array($cmd, [Delivery::POST, Delivery::POKE])) {
return;
}
- Model\ItemDeliveryData::incrementQueueFailed($id);
+ Model\Post\DeliveryData::incrementQueueFailed($item['uri-id'] ?? $item['id']);
}
/**
DFRN::import($atom, $target_importer);
if (in_array($cmd, [Delivery::POST, Delivery::POKE])) {
- Model\ItemDeliveryData::incrementQueueDone($target_item['id'], Model\ItemDeliveryData::DFRN);
+ Model\Post\DeliveryData::incrementQueueDone($target_item['uri-id'], Model\Post\DeliveryData::DFRN);
}
return;
}
- $protocol = Model\ItemDeliveryData::DFRN;
+ $protocol = Model\Post\DeliveryData::DFRN;
// We don't have a relationship with contacts on a public post.
// Se we transmit with the new method and via Diaspora as a fallback
if (in_array($cmd, [Delivery::POST, Delivery::POKE])) {
if (($deliver_status >= 200) && ($deliver_status <= 299)) {
- Model\ItemDeliveryData::incrementQueueDone($target_item['id'], $protocol);
+ Model\Post\DeliveryData::incrementQueueDone($target_item['uri-id'], $protocol);
} else {
- Model\ItemDeliveryData::incrementQueueFailed($target_item['id']);
+ Model\Post\DeliveryData::incrementQueueFailed($target_item['uri-id']);
}
}
return;
if ($deliver_status < 200) {
// Legacy DFRN
$deliver_status = DFRN::deliver($owner, $contact, $atom);
- $protocol = Model\ItemDeliveryData::LEGACY_DFRN;
+ $protocol = Model\Post\DeliveryData::LEGACY_DFRN;
}
} else {
$deliver_status = DFRN::deliver($owner, $contact, $atom);
- $protocol = Model\ItemDeliveryData::LEGACY_DFRN;
+ $protocol = Model\Post\DeliveryData::LEGACY_DFRN;
}
Logger::info('DFRN Delivery', ['cmd' => $cmd, 'url' => $contact['url'], 'guid' => ($target_item['guid'] ?? '') ?: $target_item['id'], 'return' => $deliver_status]);
Model\Contact::unmarkForArchival($contact);
if (in_array($cmd, [Delivery::POST, Delivery::POKE])) {
- Model\ItemDeliveryData::incrementQueueDone($target_item['id'], $protocol);
+ Model\Post\DeliveryData::incrementQueueDone($target_item['uri-id'], $protocol);
}
} else {
// The message could not be delivered. We mark the contact as "dead"
Logger::info('Delivery failed: defer message', ['id' => ($target_item['guid'] ?? '') ?: $target_item['id']]);
if (!Worker::defer() && in_array($cmd, [Delivery::POST, Delivery::POKE])) {
- Model\ItemDeliveryData::incrementQueueFailed($target_item['id']);
+ Model\Post\DeliveryData::incrementQueueFailed($target_item['uri-id']);
}
}
}
Model\Contact::unmarkForArchival($contact);
if (in_array($cmd, [Delivery::POST, Delivery::POKE])) {
- Model\ItemDeliveryData::incrementQueueDone($target_item['id'], Model\ItemDeliveryData::DIASPORA);
+ Model\Post\DeliveryData::incrementQueueDone($target_item['uri-id'], Model\Post\DeliveryData::DIASPORA);
}
} else {
// The message could not be delivered. We mark the contact as "dead"
Logger::info('Delivery failed: defer message', ['id' => ($target_item['guid'] ?? '') ?: $target_item['id']]);
// defer message for redelivery
if (!Worker::defer() && in_array($cmd, [Delivery::POST, Delivery::POKE])) {
- Model\ItemDeliveryData::incrementQueueFailed($target_item['id']);
+ Model\Post\DeliveryData::incrementQueueFailed($target_item['uri-id']);
}
} elseif (in_array($cmd, [Delivery::POST, Delivery::POKE])) {
- Model\ItemDeliveryData::incrementQueueFailed($target_item['id']);
+ Model\Post\DeliveryData::incrementQueueFailed($target_item['uri-id']);
}
}
}
Email::send($addr, $subject, $headers, $target_item);
- Model\ItemDeliveryData::incrementQueueDone($target_item['id'], Model\ItemDeliveryData::MAIL);
+ Model\Post\DeliveryData::incrementQueueDone($target_item['uri-id'], Model\Post\DeliveryData::MAIL);
Logger::info('Delivered via mail', ['guid' => $target_item['guid'], 'to' => $addr, 'subject' => $subject]);
}
use Friendica\Model\Conversation;
use Friendica\Model\Group;
use Friendica\Model\Item;
-use Friendica\Model\ItemDeliveryData;
+use Friendica\Model\Post;
use Friendica\Model\PushSubscriber;
use Friendica\Model\User;
use Friendica\Network\Probe;
/// @TODO Redeliver/queue these items on failure, though there is no contact record
$delivery_queue_count++;
Salmon::slapper($owner, $url, $slap);
- ItemDeliveryData::incrementQueueDone($target_id, ItemDeliveryData::OSTATUS);
+ Post\DeliveryData::incrementQueueDone($target_item['uri-id'], Post\DeliveryData::OSTATUS);
}
}
// Workaround for pure connector posts
if (in_array($cmd, [Delivery::POST, Delivery::POKE])) {
if ($delivery_queue_count == 0) {
- ItemDeliveryData::incrementQueueDone($target_item['id']);
+ Post\DeliveryData::incrementQueueDone($target_item['uri-id']);
$delivery_queue_count = 1;
}
- ItemDeliveryData::incrementQueueCount($target_item['id'], $delivery_queue_count);
+ Post\DeliveryData::incrementQueueCount($target_item['uri-id'], $delivery_queue_count);
}
}
"uri-id" => ["uri-id"]
]
],
- "item-delivery-data" => [
- "comment" => "Delivery data for items",
- "fields" => [
- "iid" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "relation" => ["item" => "id"], "comment" => "Item id"],
- "postopts" => ["type" => "text", "comment" => "External post connectors add their network name to this comma-separated string to identify that they should be delivered to these networks during delivery"],
- "inform" => ["type" => "mediumtext", "comment" => "Additional receivers of the linked item"],
- "queue_count" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Initial number of delivery recipients, used as item.delivery_queue_count"],
- "queue_done" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Number of successful deliveries, used as item.delivery_queue_done"],
- "queue_failed" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Number of unsuccessful deliveries, used as item.delivery_queue_failed"],
- "activitypub" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Number of successful deliveries via ActivityPub"],
- "dfrn" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Number of successful deliveries via DFRN"],
- "legacy_dfrn" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Number of successful deliveries via legacy DFRN"],
- "diaspora" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Number of successful deliveries via Diaspora"],
- "ostatus" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Number of successful deliveries via OStatus"],
- ],
- "indexes" => [
- "PRIMARY" => ["iid"],
- ]
- ],
"item-uri" => [
"comment" => "URI and GUID for items",
"fields" => [
"url" => ["url"]
]
],
+ "post-delivery-data" => [
+ "comment" => "Delivery data for items",
+ "fields" => [
+ "uri-id" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "relation" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the item uri"],
+ "postopts" => ["type" => "text", "comment" => "External post connectors add their network name to this comma-separated string to identify that they should be delivered to these networks during delivery"],
+ "inform" => ["type" => "mediumtext", "comment" => "Additional receivers of the linked item"],
+ "queue_count" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Initial number of delivery recipients, used as item.delivery_queue_count"],
+ "queue_done" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Number of successful deliveries, used as item.delivery_queue_done"],
+ "queue_failed" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Number of unsuccessful deliveries, used as item.delivery_queue_failed"],
+ "activitypub" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Number of successful deliveries via ActivityPub"],
+ "dfrn" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Number of successful deliveries via DFRN"],
+ "legacy_dfrn" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Number of successful deliveries via legacy DFRN"],
+ "diaspora" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Number of successful deliveries via Diaspora"],
+ "ostatus" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Number of successful deliveries via OStatus"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["uri-id"],
+ ]
+ ],
"post-tag" => [
"comment" => "post relation to tags",
"fields" => [