AOI: Send "history" section for trends

This commit is contained in:
Michael 2021-06-24 22:15:25 +00:00
parent 9cd642abbc
commit e6e90abc77
2 changed files with 8 additions and 4 deletions

View file

@ -45,7 +45,8 @@ class Trends extends BaseApi
$tags = Tag::getGlobalTrendingHashtags(24, 20); $tags = Tag::getGlobalTrendingHashtags(24, 20);
foreach ($tags as $tag) { foreach ($tags as $tag) {
$tag['name'] = $tag['term']; $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(); $trending[] = $hashtag->toArray();
} }

View file

@ -35,6 +35,8 @@ class Tag extends BaseDataTransferObject
protected $name; protected $name;
/** @var string */ /** @var string */
protected $url = null; protected $url = null;
/** @var array */
protected $history = [];
/** /**
* Creates a hashtag record from an tag-view record. * Creates a hashtag record from an tag-view record.
@ -43,9 +45,10 @@ class Tag extends BaseDataTransferObject
* @param array $tag tag-view record * @param array $tag tag-view record
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @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->name = strtolower($tag['name']);
$this->url = $baseUrl . '/search?tag=' . urlencode($this->name); $this->url = $baseUrl . '/search?tag=' . urlencode($this->name);
$this->history = $history;
} }
} }