}
$item['content-warning'] = HTML::toBBCode($activity['summary'] ?? '');
$item['raw-body'] = $item['body'] = $content;
+
+ if (!empty($activity['quote-url'])) {
+ $item['body'] .= self::addSharedData($activity['quote-url']);
+ }
}
self::storeFromBody($item);
return $item;
}
+ /**
+ * Add a share block for the given quote link
+ *
+ * @param string $url
+ * @return string
+ */
+ private static function addSharedData(string $url): string
+ {
+ $id = Item::fetchByLink($url);
+ if (empty($id)) {
+ return '';
+ }
+
+ $shared_item = Post::selectFirst(['author-name', 'author-link', 'author-avatar', 'plink', 'created', 'guid', 'title', 'body'], ['id' => $id]);
+ if (!DBA::isResult($shared_item)) {
+ return '';
+ }
+
+ $prefix = BBCode::getShareOpeningTag(
+ $shared_item['author-name'],
+ $shared_item['author-link'],
+ $shared_item['author-avatar'],
+ $shared_item['plink'],
+ $shared_item['created'],
+ $shared_item['guid']
+ );
+
+ if (!empty($shared_item['title'])) {
+ $prefix .= '[h3]' . $shared_item['title'] . "[/h3]\n";
+ }
+
+ return $prefix . $shared_item['body'] . '[/share]';
+ }
+
/**
* Store hashtags and mentions
*
$object_data['attachments'] = array_merge($object_data['attachments'], self::processAttachmentUrls($object['as:url'] ?? []));
}
+ // Support for quoted posts (Pleroma, Fedibird and Misskey)
+ $object_data['quote-url'] = JsonLD::fetchElement($object, 'as:quoteUrl', '@value');
+ if (empty($object_data['quote-url'])) {
+ $object_data['quote-url'] = JsonLD::fetchElement($object, 'fedibird:quoteUri', '@value');
+ }
+ if (empty($object_data['quote-url'])) {
+ $object_data['quote-url'] = JsonLD::fetchElement($object, 'misskey:_misskey_quote', '@value');
+ }
+
+ // Misskey adds some data to the standard "content" value for quoted posts for backwards compatibility.
+ // Their own "_misskey_content" value does then contain the content without this extra data.
+ if (!empty($object_data['quote-url'])) {
+ $misskey_content = JsonLD::fetchElement($object, 'misskey:_misskey_content', '@value');
+ if (!empty($misskey_content)) {
+ $object_data['content'] = $misskey_content;
+ }
+ }
+
// For page types we expect that the alternate url posts to some page.
// So we add this to the attachments if it differs from the id.
// Currently only Lemmy is using the page type.
'sc' => (object)['@id' => 'http://schema.org#', '@type' => '@id'],
'pt' => (object)['@id' => 'https://joinpeertube.org/ns#', '@type' => '@id'],
'mobilizon' => (object)['@id' => 'https://joinmobilizon.org/ns#', '@type' => '@id'],
+ 'fedibird' => (object)['@id' => 'http://fedibird.com/ns#', '@type' => '@id'],
+ 'misskey' => (object)['@id' => 'https://misskey-hub.net/ns#', '@type' => '@id'],
];
$orig_json = $json;
"ostatus": "http://ostatus.org#",
"schema": "http://schema.org#",
"toot": "http://joinmastodon.org/ns#",
+ "fedibird": "http://fedibird.com/ns#",
"value": "schema:value",
"sensitive": "as:sensitive",
"litepub": "http://litepub.social/ns#",
"@id": "litepub:listMessage",
"@type": "@id"
},
+ "quoteUrl": "as:quoteUrl",
+ "quoteUri": "fedibird:quoteUri",
"oauthRegistrationEndpoint": {
"@id": "litepub:oauthRegistrationEndpoint",
"@type": "@id"
"alsoKnownAs": {
"@id": "as:alsoKnownAs",
"@type": "@id"
- }
+ },
+ "vcard": "http://www.w3.org/2006/vcard/ns#"
}
]
}