mirror of
https://github.com/friendica/friendica
synced 2025-04-25 09:10:11 +00:00
Improved handling of native quotes
This commit is contained in:
parent
f418687a71
commit
3c169b534e
11 changed files with 204 additions and 217 deletions
|
@ -827,10 +827,26 @@ class Processor
|
|||
|
||||
$content = self::addMentionLinks($content, $activity['tags']);
|
||||
|
||||
if (!empty($activity['quote-url'])) {
|
||||
$id = Item::fetchByLink($activity['quote-url']);
|
||||
if ($id) {
|
||||
$shared_item = Post::selectFirst(['uri-id'], ['id' => $id]);
|
||||
$item['quote-uri-id'] = $shared_item['uri-id'];
|
||||
} else {
|
||||
Logger::info('Quote was not fetched', ['guid' => $item['guid'], 'uri-id' => $item['uri-id'], 'quote' => $activity['quote-url']]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($activity['source'])) {
|
||||
$item['body'] = $activity['source'];
|
||||
$item['raw-body'] = $content;
|
||||
$item['body'] = DI::contentItem()->improveSharedDataInBody($item);
|
||||
|
||||
$quote_uri_id = Item::getQuoteUriId($item['body']);
|
||||
if (empty($item['quote-uri-id']) && !empty($quote_uri_id)) {
|
||||
$item['quote-uri-id'] = $quote_uri_id;
|
||||
}
|
||||
|
||||
$item['body'] = BBCode::removeSharedData($item['body']);
|
||||
} else {
|
||||
$parent_uri = $item['parent-uri'] ?? $item['thr-parent'];
|
||||
if (empty($activity['directmessage']) && ($parent_uri != $item['uri']) && ($item['gravity'] == Item::GRAVITY_COMMENT)) {
|
||||
|
@ -848,10 +864,6 @@ class Processor
|
|||
}
|
||||
$item['content-warning'] = HTML::toBBCode($activity['summary'] ?? '');
|
||||
$item['raw-body'] = $item['body'] = $content;
|
||||
|
||||
if (!empty($activity['quote-url'])) {
|
||||
$item['body'] .= DI::contentItem()->createSharedPostByUrl($activity['quote-url']);
|
||||
}
|
||||
}
|
||||
|
||||
self::storeFromBody($item);
|
||||
|
|
|
@ -1664,20 +1664,17 @@ class Transmitter
|
|||
$body = preg_replace("/\s*\[attachment .*?\].*?\[\/attachment\]\s*/ism", '', $body);
|
||||
}
|
||||
|
||||
$body = BBCode::setMentionsToNicknames($body);
|
||||
$exists_reshare = BBCode::existsShare($body);
|
||||
$body = BBCode::setMentionsToNicknames($body);
|
||||
|
||||
if (!empty($item['quote-uri']) && Post::exists(['uri-id' => $item['quote-uri-id'], 'network' => [Protocol::ACTIVITYPUB, Protocol::DFRN]])) {
|
||||
$real_quote = true;
|
||||
if ($exists_reshare) {
|
||||
$body = BBCode::replaceSharedData($body);
|
||||
} elseif (strpos($body, $item['quote-uri']) === false) {
|
||||
$body .= "\n♲ " . $item['quote-uri'];
|
||||
if (!empty($item['quote-uri-id'])) {
|
||||
$body = BBCode::removeSharedData($body);
|
||||
if (Post::exists(['uri-id' => $item['quote-uri-id'], 'network' => [Protocol::ACTIVITYPUB, Protocol::DFRN]])) {
|
||||
$real_quote = true;
|
||||
$data['quoteUrl'] = $item['quote-uri'];
|
||||
$body = DI::contentItem()->addShareLink($body, $item['quote-uri-id']);
|
||||
} else {
|
||||
$body = DI::contentItem()->addSharedPost($item, $body);
|
||||
}
|
||||
$data['quoteUrl'] = $item['quote-uri'];
|
||||
} elseif (!empty($item['quote-uri']) && !$exists_reshare) {
|
||||
$body .= "\n" . DI::contentItem()->createSharedPostByUriId($item['quote-uri-id'], $item['uid'], true);
|
||||
$item['body'] = DI::contentItem()->improveSharedDataInBody($item, true);
|
||||
}
|
||||
|
||||
$data['content'] = BBCode::convertForUriId($item['uri-id'], $body, BBCode::ACTIVITYPUB);
|
||||
|
@ -1689,15 +1686,14 @@ class Transmitter
|
|||
$language = self::getLanguage($item);
|
||||
if (!empty($language)) {
|
||||
$richbody = BBCode::setMentionsToNicknames($item['body'] ?? '');
|
||||
|
||||
if ($real_quote) {
|
||||
if (BBCode::existsShare($richbody)) {
|
||||
$richbody = BBCode::replaceSharedData($richbody);
|
||||
} elseif (strpos($richbody, $item['quote-uri']) === false) {
|
||||
$richbody .= "\n♲ " . $item['quote-uri'];
|
||||
if (!empty($item['quote-uri-id'])) {
|
||||
$richbody = BBCode::removeSharedData($richbody);
|
||||
if ($real_quote) {
|
||||
$richbody = DI::contentItem()->addShareLink($richbody, $item['quote-uri-id']);
|
||||
} else {
|
||||
$richbody = DI::contentItem()->addSharedPost($item, $richbody);
|
||||
}
|
||||
}
|
||||
|
||||
$richbody = BBCode::removeAttachment($richbody);
|
||||
|
||||
$data['contentMap'][$language] = BBCode::convertForUriId($item['uri-id'], $richbody, BBCode::EXTERNAL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue