Handle "commentsEnabled"
This commit is contained in:
parent
1b13c76d2e
commit
b4a380e9de
|
@ -918,7 +918,15 @@ class Processor
|
||||||
|
|
||||||
self::storeReceivers($item['uri-id'], $activity['receiver_urls'] ?? []);
|
self::storeReceivers($item['uri-id'], $activity['receiver_urls'] ?? []);
|
||||||
|
|
||||||
self::storeCapabilities($item['uri-id'], $activity['capabilities'] ?? []);
|
if (!empty($activity['capabilities'])) {
|
||||||
|
$restrictions = self::storeCapabilities($item['uri-id'], $activity['capabilities']);
|
||||||
|
} elseif (!is_null($activity['can-comment']) && !$activity['can-comment']) {
|
||||||
|
$restrictions = [Tag::CAN_REPLY];
|
||||||
|
} else {
|
||||||
|
$restrictions = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// @todo Store restrictions
|
||||||
|
|
||||||
$item['location'] = $activity['location'];
|
$item['location'] = $activity['location'];
|
||||||
|
|
||||||
|
@ -1343,9 +1351,11 @@ class Processor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function storeCapabilities(int $uriid, array $capabilities)
|
private static function storeCapabilities(int $uriid, array $capabilities): array
|
||||||
{
|
{
|
||||||
|
$restrictions = [];
|
||||||
foreach (['pixelfed:canAnnounce' => Tag::CAN_ANNOUNCE, 'pixelfed:canLike' => Tag::CAN_LIKE, 'pixelfed:canReply' => Tag::CAN_REPLY] as $element => $type) {
|
foreach (['pixelfed:canAnnounce' => Tag::CAN_ANNOUNCE, 'pixelfed:canLike' => Tag::CAN_LIKE, 'pixelfed:canReply' => Tag::CAN_REPLY] as $element => $type) {
|
||||||
|
$restricted = true;
|
||||||
foreach ($capabilities[$element] ?? [] as $capability) {
|
foreach ($capabilities[$element] ?? [] as $capability) {
|
||||||
if ($capability == ActivityPub::PUBLIC_COLLECTION) {
|
if ($capability == ActivityPub::PUBLIC_COLLECTION) {
|
||||||
$name = Receiver::PUBLIC_COLLECTION;
|
$name = Receiver::PUBLIC_COLLECTION;
|
||||||
|
@ -1359,9 +1369,14 @@ class Processor
|
||||||
Logger::warning('Unable to coerce name from capability', ['element' => $element, 'type' => $type, 'capability' => $capability]);
|
Logger::warning('Unable to coerce name from capability', ['element' => $element, 'type' => $type, 'capability' => $capability]);
|
||||||
$name = '';
|
$name = '';
|
||||||
}
|
}
|
||||||
|
$restricted = false;
|
||||||
Tag::store($uriid, $type, $name, $capability);
|
Tag::store($uriid, $type, $name, $capability);
|
||||||
}
|
}
|
||||||
|
if ($restricted) {
|
||||||
|
$restrictions[] = $type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return $restrictions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2074,6 +2074,11 @@ class Receiver
|
||||||
$object_data['attachments'] = array_merge($object_data['attachments'], self::processAttachmentUrls($object['as:url'] ?? []));
|
$object_data['attachments'] = array_merge($object_data['attachments'], self::processAttachmentUrls($object['as:url'] ?? []));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$object_data['can-comment'] = JsonLD::fetchElement($object, 'pt:commentsEnabled', '@value');
|
||||||
|
if (is_null($object_data['can-comment'])) {
|
||||||
|
$object_data['can-comment'] = JsonLD::fetchElement($object, 'pixelfed:commentsEnabled', '@value');
|
||||||
|
}
|
||||||
|
|
||||||
// Support for quoted posts (Pleroma, Fedibird and Misskey)
|
// Support for quoted posts (Pleroma, Fedibird and Misskey)
|
||||||
$object_data['quote-url'] = JsonLD::fetchElement($object, 'as:quoteUrl', '@value');
|
$object_data['quote-url'] = JsonLD::fetchElement($object, 'as:quoteUrl', '@value');
|
||||||
if (empty($object_data['quote-url'])) {
|
if (empty($object_data['quote-url'])) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user