Fix test / Use new expandTags function

This commit is contained in:
Michael 2022-03-02 17:17:07 +00:00
parent f853d58198
commit f059e56e0f
2 changed files with 8 additions and 10 deletions

View File

@ -21,8 +21,8 @@
namespace Friendica\Module\Api\Mastodon; namespace Friendica\Module\Api\Mastodon;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\Markdown; use Friendica\Content\Text\Markdown;
use Friendica\Core\Protocol;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
@ -63,12 +63,8 @@ class Statuses extends BaseApi
// The imput is defined as text. So we can use Markdown for some enhancements // The imput is defined as text. So we can use Markdown for some enhancements
$body = Markdown::toBBCode($request['status']); $body = Markdown::toBBCode($request['status']);
// Avoids potential double expansion of existing links $item = [];
$body = BBCode::performWithEscapedTags($body, ['url'], function ($body) { $item['network'] = Protocol::DFRN;
return BBCode::expandTags($body);
});
$item = [];
$item['uid'] = $uid; $item['uid'] = $uid;
$item['verb'] = Activity::POST; $item['verb'] = Activity::POST;
$item['contact-id'] = $owner['id']; $item['contact-id'] = $owner['id'];
@ -149,6 +145,8 @@ class Statuses extends BaseApi
$item['object-type'] = Activity\ObjectType::NOTE; $item['object-type'] = Activity\ObjectType::NOTE;
} }
$item = DI::contentItem()->expandTags($item);
if (!empty($request['media_ids'])) { if (!empty($request['media_ids'])) {
$item['object-type'] = Activity\ObjectType::IMAGE; $item['object-type'] = Activity\ObjectType::IMAGE;
$item['post-type'] = Item::PT_IMAGE; $item['post-type'] = Item::PT_IMAGE;

View File

@ -21,9 +21,9 @@
namespace Friendica\Module\Api\Twitter\Statuses; namespace Friendica\Module\Api\Twitter\Statuses;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML; use Friendica\Content\Text\HTML;
use Friendica\Content\Text\Markdown; use Friendica\Content\Text\Markdown;
use Friendica\Core\Protocol;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
@ -79,11 +79,11 @@ class Update extends BaseApi
} }
$item = []; $item = [];
$item['network'] = Protocol::DFRN;
$item['uid'] = $uid; $item['uid'] = $uid;
$item['verb'] = Activity::POST; $item['verb'] = Activity::POST;
$item['contact-id'] = $owner['id']; $item['contact-id'] = $owner['id'];
$item['author-id'] = Contact::getPublicIdByUserId($uid); $item['author-id'] = $item['owner-id'] = Contact::getPublicIdByUserId($uid);
$item['owner-id'] = $item['author-id'];
$item['title'] = $request['title']; $item['title'] = $request['title'];
$item['body'] = $body; $item['body'] = $body;
$item['app'] = $request['source']; $item['app'] = $request['source'];