mirror of
https://github.com/friendica/friendica
synced 2025-04-23 10:30:11 +00:00
Store Pixelfed's capabilities
This commit is contained in:
parent
a86cd93fb8
commit
da65f0bea7
4 changed files with 46 additions and 0 deletions
|
@ -918,6 +918,8 @@ class Processor
|
|||
|
||||
self::storeReceivers($item['uri-id'], $activity['receiver_urls'] ?? []);
|
||||
|
||||
self::storeCapabilities($item['uri-id'], $activity['capabilities'] ?? []);
|
||||
|
||||
$item['location'] = $activity['location'];
|
||||
|
||||
if (!empty($activity['latitude']) && !empty($activity['longitude'])) {
|
||||
|
@ -1343,6 +1345,29 @@ class Processor
|
|||
}
|
||||
}
|
||||
|
||||
private static function storeCapabilities(int $uriid, array $capabilities)
|
||||
{
|
||||
foreach (['pixelfed:canAnnounce' => Tag::CAN_ANNOUNCE, 'pixelfed:canLike' => Tag::CAN_LIKE, 'pixelfed:canReply' => Tag::CAN_REPLY] as $element => $type) {
|
||||
if (!empty($capabilities[$element])) {
|
||||
foreach ($capabilities[$element] as $capability) {
|
||||
if ($capability == ActivityPub::PUBLIC_COLLECTION) {
|
||||
$name = Receiver::PUBLIC_COLLECTION;
|
||||
} elseif (empty($capability) || ($capability == '[]')) {
|
||||
continue;
|
||||
} elseif ($path = parse_url($capability, PHP_URL_PATH)) {
|
||||
$name = trim($path, '/');
|
||||
} elseif ($host = parse_url($capability, PHP_URL_HOST)) {
|
||||
$name = $host;
|
||||
} else {
|
||||
Logger::warning('Unable to coerce name from capability', ['element' => $element, 'type' => $type, 'capability' => $capability]);
|
||||
$name = '';
|
||||
}
|
||||
Tag::store($uriid, $type, $name, $capability);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an mail post
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue