X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FProtocol%2FFeed.php;h=ebd6f5ed3008ddf1f569d55b78ec08501092cbac;hb=5211c12b0c752f186c1358d9347c24838725120a;hp=dbfb72977d1efd267193106386596cb12c522af9;hpb=b54465ba9c3c3fcea52f2d2907496c056dc0e152;p=friendica.git diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php index dbfb72977d..ebd6f5ed30 100644 --- a/src/Protocol/Feed.php +++ b/src/Protocol/Feed.php @@ -1,6 +1,6 @@ $item]); $notify = Item::isRemoteSelf($contact, $item); @@ -615,11 +559,15 @@ class Feed } $condition = ['uid' => $item['uid'], 'uri' => $item['uri']]; - if (!Item::exists($condition) && !Post\Delayed::exists($item["uri"], $item['uid'])) { - $postings[] = ['item' => $item, 'notify' => $notify, - 'taglist' => $taglist, 'attachments' => $attachments]; + if (!Post::exists($condition) && !Post\Delayed::exists($item["uri"], $item['uid'])) { + if (!$notify) { + Post\Delayed::publish($item, $notify, $taglist, $attachments); + } else { + $postings[] = ['item' => $item, 'notify' => $notify, + 'taglist' => $taglist, 'attachments' => $attachments]; + } } else { - Logger::info('Post already exists in the delayed posts queue', ['uri' => $item["uri"]]); + Logger::info('Post already created or exists in the delayed posts queue', ['uid' => $item['uid'], 'uri' => $item["uri"]]); } } @@ -630,7 +578,7 @@ class Feed // Posts shouldn't be delayed more than a day $interval = min(1440, self::getPollInterval($contact)); $delay = max(round(($interval * 60) / $total), 60 * $min_posting); - Logger::notice('Got posting delay', ['delay' => $delay, 'interval' => $interval, 'items' => $total, 'cid' => $contact['id'], 'url' => $contact['url']]); + Logger::info('Got posting delay', ['delay' => $delay, 'interval' => $interval, 'items' => $total, 'cid' => $contact['id'], 'url' => $contact['url']]); } else { $delay = 0; } @@ -638,14 +586,8 @@ class Feed $post_delay = 0; foreach ($postings as $posting) { - if (!$posting['notify']) { - Post\Delayed::publish($posting['item'], $posting['notify'], $posting['taglist'], $posting['attachments']); - continue; - } - if ($delay > 0) { $publish_time = time() + $post_delay; - Logger::notice('Got publishing date', ['delay' => $delay, 'cid' => $contact['id'], 'url' => $contact['url']]); $post_delay += $delay; } else { $publish_time = time(); @@ -654,16 +596,11 @@ class Feed $last_publish = DI::pConfig()->get($posting['item']['uid'], 'system', 'last_publish', 0, true); $next_publish = max($last_publish + (60 * $min_posting), time()); if ($publish_time < $next_publish) { - Logger::notice('Adapting publish time', - ['last' => date(DateTimeFormat::MYSQL, $last_publish), - 'next' => date(DateTimeFormat::MYSQL, $next_publish), - 'publish' => date(DateTimeFormat::MYSQL, $publish_time)]); $publish_time = $next_publish; } $publish_at = date(DateTimeFormat::MYSQL, $publish_time); - Post\Delayed::add($publish_at, $posting['item'], $posting['notify'], $posting['taglist'], $posting['attachments']); - DI::pConfig()->set($item['uid'], 'system', 'last_publish', $next_publish); + Post\Delayed::add($posting['item']['uri'], $posting['item'], $posting['notify'], false, $publish_at, $posting['taglist'], $posting['attachments']); } } @@ -953,12 +890,12 @@ class Feed $params = ['order' => ['received' => true], 'limit' => $max_items]; if ($filter === 'posts') { - $ret = Item::selectThread([], $condition, $params); + $ret = Post::selectThread(Item::DELIVER_FIELDLIST, $condition, $params); } else { - $ret = Item::select([], $condition, $params); + $ret = Post::select(Item::DELIVER_FIELDLIST, $condition, $params); } - $items = Item::inArray($ret); + $items = Post::toArray($ret); $doc = new DOMDocument('1.0', 'utf-8'); $doc->formatOutput = true; @@ -1107,7 +1044,7 @@ class Feed $condition = ['uid' => $owner["uid"], 'guid' => $repeated_guid, 'private' => [Item::PUBLIC, Item::UNLISTED], 'network' => Protocol::FEDERATED]; - $repeated_item = Item::selectFirst([], $condition); + $repeated_item = Post::selectFirst(Item::DELIVER_FIELDLIST, $condition); if (!DBA::isResult($repeated_item)) { return false; } @@ -1199,9 +1136,9 @@ class Feed $mentioned = []; if ($item['gravity'] != GRAVITY_PARENT) { - $parent = Item::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]); + $parent = Post::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]); - $thrparent = Item::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner["uid"], 'uri' => $item['thr-parent']]); + $thrparent = Post::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner["uid"], 'uri' => $item['thr-parent']]); if (DBA::isResult($thrparent)) { $mentioned[$thrparent["author-link"]] = $thrparent["author-link"];