]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Contact.php
Merge remote-tracking branch 'upstream/develop' into fix-diaspora-signature
[friendica.git] / src / Model / Contact.php
index ae42030952c8a2cada748dca3d9788d08dc35046..23c31d0b17c40fb20962208a05dc6327c335058f 100644 (file)
@@ -557,10 +557,10 @@ class Contact extends BaseObject
                } elseif ($contact['network'] == Protocol::DIASPORA) {
                        Diaspora::sendUnshare($user, $contact);
                } elseif ($contact['network'] == Protocol::ACTIVITYPUB) {
-                       ActivityPub::transmitContactUndo($contact['url'], $user['uid']);
+                       ActivityPub\Transmitter::sendContactUndo($contact['url'], $user['uid']);
 
                        if ($dissolve) {
-                               ActivityPub::transmitContactReject($contact['url'], $contact['hub-verify'], $user['uid']);
+                               ActivityPub\Transmitter::sendContactReject($contact['url'], $contact['hub-verify'], $user['uid']);
                        }
                }
        }
@@ -1322,33 +1322,27 @@ class Contact extends BaseObject
 
                require_once 'include/conversation.php';
 
-               // There are no posts with "uid = 0" with connector networks
-               // This speeds up the query a lot
-               $r = q("SELECT `network`, `id` AS `author-id`, `contact-type` FROM `contact`
-                       WHERE `contact`.`nurl` = '%s' AND `contact`.`uid` = 0",
-                       DBA::escape(normalise_link($contact_url))
-               );
+               $cid = Self::getIdForURL($contact_url);
 
-               if (!DBA::isResult($r)) {
+               $contact = DBA::selectFirst('contact', ['contact-type', 'network'], ['id' => $cid]);
+               if (!DBA::isResult($contact)) {
                        return '';
                }
 
-               if (in_array($r[0]["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""])) {
+               if (in_array($contact["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""])) {
                        $sql = "(`item`.`uid` = 0 OR (`item`.`uid` = ? AND NOT `item`.`global`))";
                } else {
                        $sql = "`item`.`uid` = ?";
                }
 
-               $author_id = intval($r[0]["author-id"]);
-
-               $contact = ($r[0]["contact-type"] == self::ACCOUNT_TYPE_COMMUNITY ? 'owner-id' : 'author-id');
+               $contact_field = ($contact["contact-type"] == self::ACCOUNT_TYPE_COMMUNITY ? 'owner-id' : 'author-id');
 
                if ($thread_mode) {
-                       $condition = ["`$contact` = ? AND `gravity` = ? AND " . $sql,
-                               $author_id, GRAVITY_PARENT, local_user()];
+                       $condition = ["`$contact_field` = ? AND `gravity` = ? AND " . $sql,
+                               $cid, GRAVITY_PARENT, local_user()];
                } else {
-                       $condition = ["`$contact` = ? AND `gravity` IN (?, ?) AND " . $sql,
-                               $author_id, GRAVITY_PARENT, GRAVITY_COMMENT, local_user()];
+                       $condition = ["`$contact_field` = ? AND `gravity` IN (?, ?) AND " . $sql,
+                               $cid, GRAVITY_PARENT, GRAVITY_COMMENT, local_user()];
                }
 
                $params = ['order' => ['created' => true],
@@ -1638,10 +1632,10 @@ class Contact extends BaseObject
 
                if (($ret['network'] === Protocol::DFRN) && !DBA::isResult($contact)) {
                        if ($interactive) {
-                               if (strlen($a->urlpath)) {
+                               if (strlen($a->getURLPath())) {
                                        $myaddr = bin2hex(System::baseUrl() . '/profile/' . $a->user['nickname']);
                                } else {
-                                       $myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname());
+                                       $myaddr = bin2hex($a->user['nickname'] . '@' . $a->getHostName());
                                }
 
                                goaway($ret['request'] . "&addr=$myaddr");
@@ -1775,7 +1769,7 @@ class Contact extends BaseObject
                                $ret = Diaspora::sendShare($a->user, $contact);
                                logger('share returns: ' . $ret);
                        } elseif ($contact['network'] == Protocol::ACTIVITYPUB) {
-                               $ret = ActivityPub::transmitActivity('Follow', $contact['url'], $uid);
+                               $ret = ActivityPub\Transmitter::sendActivity('Follow', $contact['url'], $uid);
                                logger('Follow returns: ' . $ret);
                        }
                }
@@ -1852,7 +1846,7 @@ class Contact extends BaseObject
                        }
 
                        if ($contact['network'] == Protocol::ACTIVITYPUB) {
-                               ActivityPub::transmitContactAccept($contact['url'], $contact['hub-verify'], $importer['uid']);
+                               ActivityPub\Transmitter::sendContactAccept($contact['url'], $contact['hub-verify'], $importer['uid']);
                        }
 
                        // send email notification to owner?
@@ -1923,6 +1917,12 @@ class Contact extends BaseObject
                        } elseif (DBA::isResult($user) && in_array($user['page-flags'], [self::PAGE_SOAPBOX, self::PAGE_FREELOVE, self::PAGE_COMMUNITY])) {
                                $condition = ['uid' => $importer['uid'], 'url' => $url, 'pending' => true];
                                DBA::update('contact', ['pending' => false], $condition);
+
+                               $contact = DBA::selectFirst('contact', ['url', 'network', 'hub-verify'], ['id' => $contact_record['id']]);
+
+                               if ($contact['network'] == Protocol::ACTIVITYPUB) {
+                                       ActivityPub\Transmitter::sendContactAccept($contact['url'], $contact['hub-verify'], $importer['uid']);
+                               }
                        }
                }
        }