X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FFollowConfirm.php;h=28c849a861abbf4a7c9e5e9353913cd9db259be9;hb=6c36fd9e01510a14fea9de766b4afe6760912a2e;hp=1e632d92a9e0a805f62ff3e6135968a28d0c30e6;hpb=37f9af2f24ef9bb76b8bd95737386bf752b1b689;p=friendica.git diff --git a/src/Module/FollowConfirm.php b/src/Module/FollowConfirm.php index 1e632d92a9..28c849a861 100644 --- a/src/Module/FollowConfirm.php +++ b/src/Module/FollowConfirm.php @@ -1,93 +1,32 @@ t('Permission denied.') . EOL); return; } - $intro_id = intval(defaults($_POST, 'intro_id' , 0)); - $duplex = intval(defaults($_POST, 'duplex' , 0)); - $cid = intval(defaults($_POST, 'contact_id', 0)); - $hidden = intval(defaults($_POST, 'hidden' , 0)); + $intro_id = intval($_POST['intro_id'] ?? 0); + $duplex = intval($_POST['duplex'] ?? 0); + $hidden = intval($_POST['hidden'] ?? 0); - if (empty($cid)) { - notice(L10n::t('No given contact.') . EOL); - return; - } + $intro = DI::intro()->selectFirst(['id' => $intro_id, 'uid' => local_user()]); - Logger::log('Confirming follower with contact_id: ' . $cid); - - $contact = DBA::selectFirst('contact', [], ['id' => $cid, 'uid' => $uid]); - if (!DBA::isResult($contact)) { - Logger::log('Contact not found in DB.'); - notice(L10n::t('Contact not found.') . EOL); - return; - } - - $relation = $contact['rel']; - $new_relation = $contact['rel']; - $writable = $contact['writable']; - - if (!empty($contact['protocol'])) { - $protocol = $contact['protocol']; - } else { - $protocol = $contact['network']; - } - - if ($protocol == Protocol::ACTIVITYPUB) { - ActivityPub\Transmitter::sendContactAccept($contact['url'], $contact['hub-verify'], $uid); - } - - if (in_array($protocol, [Protocol::DIASPORA, Protocol::ACTIVITYPUB])) { - if ($duplex) { - $new_relation = Contact::FRIEND; - } else { - $new_relation = Contact::FOLLOWER; - } - - if ($new_relation != Contact::FOLLOWER) { - $writable = 1; - } - } - - $fields = ['name-date' => DateTimeFormat::utcNow(), - 'uri-date' => DateTimeFormat::utcNow(), - 'blocked' => false, 'pending' => false, 'protocol' => $protocol, - 'writable' => $writable, 'hidden' => $hidden, 'rel' => $new_relation]; - DBA::update('contact', $fields, ['id' => $cid]); - - if ($new_relation == Contact::FRIEND) { - if ($protocol == Protocol::DIASPORA) { - $user = DBA::selectFirst('user', [], ['uid' => $uid]); - $contact = DBA::select('contact', [], ['id' => $cid]); - $ret = Diaspora::sendShare($user, $contact); - Logger::log('share returns: ' . $ret); - } elseif ($protocol == Protocol::ACTIVITYPUB) { - ActivityPub\Transmitter::sendActivity('Follow', $contact['url'], $uid); - } - } + $cid = $intro->{'contact-id'}; - DBA::delete('intro', ['id' => $intro_id]); + $intro->confirm($duplex, $hidden); - $a->internalRedirect('contact/' . intval($cid)); + DI::baseUrl()->redirect('contact/' . intval($cid)); } }