<?php
/**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
use DOMDocument;
use DOMXPath;
-use Friendica\Content\PageInfo;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Cache\Duration;
$item["body"] .= $add_body;
- // Only add additional data when there is no picture in the post
- if (!strstr($item["body"], '[/img]')) {
- $item["body"] = PageInfo::searchAndAppendToBody($item["body"]);
- }
-
Tag::storeFromBody($item['uri-id'], $item['body']);
// Mastodon Content Warning
$curlResult = DI::httpRequest()->get($conversation, ['accept_content' => 'application/atom+xml, text/html']);
- if (!$curlResult->isSuccess()) {
+ if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
return;
}
$stored = false;
$curlResult = DI::httpRequest()->get($related, ['accept_content' => 'application/atom+xml, text/html']);
- if (!$curlResult->isSuccess()) {
+ if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
return;
}
if (($item["object-type"] == Activity\ObjectType::QUESTION)
|| ($item["object-type"] == Activity\ObjectType::EVENT)
) {
- $item["body"] .= "\n" . PageInfo::getFooterFromUrl($attribute['href']);
+ Post\Media::insert(['uri-id' => $item['uri-id'], 'type' => Post\Media::UNKNOWN,
+ 'url' => $attribute['href'], 'mimetype' => $attribute['type'] ?? null,
+ 'size' => $attribute['length'] ?? null, 'description' => $attribute['title'] ?? null]);
}
break;
case "ostatus:conversation":
}
$link_data['related'] = $attribute['href'];
} else {
- $item["body"] .= "\n" . PageInfo::getFooterFromUrl($attribute['href']);
+ Post\Media::insert(['uri-id' => $item['uri-id'], 'type' => Post\Media::UNKNOWN,
+ 'url' => $attribute['href'], 'mimetype' => $attribute['type'] ?? null,
+ 'size' => $attribute['length'] ?? null, 'description' => $attribute['title'] ?? null]);
}
break;
case "self":
XML::addElement($doc, $entry, "id", $item["uri"]);
XML::addElement($doc, $entry, "title", html_entity_decode($title, ENT_QUOTES, 'UTF-8'));
- $body = self::formatPicturePost($item['body']);
+ $body = Post\Media::addAttachmentsToBody($item['uri-id'], $item['body']);
+ $body = self::formatPicturePost($body);
if (!empty($item['title'])) {
$body = "[b]".$item['title']."[/b]\n\n".$body;