]> git.mxchange.org Git - friendica.git/commitdiff
AOI: Send "history" section for trends
authorMichael <heluecht@pirati.ca>
Thu, 24 Jun 2021 22:15:25 +0000 (22:15 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 24 Jun 2021 22:15:25 +0000 (22:15 +0000)
src/Module/Api/Mastodon/Trends.php
src/Object/Api/Mastodon/Tag.php

index 7765a175a9473720665f6ac961607eb61fbf3f2b..505cdbabd1d59ad4e8797469090e9e78d29ab8b1 100644 (file)
@@ -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();
                }
 
index 1424d9e20fbc990a35500bf9776bee17a56ff84b..4a6d2d3a23a56fd1fd1f4c76f967c81b5cfcae59 100644 (file)
@@ -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;
        }
 }