From e6e90abc7765ac5386b46fe9f3ca22d5f68fefe7 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 24 Jun 2021 22:15:25 +0000 Subject: [PATCH] AOI: Send "history" section for trends --- src/Module/Api/Mastodon/Trends.php | 3 ++- src/Object/Api/Mastodon/Tag.php | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Module/Api/Mastodon/Trends.php b/src/Module/Api/Mastodon/Trends.php index 7765a175a..505cdbabd 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 1424d9e20..4a6d2d3a2 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; } }