]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/GContact.php
File and category aren't using "term" anymore
[friendica.git] / src / Model / GContact.php
index 59c84bc4907b62a0950d22cf4b353441eb5c5062..becfd61b08e44105a9a4452d0b20154a327ad3ff 100644 (file)
@@ -107,12 +107,13 @@ class GContact
 
                        // Ignore results that look strange.
                        // For historic reasons the gcontact table does contain some garbage.
-                       if (!empty($urlparts['query']) || !empty($urlparts['fragment'])) {
+                       if (empty($result['nurl']) || !empty($urlparts['query']) || !empty($urlparts['fragment'])) {
                                continue;
                        }
 
                        $gcontacts[] = Contact::getDetailsByURL($result['nurl'], local_user());
                }
+               DBA::close($results);
                return $gcontacts;
        }
 
@@ -563,6 +564,7 @@ class GContact
                                PortableContact::loadWorker(0, 0, 0, $base);
                        }
                }
+               DBA::close($contacts);
        }
 
        /**
@@ -884,11 +886,11 @@ class GContact
                        $items = $outbox['orderedItems'];
                } elseif (!empty($outbox['first']['orderedItems'])) {
                        $items = $outbox['first']['orderedItems'];
-               } elseif (!empty($outbox['first']['href'])) {
+               } elseif (!empty($outbox['first']['href']) && ($outbox['first']['href'] != $feed)) {
                        self::updateFromOutbox($outbox['first']['href'], $data);
                        return;
                } elseif (!empty($outbox['first'])) {
-                       if (is_string($outbox['first'])) {
+                       if (is_string($outbox['first']) && ($outbox['first'] != $feed)) {
                                self::updateFromOutbox($outbox['first'], $data);
                        } else {
                                Logger::warning('Unexpected data', ['outbox' => $outbox]);
@@ -1343,19 +1345,23 @@ class GContact
                        foreach ($contacts as $contact) {
                                $gcontact = DBA::selectFirst('gcontact', ['id'], ['nurl' => Strings::normaliseLink(($contact))]);
                                if (DBA::isResult($gcontact)) {
+                                       $fields = [];
                                        if (in_array($contact, $followers)) {
                                                $fields = ['gcid' => $gcid, 'follower-gcid' => $gcontact['id']];
                                        } elseif (in_array($contact, $followings)) {
                                                $fields = ['gcid' => $gcontact['id'], 'follower-gcid' => $gcid];
                                        }
-                                       Logger::info('Set relation between contacts', $fields);
-                                       DBA::update('gfollower', ['deleted' => false], $fields, true);
-                                       continue;
+
+                                       if (!empty($fields)) {
+                                               Logger::info('Set relation between contacts', $fields);
+                                               DBA::update('gfollower', ['deleted' => false], $fields, true);
+                                               continue;
+                                       }
                                }
 
                                if (!Network::isUrlBlocked($contact)) {
                                        Logger::info('Discover new AP contact', ['url' => $contact]);
-                                       Worker::add(PRIORITY_LOW, 'UpdateGContact', $contact);
+                                       Worker::add(PRIORITY_LOW, 'UpdateGContact', $contact, 'nodiscover');
                                } else {
                                        Logger::info('No discovery, the URL is blocked.', ['url' => $contact]);
                                }
@@ -1395,7 +1401,7 @@ class GContact
                                                }
                                                if (!Network::isUrlBlocked($entry['value'])) {
                                                        Logger::info('Discover new PoCo contact', ['url' => $entry['value']]);
-                                                       Worker::add(PRIORITY_LOW, 'UpdateGContact', $entry['value']);
+                                                       Worker::add(PRIORITY_LOW, 'UpdateGContact', $entry['value'], 'nodiscover');
                                                } else {
                                                        Logger::info('No discovery, the URL is blocked.', ['url' => $entry['value']]);
                                                }