X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FContact.php;h=23c31d0b17c40fb20962208a05dc6327c335058f;hb=914b3a9e3eb9d69ae3f7c5eeac828f5a5ca7dc36;hp=ae42030952c8a2cada748dca3d9788d08dc35046;hpb=2eabe45a8e23512e31517ae8660f0576c111e32c;p=friendica.git diff --git a/src/Model/Contact.php b/src/Model/Contact.php index ae42030952..23c31d0b17 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -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']); + } } } }