mirror of
https://github.com/friendica/friendica
synced 2025-04-27 09:10:12 +00:00
We now store uncommon endpoints
This commit is contained in:
parent
b89f727cca
commit
990eea2c4e
7 changed files with 156 additions and 4 deletions
|
@ -365,7 +365,7 @@ class APContact
|
|||
// To-Do
|
||||
|
||||
// Unhandled
|
||||
// tag, attachment, image, nomadicLocations, signature, featured, movedTo, liked
|
||||
// tag, attachment, image, nomadicLocations, signature, movedTo, liked
|
||||
|
||||
// Unhandled from Misskey
|
||||
// sharedInbox, isCat
|
||||
|
@ -431,6 +431,30 @@ class APContact
|
|||
$apcontact['uri-id'] = ItemURI::insert(['uri' => $apcontact['url'], 'guid' => $apcontact['uuid']]);
|
||||
}
|
||||
|
||||
foreach (APContact\Endpoint::ENDPOINT_NAMES as $type => $name) {
|
||||
$value = JsonLD::fetchElement($compacted, $name, '@id');
|
||||
if (empty($value)) {
|
||||
continue;
|
||||
}
|
||||
APContact\Endpoint::update($apcontact['uri-id'], $type, $value);
|
||||
}
|
||||
|
||||
if (!empty($compacted['as:endpoints'])) {
|
||||
foreach ($compacted['as:endpoints'] as $name => $endpoint) {
|
||||
if (empty($endpoint['@id']) || !is_string($endpoint['@id'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($name, APContact\Endpoint::ENDPOINT_NAMES)) {
|
||||
$key = array_search($name, APContact\Endpoint::ENDPOINT_NAMES);
|
||||
APContact\Endpoint::update($apcontact['uri-id'], $key, $endpoint['@id']);
|
||||
Logger::debug('Store endpoint', ['key' => $key, 'name' => $name, 'endpoint' => $endpoint['@id']]);
|
||||
} elseif (!in_array($name, ['as:sharedInbox', 'as:uploadMedia', 'as:oauthTokenEndpoint', 'as:oauthAuthorizationEndpoint', 'litepub:oauthRegistrationEndpoint'])) {
|
||||
Logger::debug('Unknown endpoint', ['name' => $name, 'endpoint' => $endpoint['@id']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$apcontact['updated'] = DateTimeFormat::utcNow();
|
||||
|
||||
// We delete the old entry when the URL is changed
|
||||
|
|
71
src/Model/APContact/Endpoint.php
Normal file
71
src/Model/APContact/Endpoint.php
Normal file
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2022, the Friendica project
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Model\APContact;
|
||||
|
||||
use Friendica\Database\DBA;
|
||||
|
||||
class Endpoint
|
||||
{
|
||||
// Mobilizon Endpoints
|
||||
const DISCUSSIONS = 10;
|
||||
const EVENTS = 11;
|
||||
const MEMBERS = 12;
|
||||
const POSTS = 13;
|
||||
const RESOURCES = 14;
|
||||
const TODOS = 15;
|
||||
|
||||
// Peertube Endpoints
|
||||
const PLAYLISTS = 20;
|
||||
|
||||
// Mastodon Endpoints
|
||||
const DEVICES = 30;
|
||||
|
||||
const ENDPOINT_NAMES = [
|
||||
self::PLAYLISTS => 'pt:playlists',
|
||||
self::DISCUSSIONS => 'mobilizon:discussions',
|
||||
self::EVENTS => 'mobilizon:events',
|
||||
self::MEMBERS => 'mobilizon:members',
|
||||
self::POSTS => 'mobilizon:posts',
|
||||
self::RESOURCES => 'mobilizon:resources',
|
||||
self::TODOS => 'mobilizon:todos',
|
||||
self::DEVICES => 'toot:devices',
|
||||
];
|
||||
|
||||
/**
|
||||
* Update an apcontact endpoint
|
||||
*
|
||||
* @param int $owner_uri_id
|
||||
* @param int $type
|
||||
* @param string $url
|
||||
* @return bool
|
||||
*/
|
||||
public static function update(int $owner_uri_id, int $type, string $url)
|
||||
{
|
||||
if (empty($url) || empty($owner_uri_id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$fields = ['owner-uri-id' => $owner_uri_id, 'type' => $type];
|
||||
|
||||
return DBA::update('endpoint', $fields, ['url' => $url], true);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue