]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/OStatus.php
The endless saga of the fight against notices continues
[friendica.git] / src / Protocol / OStatus.php
index 80c6edbe9f2b8614fe884b875f811f1aeda8a531..ece265c99b391dff3ba23c1c2f545cbebe281b58 100644 (file)
@@ -74,6 +74,16 @@ class OStatus
                $author["contact-id"] = $contact["id"];
 
                $contact = null;
+
+/*
+               This here would be better, but we would get problems with contacts from the statusnet addon
+               This is kept here as a reminder for the future
+
+               $cid = Contact::getIdForURL($author["author-link"], $importer["uid"]);
+               if ($cid) {
+                       $contact = DBA::selectFirst('contact', [], ['id' => $cid]);
+               }
+*/
                if ($aliaslink != '') {
                        $condition = ["`uid` = ? AND `alias` = ? AND `network` != ? AND `rel` IN (?, ?)",
                                        $importer["uid"], $aliaslink, Protocol::STATUSNET,
@@ -219,7 +229,7 @@ class OStatus
                        $gcid = GContact::update($contact);
 
                        GContact::link($gcid, $contact["uid"], $contact["id"]);
-               } else {
+               } elseif ($contact["network"] != Protocol::DFRN) {
                        $contact = null;
                }
 
@@ -312,7 +322,7 @@ class OStatus
                        self::$conv_list = [];
                }
 
-               logger("Import OStatus message", LOGGER_DEBUG);
+               logger('Import OStatus message for user ' . $importer['uid'], LOGGER_DEBUG);
 
                if ($xml == "") {
                        return false;
@@ -351,7 +361,7 @@ class OStatus
                $header["origin"] = 0;
                $header["gravity"] = GRAVITY_COMMENT;
 
-               if (!is_object($doc->firstChild)) {
+               if (!is_object($doc->firstChild) || empty($doc->firstChild->tagName)) {
                        return false;
                }
 
@@ -1351,13 +1361,15 @@ class OStatus
 
                switch ($siteinfo["type"]) {
                        case 'photo':
-                               $imgdata = Image::getInfoFromURL($siteinfo["image"]);
-                               if ($imgdata) {
-                                       $attributes = ["rel" => "enclosure",
-                                                       "href" => $siteinfo["image"],
-                                                       "type" => $imgdata["mime"],
-                                                       "length" => intval($imgdata["size"])];
-                                       XML::addElement($doc, $root, "link", "", $attributes);
+                               if (!empty($siteinfo["image"])) {
+                                       $imgdata = Image::getInfoFromURL($siteinfo["image"]);
+                                       if ($imgdata) {
+                                               $attributes = ["rel" => "enclosure",
+                                                               "href" => $siteinfo["image"],
+                                                               "type" => $imgdata["mime"],
+                                                               "length" => intval($imgdata["size"])];
+                                               XML::addElement($doc, $root, "link", "", $attributes);
+                                       }
                                }
                                break;
                        case 'video':
@@ -1595,12 +1607,9 @@ class OStatus
                }
 
                if (!DBA::isResult($r)) {
-                       $r = q(
-                               "SELECT * FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
-                               DBA::escape(normalise_link($url))
-                       );
+                       $gcontact = DBA::selectFirst('gcontact', [], ['nurl' => normalise_link($url)]);
                        if (DBA::isResult($r)) {
-                               $contact = $r[0];
+                               $contact = $gcontact;
                                $contact["uid"] = -1;
                                $contact["success_update"] = $contact["updated"];
                        }
@@ -1801,14 +1810,11 @@ class OStatus
                        $item['follow'] = $contact['alias'];
                }
 
-               $r = q(
-                       "SELECT `id` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s'",
-                       intval($owner['uid']),
-                       DBA::escape(normalise_link($contact["url"]))
-               );
+               $condition = ['uid' => $owner['uid'], 'nurl' => normalise_link($contact["url"])];
+               $user_contact = DBA::selectFirst('contact', ['id'], $condition);
 
-               if (DBA::isResult($r)) {
-                       $connect_id = $r[0]['id'];
+               if (DBA::isResult($user_contact)) {
+                       $connect_id = $user_contact['id'];
                } else {
                        $connect_id = 0;
                }