]> git.mxchange.org Git - friendica.git/blobdiff - mod/display.php
Merge pull request #11761 from tobiasd/20220722-zh-cn
[friendica.git] / mod / display.php
index 580ff40fe8bc9ec956fc7c8c4edd8a6c158c4978..ed2c9ef0f7886e4c19e77422159a16a3a668e422 100644 (file)
@@ -38,6 +38,7 @@ use Friendica\Network\HTTPException;
 use Friendica\Protocol\ActivityPub;
 use Friendica\Protocol\DFRN;
 use Friendica\Protocol\Diaspora;
+use Friendica\Util\DateTimeFormat;
 
 function display_init(App $a)
 {
@@ -106,7 +107,7 @@ function display_init(App $a)
        }
 
        if ($item['gravity'] != GRAVITY_PARENT) {
-               $parent = Post::selectFirstForUser($item_user, $fields, ['uid' => [$item['uid'], local_user()], 'uri-id' => $item['parent-uri-id']], ['order' => ['uid']]);
+               $parent = Post::selectFirstForUser($item_user, $fields, ['uid' => [0, $item_user], 'uri-id' => $item['parent-uri-id']], ['order' => ['uid' => true]]);
                $item = $parent ?: $item;
        }
 
@@ -117,6 +118,7 @@ function display_init(App $a)
        } else {
                DI::page()['aside'] = Widget\VCard::getHTML($author);
        }
+       $a->setProfileOwner($item['uid']);
 }
 
 function display_fetchauthor($item)
@@ -158,6 +160,20 @@ function display_content(App $a, $update = false, $update_uid = 0)
                        }
                        $parent_uri_id = $item['parent-uri-id'];
                }
+               if (empty($_REQUEST['force'])) {
+                       $browser_update = intval(DI::pConfig()->get($update_uid, 'system', 'update_interval'));
+                       if (!empty($browser_update)) {
+                               $update_date = date(DateTimeFormat::MYSQL, time() - ($browser_update / 500));
+                               if (!Post::exists(["`parent-uri-id` = ? AND `uid` IN (?, ?) AND `received` > ?", $parent_uri_id, 0, $update_uid, $update_date])) {
+                                       Logger::debug('No updated content', ['uri-id' => $uri_id, 'uid' => $update_uid, 'updated' => $update_date]);
+                                       return '';
+                               } else {
+                                       Logger::debug('Updated content found', ['uri-id' => $uri_id, 'uid' => $update_uid, 'updated' => $update_date]);
+                               }
+                       }       
+               } else {
+                       Logger::debug('Forced content update', ['uri-id' => $uri_id, 'uid' => $update_uid]);
+               }
        } else {
                $uri_id = ((DI::args()->getArgc() > 2) ? DI::args()->getArgv()[2] : 0);
                $parent_uri_id = $uri_id;
@@ -286,7 +302,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
 
        // Preparing the meta header
        $description = trim(BBCode::toPlaintext($item['body']));
-       $title = trim(BBCode::toPlaintext($item['title']));
+       $title = trim(BBCode::toPlaintext($item['title'] ?? ''));
        $author_name = $item['author-name'];
 
        $image = DI::baseUrl()->remove($item['author-avatar']);