]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/OStatus.php
Merge branch 'master' into develop
[friendica.git] / src / Protocol / OStatus.php
index 602d178bce2b77a5be73d2725619ff7d1fed693c..ce9e6642edec4edab337907fdc57bbbbd3bcda6c 100644 (file)
@@ -537,13 +537,12 @@ class OStatus
        private static function deleteNotice($item)
        {
                $condition = ['uid' => $item['uid'], 'author-link' => $item['author-link'], 'uri' => $item['uri']];
-               $deleted = dba::selectFirst('item', ['id', 'parent-uri'], $condition);
-               if (!DBM::is_result($deleted)) {
-                       logger('Item from '.$item['author-link'].' with uri '.$item['uri'].' for user '.$item['uid']." wasn't found. We don't delete it. ");
+               if (!dba::exists('item', $condition)) {
+                       logger('Item from '.$item['author-link'].' with uri '.$item['uri'].' for user '.$item['uid']." wasn't found. We don't delete it.");
                        return;
                }
 
-               Item::deleteById($deleted["id"]);
+               Item::delete($condition);
 
                logger('Deleted item with uri '.$item['uri'].' for user '.$item['uid']);
        }
@@ -1313,7 +1312,7 @@ class OStatus
        }
 
        /**
-        * @brief Adds attachement data to the XML document
+        * @brief Adds attachment data to the XML document
         *
         * @param object $doc  XML document
         * @param object $root XML root element where the hub links are added
@@ -1328,11 +1327,13 @@ class OStatus
                switch ($siteinfo["type"]) {
                        case 'photo':
                                $imgdata = Image::getInfoFromURL($siteinfo["image"]);
-                               $attributes = ["rel" => "enclosure",
-                                               "href" => $siteinfo["image"],
-                                               "type" => $imgdata["mime"],
-                                               "length" => intval($imgdata["size"])];
-                               XML::addElement($doc, $root, "link", "", $attributes);
+                               if ($imgdata) {
+                                       $attributes = ["rel" => "enclosure",
+                                                       "href" => $siteinfo["image"],
+                                                       "type" => $imgdata["mime"],
+                                                       "length" => intval($imgdata["size"])];
+                                       XML::addElement($doc, $root, "link", "", $attributes);
+                               }
                                break;
                        case 'video':
                                $attributes = ["rel" => "enclosure",
@@ -1348,12 +1349,14 @@ class OStatus
 
                if (!Config::get('system', 'ostatus_not_attach_preview') && ($siteinfo["type"] != "photo") && isset($siteinfo["image"])) {
                        $imgdata = Image::getInfoFromURL($siteinfo["image"]);
-                       $attributes = ["rel" => "enclosure",
-                                       "href" => $siteinfo["image"],
-                                       "type" => $imgdata["mime"],
-                                       "length" => intval($imgdata["size"])];
+                       if ($imgdata) {
+                               $attributes = ["rel" => "enclosure",
+                                               "href" => $siteinfo["image"],
+                                               "type" => $imgdata["mime"],
+                                               "length" => intval($imgdata["size"])];
 
-                       XML::addElement($doc, $root, "link", "", $attributes);
+                               XML::addElement($doc, $root, "link", "", $attributes);
+                       }
                }
 
                $arr = explode('[/attach],', $item['attach']);
@@ -1944,7 +1947,7 @@ class OStatus
         * @param bool   $complete default true
         * @return void
         */
-       private static function entryFooter($doc, $entry, $item, $owner, $complete = true)
+       private static function entryFooter($doc, $entry, array $item, array $owner, $complete = true)
        {
                $mentioned = [];
 
@@ -1984,6 +1987,7 @@ class OStatus
 
                        if (isset($parent_item)) {
                                $r = dba::fetch_first("SELECT `conversation-uri`, `conversation-href` FROM `conversation` WHERE `item-uri` = ?", $parent_item);
+
                                if (DBM::is_result($r)) {
                                        if ($r['conversation-uri'] != '') {
                                                $conversation_uri = $r['conversation-uri'];
@@ -2044,9 +2048,11 @@ class OStatus
                }
 
                if ($owner['account-type'] == ACCOUNT_TYPE_COMMUNITY) {
-                       XML::addElement($doc, $entry, "link", "", ["rel" => "mentioned",
-                                                                       "ostatus:object-type" => "http://activitystrea.ms/schema/1.0/group",
-                                                                       "href" => $owner['url']]);
+                       XML::addElement($doc, $entry, "link", "", [
+                               "rel" => "mentioned",
+                               "ostatus:object-type" => "http://activitystrea.ms/schema/1.0/group",
+                               "href" => $owner['url']
+                       ]);
                }
 
                if (!$item["private"]) {