X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FContact.php;h=fa6966a0eff8c66144cc4eaffc7d00cc022429b9;hb=dc49ad090eca1bf4e511091418166da6fe68009b;hp=2bcb86327bdd0c6ba1dc652286c9dd5d28352c2f;hpb=6a8ebc8639507404be07bb7d6fd5a37189e46563;p=friendica.git diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 2bcb86327b..fa6966a0ef 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -557,7 +557,11 @@ class Contact extends BaseObject } elseif ($contact['network'] == Protocol::DIASPORA) { Diaspora::sendUnshare($user, $contact); } elseif ($contact['network'] == Protocol::ACTIVITYPUB) { - ActivityPub::transmitContactActivity('Undo', $contact['url'], '', $user['uid']); + ActivityPub\Transmitter::sendContactUndo($contact['url'], $user['uid']); + + if ($dissolve) { + ActivityPub\Transmitter::sendContactReject($contact['url'], $contact['hub-verify'], $user['uid']); + } } } @@ -1318,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], @@ -1771,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); } } @@ -1834,7 +1832,7 @@ class Contact extends BaseObject return; } - $url = $pub_contact['url']; + $url = defaults($datarray, 'author-link', $pub_contact['url']); $name = $pub_contact['name']; $photo = $pub_contact['photo']; $nick = $pub_contact['nick']; @@ -1848,7 +1846,7 @@ class Contact extends BaseObject } if ($contact['network'] == Protocol::ACTIVITYPUB) { - ActivityPub::transmitContactActivity('Accept', $contact['url'], $contact['hub-verify'], $importer['uid']); + ActivityPub\Transmitter::sendContactAccept($contact['url'], $contact['hub-verify'], $importer['uid']); } // send email notification to owner? @@ -1919,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']); + } } } }