From: Michael Date: Thu, 24 Jun 2021 22:15:25 +0000 (+0000) Subject: AOI: Send "history" section for trends X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e6e90abc7765ac5386b46fe9f3ca22d5f68fefe7;p=friendica.git AOI: Send "history" section for trends --- diff --git a/src/Module/Api/Mastodon/Trends.php b/src/Module/Api/Mastodon/Trends.php index 7765a175a9..505cdbabd1 100644 --- a/src/Module/Api/Mastodon/Trends.php +++ b/src/Module/Api/Mastodon/Trends.php @@ -45,7 +45,8 @@ class Trends extends BaseApi $tags = Tag::getGlobalTrendingHashtags(24, 20); foreach ($tags as $tag) { $tag['name'] = $tag['term']; - $hashtag = new \Friendica\Object\Api\Mastodon\Tag(DI::baseUrl(), $tag); + $history = [['day' => (string)time(), 'uses' => (string)$tag['score'], 'accounts' => (string)$tag['authors']]]; + $hashtag = new \Friendica\Object\Api\Mastodon\Tag(DI::baseUrl(), $tag, $history); $trending[] = $hashtag->toArray(); } diff --git a/src/Object/Api/Mastodon/Tag.php b/src/Object/Api/Mastodon/Tag.php index 1424d9e20f..4a6d2d3a23 100644 --- a/src/Object/Api/Mastodon/Tag.php +++ b/src/Object/Api/Mastodon/Tag.php @@ -35,6 +35,8 @@ class Tag extends BaseDataTransferObject protected $name; /** @var string */ protected $url = null; + /** @var array */ + protected $history = []; /** * Creates a hashtag record from an tag-view record. @@ -43,9 +45,10 @@ class Tag extends BaseDataTransferObject * @param array $tag tag-view record * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function __construct(BaseURL $baseUrl, array $tag) + public function __construct(BaseURL $baseUrl, array $tag, array $history = []) { - $this->name = strtolower($tag['name']); - $this->url = $baseUrl . '/search?tag=' . urlencode($this->name); + $this->name = strtolower($tag['name']); + $this->url = $baseUrl . '/search?tag=' . urlencode($this->name); + $this->history = $history; } }