Add title to the text/html content for Twitter status object
This commit is contained in:
parent
2f13afb4c0
commit
4c77e99f89
|
@ -119,7 +119,21 @@ class Status extends BaseFactory
|
|||
|
||||
$friendica_comments = Post::countPosts(['thr-parent-id' => $item['uri-id'], 'deleted' => false, 'gravity' => GRAVITY_COMMENT]);
|
||||
|
||||
$text = Post\Media::addAttachmentsToBody($item['uri-id'], $item['body']);
|
||||
$text = '';
|
||||
|
||||
// Add the title to text / html if set
|
||||
if (!empty($item['title'])) {
|
||||
$text .= $item['title'] . ' ';
|
||||
|
||||
$title = sprintf("[h4]%s[/h4]\n", $item['title']);
|
||||
$statusnetHtml = BBCode::convertForUriId($item['uri-id'], BBCode::setMentionsToNicknames($title . $item['raw-body'] ?? $item['body']), BBCode::API);
|
||||
$friendicaHtml = BBCode::convertForUriId($item['uri-id'], $title . $item['body'], BBCode::EXTERNAL);
|
||||
} else {
|
||||
$statusnetHtml = BBCode::convertForUriId($item['uri-id'], BBCode::setMentionsToNicknames($item['raw-body'] ?? $item['body']), BBCode::API);
|
||||
$friendicaHtml = BBCode::convertForUriId($item['uri-id'], $item['body'], BBCode::EXTERNAL);
|
||||
}
|
||||
|
||||
$text .= Post\Media::addAttachmentsToBody($item['uri-id'], $item['body']);
|
||||
|
||||
$text = trim(HTML::toPlaintext(BBCode::convertForUriId($item['uri-id'], $text, BBCode::API), 0));
|
||||
|
||||
|
@ -190,6 +204,6 @@ class Status extends BaseFactory
|
|||
$entities = [];
|
||||
}
|
||||
|
||||
return new \Friendica\Object\Api\Twitter\Status($text, $item, $author, $owner, $retweeted, $quoted, $geo, $friendica_activities, $entities, $attachments, $friendica_comments, $liked);
|
||||
return new \Friendica\Object\Api\Twitter\Status($text, $statusnetHtml, $friendicaHtml, $item, $author, $owner, $retweeted, $quoted, $geo, $friendica_activities, $entities, $attachments, $friendica_comments, $liked);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace Friendica\Object\Api\Twitter;
|
|||
|
||||
use Friendica\BaseDataTransferObject;
|
||||
use Friendica\Content\ContactSelector;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
||||
|
@ -99,7 +98,7 @@ class Status extends BaseDataTransferObject
|
|||
* @param array $item
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function __construct(string $text, array $item, User $author, User $owner, array $retweeted, array $quoted, array $geo, array $friendica_activities, array $entities, array $attachments, int $friendica_comments, bool $liked)
|
||||
public function __construct(string $text, string $statusnetHtml, string $friendicaHtml, array $item, User $author, User $owner, array $retweeted, array $quoted, array $geo, array $friendica_activities, array $entities, array $attachments, int $friendica_comments, bool $liked)
|
||||
{
|
||||
$this->id = (int)$item['id'];
|
||||
$this->id_str = (string)$item['id'];
|
||||
|
@ -117,8 +116,8 @@ class Status extends BaseDataTransferObject
|
|||
|
||||
$this->text = $text;
|
||||
$this->friendica_title = $item['title'];
|
||||
$this->statusnet_html = BBCode::convertForUriId($item['uri-id'], BBCode::setMentionsToNicknames($item['raw-body'] ?? $item['body']), BBCode::API);
|
||||
$this->friendica_html = BBCode::convertForUriId($item['uri-id'], $item['body'], BBCode::EXTERNAL);
|
||||
$this->statusnet_html = $statusnetHtml;
|
||||
$this->friendica_html = $friendicaHtml;
|
||||
$this->user = $author->toArray();
|
||||
$this->friendica_author = $author->toArray();
|
||||
$this->friendica_owner = $owner->toArray();
|
||||
|
|
|
@ -34,7 +34,7 @@ class StatusTest extends FixtureTest
|
|||
$status = $statusObj->toArray();
|
||||
|
||||
self::assertStringStartsWith('item_title', $status['text']);
|
||||
self::assertStringStartsWith('<h4>item_title</h4><br>perspiciatis impedit voluptatem', $status['html']);
|
||||
self::assertStringStartsWith('<h4>item_title</h4><br>perspiciatis impedit voluptatem', $status['friendica_html']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user