namespace Friendica\Protocol;
use Friendica\Content\Feature;
-use Friendica\Content\PageInfo;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\Markdown;
use Friendica\Core\Cache\Duration;
* 'key' => The public key of the author
* @throws \Exception
*/
- private static function message($guid, $server, $level = 0)
+ public static function message($guid, $server, $level = 0)
{
if ($level > 5) {
return false;
$item["body"] = self::replacePeopleGuid($item["body"], $item["author-link"]);
- // Add OEmbed and other information to the body
- $item["body"] = PageInfo::searchAndAppendToBody($item["body"], false, true);
-
return $item;
} else {
return $item;
Tag::storeFromBody($datarray['uri-id'], $datarray["body"]);
- Post\Media::copy($original_item['uri-id'], $datarray['uri-id']);
$datarray["app"] = $original_item["app"];
$datarray["plink"] = self::plink($author, $guid);
if ($data->photo) {
foreach ($data->photo as $photo) {
self::storePhotoAsMedia($datarray['uri-id'], $photo);
- $body = "[img]".XML::unescape($photo->remote_photo_path).
- XML::unescape($photo->remote_photo_name)."[/img]\n".$body;
}
$datarray["object-type"] = Activity\ObjectType::IMAGE;
} else {
$datarray["object-type"] = Activity\ObjectType::NOTE;
$datarray["post-type"] = Item::PT_NOTE;
-
- // Add OEmbed and other information to the body
- if (!self::isHubzilla($contact["url"])) {
- $body = PageInfo::searchAndAppendToBody($body, false, true);
- }
}
/// @todo enable support for polls
return $eventdata;
}
+ /**
+ * Add media attachments to the body
+ *
+ * @param array $item
+ * @return string body
+ */
+ private static function addAttachments(array $item)
+ {
+ $body = $item['body'];
+
+ foreach (Post\Media::getByURIId($item['uri-id'], [Post\Media::IMAGE, Post\Media::AUDIO, Post\Media::VIDEO]) as $media) {
+ if (Item::containsLink($item['body'], $media['url'])) {
+ continue;
+ }
+
+ if ($media['type'] == Post\Media::IMAGE) {
+ if (!empty($media['description'])) {
+ $body .= "\n[img=" . $media['url'] . ']' . $media['description'] .'[/img]';
+ } else {
+ $body .= "\n[img]" . $media['url'] .'[/img]';
+ }
+ } elseif ($media['type'] == Post\Media::AUDIO) {
+ $body .= "\n[audio]" . $media['url'] . "[/audio]\n";
+ } elseif ($media['type'] == Post\Media::VIDEO) {
+ $body .= "\n[video]" . $media['url'] . "[/video]\n";
+ }
+ }
+ return $body;
+ }
+
/**
* Create a post (status message or reshare)
*
$type = "reshare";
} else {
$title = $item["title"];
- $body = $item["body"];
+ $body = self::addAttachments($item);
// Fetch the title from an attached link - if there is one
if (empty($item["title"]) && DI::pConfig()->get($owner['uid'], 'system', 'attach_link_title')) {
$thread_parent_item = Post::selectFirst(['guid', 'author-id', 'author-link', 'gravity'], ['uri' => $item['thr-parent'], 'uid' => $item['uid']]);
}
- $body = $item["body"];
+ $body = self::addAttachments($item);
// The replied to autor mention is prepended for clarity if:
// - Item replied isn't yours