mirror of
https://github.com/friendica/friendica
synced 2024-12-23 08:40:16 +00:00
Merge pull request #14032 from annando/quoted-posts
Implementation of FEP-e232 for quoted posts
This commit is contained in:
commit
d824bb536f
3 changed files with 21 additions and 14 deletions
|
@ -800,14 +800,14 @@ class Item
|
||||||
*/
|
*/
|
||||||
public function addShareLink(string $body, int $quote_uri_id): string
|
public function addShareLink(string $body, int $quote_uri_id): string
|
||||||
{
|
{
|
||||||
$post = Post::selectFirstPost(['uri', 'plink'], ['uri-id' => $quote_uri_id]);
|
$post = Post::selectFirstPost(['uri'], ['uri-id' => $quote_uri_id]);
|
||||||
if (empty($post)) {
|
if (empty($post)) {
|
||||||
return $body;
|
return $body;
|
||||||
}
|
}
|
||||||
|
|
||||||
$body = BBCode::removeSharedData($body);
|
$body = BBCode::removeSharedData($body);
|
||||||
|
|
||||||
$body .= "\n♲ " . ($post['plink'] ?: $post['uri']);
|
$body .= "\nRE: " . $post['uri'];
|
||||||
|
|
||||||
return $body;
|
return $body;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1577,7 +1577,8 @@ class Receiver
|
||||||
$element = [
|
$element = [
|
||||||
'type' => str_replace('as:', '', JsonLD::fetchElement($tag, '@type') ?? ''),
|
'type' => str_replace('as:', '', JsonLD::fetchElement($tag, '@type') ?? ''),
|
||||||
'href' => JsonLD::fetchElement($tag, 'as:href', '@id'),
|
'href' => JsonLD::fetchElement($tag, 'as:href', '@id'),
|
||||||
'name' => JsonLD::fetchElement($tag, 'as:name', '@value')
|
'name' => JsonLD::fetchElement($tag, 'as:name', '@value'),
|
||||||
|
'mediaType' => JsonLD::fetchElement($tag, 'as:mediaType', '@value')
|
||||||
];
|
];
|
||||||
|
|
||||||
if (empty($element['type'])) {
|
if (empty($element['type'])) {
|
||||||
|
@ -2094,12 +2095,18 @@ class Receiver
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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', '@id');
|
||||||
if (empty($object_data['quote-url'])) {
|
if (empty($object_data['quote-url'])) {
|
||||||
$object_data['quote-url'] = JsonLD::fetchElement($object, 'fedibird:quoteUri', '@value');
|
$object_data['quote-url'] = JsonLD::fetchElement($object, 'fedibird:quoteUri', '@id');
|
||||||
}
|
}
|
||||||
if (empty($object_data['quote-url'])) {
|
if (empty($object_data['quote-url'])) {
|
||||||
$object_data['quote-url'] = JsonLD::fetchElement($object, 'misskey:_misskey_quote', '@value');
|
$object_data['quote-url'] = JsonLD::fetchElement($object, 'misskey:_misskey_quote', '@id');
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($object_data['tags'] as $tag) {
|
||||||
|
if (HTTPSignature::isValidContentType($tag['mediaType'] ?? '', $tag['href'])) {
|
||||||
|
$object_data['quote-url'] = $tag['href'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Misskey adds some data to the standard "content" value for quoted posts for backwards compatibility.
|
// Misskey adds some data to the standard "content" value for quoted posts for backwards compatibility.
|
||||||
|
|
|
@ -1589,15 +1589,14 @@ class Transmitter
|
||||||
$tags[] = ['type' => 'Mention', 'href' => $announce['actor']['url'], 'name' => '@' . $announce['actor']['addr']];
|
$tags[] = ['type' => 'Mention', 'href' => $announce['actor']['url'], 'name' => '@' . $announce['actor']['addr']];
|
||||||
}
|
}
|
||||||
|
|
||||||
// @see https://codeberg.org/fediverse/fep/src/branch/main/feps/fep-e232.md
|
// @see https://codeberg.org/fediverse/fep/src/branch/main/fep/e232/fep-e232.md
|
||||||
if (!empty($quote_url)) {
|
if (!empty($quote_url)) {
|
||||||
// Currently deactivated because of compatibility issues with Pleroma
|
$tags[] = [
|
||||||
//$tags[] = [
|
'type' => 'Link',
|
||||||
// 'type' => 'Link',
|
'mediaType' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
|
||||||
// 'mediaType' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
|
'href' => $quote_url,
|
||||||
// 'href' => $quote_url,
|
'name' => 'RE: ' . $quote_url,
|
||||||
// 'name' => '♲ ' . BBCode::convertForUriId($item['uri-id'], $quote_url, BBCode::ACTIVITYPUB)
|
];
|
||||||
//];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $tags;
|
return $tags;
|
||||||
|
@ -1862,6 +1861,7 @@ class Transmitter
|
||||||
if (!empty($item['quote-uri-id']) && ($item['quote-uri-id'] != $item['uri-id'])) {
|
if (!empty($item['quote-uri-id']) && ($item['quote-uri-id'] != $item['uri-id'])) {
|
||||||
if (Post::exists(['uri-id' => $item['quote-uri-id'], 'network' => [Protocol::ACTIVITYPUB, Protocol::DFRN]])) {
|
if (Post::exists(['uri-id' => $item['quote-uri-id'], 'network' => [Protocol::ACTIVITYPUB, Protocol::DFRN]])) {
|
||||||
$real_quote = true;
|
$real_quote = true;
|
||||||
|
$data['_misskey_content'] = BBCode::removeSharedData($body);
|
||||||
$data['quoteUrl'] = $item['quote-uri'];
|
$data['quoteUrl'] = $item['quote-uri'];
|
||||||
$body = DI::contentItem()->addShareLink($body, $item['quote-uri-id']);
|
$body = DI::contentItem()->addShareLink($body, $item['quote-uri-id']);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue