]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/OStatus.php
OStatus: Avoid a notice
[friendica.git] / src / Protocol / OStatus.php
index dc30b596fcc2b54098e3dc7e3db1a4dacff18ced..bf3a6ef9d597021227c21bd57b6096dbd592c842 100644 (file)
@@ -1,7 +1,24 @@
 <?php
 /**
- * @file src/Protocol/OStatus.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\Protocol;
 
 use DOMDocument;
@@ -230,7 +247,7 @@ class OStatus
                        $gcid = GContact::update($contact);
 
                        GContact::link($gcid, $contact["uid"], $contact["id"]);
-               } elseif ($contact["network"] != Protocol::DFRN) {
+               } elseif (empty($contact["network"]) || ($contact["network"] != Protocol::DFRN)) {
                        $contact = [];
                }
 
@@ -568,7 +585,7 @@ class OStatus
                        return;
                }
 
-               Item::delete($condition);
+               Item::markForDeletion($condition);
 
                Logger::log('Deleted item with uri '.$item['uri'].' for user '.$item['uid']);
        }
@@ -1665,7 +1682,7 @@ class OStatus
 
                $entry = self::entryHeader($doc, $owner, $item, $toplevel);
 
-               $condition = ['uid' => $owner["uid"], 'guid' => $repeated_guid, 'private' => false,
+               $condition = ['uid' => $owner["uid"], 'guid' => $repeated_guid, 'private' => [Item::PUBLIC, Item::UNLISTED],
                        'network' => [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]];
                $repeated_item = Item::selectFirst([], $condition);
                if (!DBA::isResult($repeated_item)) {
@@ -1810,7 +1827,7 @@ class OStatus
        {
                $item["id"] = $item["parent"] = 0;
                $item["created"] = $item["edited"] = date("c");
-               $item["private"] = true;
+               $item["private"] = Item::PRIVATE;
 
                $contact = Probe::uri($item['follow']);
 
@@ -2103,7 +2120,7 @@ class OStatus
                        ]);
                }
 
-               if (!$item["private"] && !$feed_mode) {
+               if (($item['private'] != Item::PRIVATE) && !$feed_mode) {
                        XML::addElement($doc, $entry, "link", "", ["rel" => "ostatus:attention",
                                                                        "href" => "http://activityschema.org/collection/public"]);
                        XML::addElement($doc, $entry, "link", "", ["rel" => "mentioned",
@@ -2195,8 +2212,8 @@ class OStatus
                $authorid = Contact::getIdForURL($owner["url"], 0, true);
 
                $condition = ["`uid` = ? AND `received` > ? AND NOT `deleted`
-                       AND NOT `private` AND `visible` AND `wall` AND `parent-network` IN (?, ?)",
-                       $owner["uid"], $check_date, Protocol::OSTATUS, Protocol::DFRN];
+                       AND `private` != ? AND `visible` AND `wall` AND `parent-network` IN (?, ?)",
+                       $owner["uid"], $check_date, Item::PRIVATE, Protocol::OSTATUS, Protocol::DFRN];
 
                if ($filter === 'comments') {
                        $condition[0] .= " AND `object-type` = ? ";