]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/Feed.php
Standards
[friendica.git] / src / Protocol / Feed.php
index 1cecee1e2310a0e50704c1cc95807e211ffe2ed5..a2e9daaa036ab31826aa4ac82991ec72e5cd173b 100644 (file)
@@ -616,10 +616,14 @@ 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 (!$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 +634,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,24 +642,17 @@ class Feed
                        $post_delay = 0;
 
                        foreach ($postings as $posting) {
-                               $publish_time = time();
-
-                               if ($posting['notify']) {
-                                       if ($delay > 0) {
-                                               $publish_time = time() + $post_delay;
-                                               Logger::notice('Got publishing date', ['delay' => $delay, 'cid' => $contact['id'], 'url' => $contact['url']]);
-                                               $post_delay += $delay;
-                                       }
+                               if ($delay > 0) {
+                                       $publish_time = time() + $post_delay;
+                                       $post_delay += $delay;
+                               } else {
+                                       $publish_time = time();
+                               }
 
-                                       $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;
-                                       }
+                               $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) {
+                                       $publish_time = $next_publish;
                                }
                                $publish_at = date(DateTimeFormat::MYSQL, $publish_time);