mirror of
https://github.com/friendica/friendica
synced 2025-04-27 12:30:11 +00:00
No link guessing for DFRN / Don't show redundant data
This commit is contained in:
parent
02ec019ddc
commit
b3e511eb0c
3 changed files with 74 additions and 20 deletions
|
@ -172,7 +172,7 @@ class Item
|
|||
|
||||
Logger::info('Updating per single row method', ['fields' => $fields, 'condition' => $condition]);
|
||||
|
||||
$items = Post::select(['id', 'origin', 'uri-id', 'uid'], $condition);
|
||||
$items = Post::select(['id', 'origin', 'uri-id', 'uid', 'author-network'], $condition);
|
||||
|
||||
$notify_items = [];
|
||||
|
||||
|
@ -180,6 +180,10 @@ class Item
|
|||
if (!empty($fields['body'])) {
|
||||
Post\Media::insertFromAttachmentData($item['uri-id'], $fields['body']);
|
||||
|
||||
if ($item['author-network'] != Protocol::DFRN) {
|
||||
Post\Media::insertFromRelevantUrl($item['uri-id'], $fields['body']);
|
||||
}
|
||||
|
||||
$content_fields = ['raw-body' => trim($fields['raw-body'] ?? $fields['body'])];
|
||||
|
||||
// Remove all media attachments from the body and store them in the post-media table
|
||||
|
@ -967,12 +971,16 @@ class Item
|
|||
unset($item['attachments']);
|
||||
}
|
||||
|
||||
Post\Media::insertFromAttachmentData($item['uri-id'], $item['body']);
|
||||
|
||||
if (!DBA::exists('contact', ['id' => $item['author-id'], 'network' => Protocol::DFRN])) {
|
||||
Post\Media::insertFromRelevantUrl($item['uri-id'], $item['body']);
|
||||
}
|
||||
|
||||
// Remove all media attachments from the body and store them in the post-media table
|
||||
$item['raw-body'] = Post\Media::insertFromBody($item['uri-id'], $item['raw-body']);
|
||||
$item['raw-body'] = self::setHashtags($item['raw-body']);
|
||||
|
||||
Post\Media::insertFromAttachmentData($item['uri-id'], $item['body']);
|
||||
|
||||
// Check for hashtags in the body and repair or add hashtag links
|
||||
$item['body'] = self::setHashtags($item['body']);
|
||||
|
||||
|
@ -2891,28 +2899,48 @@ class Item
|
|||
$data['preview'] = $attachment['preview'] ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($data['description']) && !empty($content)) {
|
||||
similar_text($data['description'], $content, $percent);
|
||||
} else {
|
||||
$percent = 0;
|
||||
}
|
||||
|
||||
if (!empty($data['description']) && (($data['title'] == $data['description']) || ($percent > 95) || (strpos($content, $data['description']) !== false))) {
|
||||
$data['description'] = '';
|
||||
}
|
||||
} elseif (preg_match("/.*(\[attachment.*?\].*?\[\/attachment\]).*/ism", $body, $match)) {
|
||||
$data = BBCode::getAttachmentData($match[1]);
|
||||
}
|
||||
DI::profiler()->saveTimestamp($stamp1, 'rendering');
|
||||
|
||||
if (isset($data['url']) && !in_array($data['url'], $ignore_links)) {
|
||||
$parts = parse_url($data['url']);
|
||||
if (!empty($parts['scheme']) && !empty($parts['host'])) {
|
||||
if (empty($data['provider_name'])) {
|
||||
$data['provider_name'] = $parts['host'];
|
||||
}
|
||||
if (empty($data['provider_url']) || empty(parse_url($data['provider_url'], PHP_URL_SCHEME))) {
|
||||
$data['provider_url'] = $parts['scheme'] . '://' . $parts['host'];
|
||||
if (!empty($data['description']) || !empty($data['image'] || !empty($data['preview']))) {
|
||||
$parts = parse_url($data['url']);
|
||||
if (!empty($parts['scheme']) && !empty($parts['host'])) {
|
||||
if (empty($data['provider_name'])) {
|
||||
$data['provider_name'] = $parts['host'];
|
||||
}
|
||||
if (empty($data['provider_url']) || empty(parse_url($data['provider_url'], PHP_URL_SCHEME))) {
|
||||
$data['provider_url'] = $parts['scheme'] . '://' . $parts['host'];
|
||||
|
||||
if (!empty($parts['port'])) {
|
||||
$data['provider_url'] .= ':' . $parts['port'];
|
||||
if (!empty($parts['port'])) {
|
||||
$data['provider_url'] .= ':' . $parts['port'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @todo Use a template
|
||||
$rendered = BBCode::convertAttachment('', BBCode::INTERNAL, false, $data);
|
||||
} elseif (!self::containsLink($content, $data['url'])) {
|
||||
$rendered = Renderer::replaceMacros(Renderer::getMarkupTemplate('content/link.tpl'), [
|
||||
'$url' => $data['url'],
|
||||
'$title' => $data['title'],
|
||||
]);
|
||||
} else {
|
||||
return $content;
|
||||
}
|
||||
|
||||
// @todo Use a template
|
||||
$rendered = BBCode::convertAttachment('', BBCode::INTERNAL, false, $data);
|
||||
if ($shared) {
|
||||
return str_replace(BBCode::BOTTOM_ANCHOR, BBCode::BOTTOM_ANCHOR . $rendered, $content);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue