mirror of
https://github.com/friendica/friendica
synced 2025-05-11 21:04:11 +02:00
Relay code reworked to support AP delivery
This commit is contained in:
parent
490ce976c1
commit
0384bf3e76
8 changed files with 285 additions and 206 deletions
|
@ -176,6 +176,14 @@ class Contact
|
|||
*/
|
||||
public static function insert(array $fields, bool $on_duplicate_update = false)
|
||||
{
|
||||
if (!empty($fields['baseurl']) && empty($fields['gsid'])) {
|
||||
$fields['gsid'] = GServer::getID($fields['baseurl'], true);
|
||||
}
|
||||
|
||||
if (empty($fields['created'])) {
|
||||
$fields['created'] = DateTimeFormat::utcNow();
|
||||
}
|
||||
|
||||
$ret = DBA::insert('contact', $fields, $on_duplicate_update);
|
||||
$contact = DBA::selectFirst('contact', ['nurl', 'uid'], ['id' => DBA::lastInsertId()]);
|
||||
if (!DBA::isResult($contact)) {
|
||||
|
|
|
@ -31,7 +31,7 @@ use Friendica\Database\DBA;
|
|||
use Friendica\DI;
|
||||
use Friendica\Module\Register;
|
||||
use Friendica\Network\CurlResult;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Protocol\Relay;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Strings;
|
||||
|
@ -518,7 +518,7 @@ class GServer
|
|||
$data['tags'] = [];
|
||||
}
|
||||
|
||||
$gserver = DBA::selectFirst('gserver', ['id', 'relay-subscribe', 'relay-scope'], ['nurl' => Strings::normaliseLink($server_url)]);
|
||||
$gserver = DBA::selectFirst('gserver', ['id', 'url', 'network', 'relay-subscribe', 'relay-scope'], ['nurl' => Strings::normaliseLink($server_url)]);
|
||||
if (!DBA::isResult($gserver)) {
|
||||
return;
|
||||
}
|
||||
|
@ -567,8 +567,22 @@ class GServer
|
|||
$fields['batch'] = $data['protocols']['dfrn'];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['protocols']['activitypub'])) {
|
||||
$fields['network'] = Protocol::ACTIVITYPUB;
|
||||
|
||||
if (!empty($data['protocols']['activitypub']['actor'])) {
|
||||
$fields['url'] = $data['protocols']['activitypub']['actor'];
|
||||
}
|
||||
if (!empty($data['protocols']['activitypub']['receive'])) {
|
||||
$fields['batch'] = $data['protocols']['activitypub']['receive'];
|
||||
}
|
||||
}
|
||||
}
|
||||
Diaspora::setRelayContact($server_url, $fields);
|
||||
|
||||
Logger::info('Discovery ended', ['server' => $server_url, 'data' => $fields]);
|
||||
|
||||
Relay::updateContact($gserver, $fields);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue