refine shre to quote conversion

This commit is contained in:
Mario
2025-11-23 10:50:21 +00:00
parent 9e5344d624
commit ec57f8293a
2 changed files with 19 additions and 13 deletions

View File

@@ -644,14 +644,14 @@ class Activity {
// TODO: Do not replace the if the owner is a forum.
// Receivers will not be able to fetch the original in that case.
if (str_contains($i['body'], '[/share]') && !$i['owner']['xchan_pubforum']) {
preg_match_all('/\[share(.*?)\[\/share\]/ism', $i['body'], $all_shares, PREG_SET_ORDER);
if (str_contains($i['body'], '[/share]')) {
preg_match_all('/\[share(.*?)\](.*?)\[\/share\]/ism', $i['body'], $all_shares, PREG_SET_ORDER);
$quote_urls = [];
foreach ($all_shares as $share) {
// Extract the link attribute from each [share] block
if (preg_match("/link='(.*?)'/ism", $share[1], $match)) {
// Extract the link attribute from each [share] block if slated for quote
if (str_contains($share[1], "quote='true'") && preg_match("/link='(.*?)'/ism", $share[1], $match)) {
$url = $match[1];
$quote_urls[] = $url;

View File

@@ -119,16 +119,22 @@ class Share {
}
if (!str_contains($this->item['body'], '[/share]')) {
$bb .= "[share author='".urlencode($this->item['author']['xchan_name']).
"' profile='" . $this->item['author']['xchan_url'] .
"' avatar='" . $this->item['author']['xchan_photo_s'] .
"' link='" . $this->item['plink'] .
"' auth='" . (($this->item['author']['xchan_network'] === 'zot6') ? 'true' : 'false') .
"' posted='" . $this->item['created'] .
"' message_id='" . $this->item['mid'] .
"']";
if($this->item['title'])
$quote = in_array($this->item['author']['xchan_network'], ['zot6', 'activitypub']) ? "quote='true'" : '';
$bb .= "[share author='" . urlencode($this->item['author']['xchan_name']) . "'
profile='" . $this->item['author']['xchan_url'] . "'
avatar='" . $this->item['author']['xchan_photo_s'] . "'
link='" . $this->item['plink'] . "'
auth='" . (($this->item['author']['xchan_network'] === 'zot6') ? 'true' : 'false') . "'
posted='" . $this->item['created'] . "'
message_id='" . $this->item['mid'] . "'
$quote
]";
if ($this->item['title']) {
$bb .= '[h3][b]'.$this->item['title'].'[/b][/h3]'."\r\n";
}
$bb .= (($is_photo) ? $photo_bb . "\r\n" . $this->item['body'] : $this->item['body']);
$bb .= "[/share]";
}