use Friendica\Model\User;
use Friendica\Network\Probe;
use Friendica\Protocol\Diaspora;
+use Friendica\Protocol\ActivityPub;
use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
*
*/
- $res = Network::post($dfrn_confirm, $params, null, $redirects, 120);
+ $res = Network::post($dfrn_confirm, $params, null, $redirects, 120)->getBody();
logger(' Confirm: received data: ' . $res, LOGGER_DATA);
intval($contact_id)
);
} else {
+ if ($network == Protocol::ACTIVITYPUB) {
+ ActivityPub\Transmitter::sendContactAccept($contact['url'], $contact['hub-verify'], $uid);
+ $pending = true;
+ } else {
+ $pending = false;
+ }
+
// $network !== Protocol::DFRN
$network = defaults($contact, 'network', Protocol::OSTATUS);
- $arr = Probe::uri($contact['url']);
+ $arr = Probe::uri($contact['url'], $network);
$notify = defaults($contact, 'notify' , $arr['notify']);
$poll = defaults($contact, 'poll' , $arr['poll']);
$new_relation = $contact['rel'];
$writable = $contact['writable'];
- if ($network === Protocol::DIASPORA) {
+ if (in_array($network, [Protocol::DIASPORA, Protocol::ACTIVITYPUB])) {
if ($duplex) {
$new_relation = Contact::FRIEND;
} else {
DBA::delete('intro', ['id' => $intro_id]);
- $r = q("UPDATE `contact` SET `name-date` = '%s',
- `uri-date` = '%s',
- `addr` = '%s',
- `notify` = '%s',
- `poll` = '%s',
- `blocked` = 0,
- `pending` = 0,
- `network` = '%s',
- `writable` = %d,
- `hidden` = %d,
- `rel` = %d
- WHERE `id` = %d
- ",
- DBA::escape(DateTimeFormat::utcNow()),
- DBA::escape(DateTimeFormat::utcNow()),
- DBA::escape($addr),
- DBA::escape($notify),
- DBA::escape($poll),
- DBA::escape($network),
- intval($writable),
- intval($hidden),
- intval($new_relation),
- intval($contact_id)
- );
+ $fields = ['name-date' => DateTimeFormat::utcNow(),
+ 'uri-date' => DateTimeFormat::utcNow(), 'addr' => $addr,
+ 'notify' => $notify, 'poll' => $poll, 'blocked' => false,
+ 'pending' => $pending, 'network' => $network,
+ 'writable' => $writable, 'hidden' => $hidden, 'rel' => $new_relation];
+ DBA::update('contact', $fields, ['id' => $contact_id]);
}
if (!DBA::isResult($r)) {
Group::addMember(User::getDefaultGroup($uid, $contact["network"]), $contact['id']);
+ if ($network == Protocol::ACTIVITYPUB && $duplex) {
+ ActivityPub\Transmitter::sendActivity('Follow', $contact['url'], $uid);
+ }
+
// Let's send our user to the contact editor in case they want to
// do anything special with this new friend.
if ($handsfree === null) {
- goaway(System::baseUrl() . '/contacts/' . intval($contact_id));
+ $a->redirect('contact/' . intval($contact_id));
} else {
return;
}
'to_name' => $combined['username'],
'to_email' => $combined['email'],
'uid' => $combined['uid'],
- 'link' => System::baseUrl() . '/contacts/' . $dfrn_record,
+ 'link' => System::baseUrl() . '/contact/' . $dfrn_record,
'source_name' => ((strlen(stripslashes($combined['name']))) ? stripslashes($combined['name']) : L10n::t('[Name Withheld]')),
'source_link' => $combined['url'],
'source_photo' => $combined['photo'],
}
// somebody arrived here by mistake or they are fishing. Send them to the homepage.
- goaway(System::baseUrl());
+ $a->redirect();
// NOTREACHED
}