mirror of https://github.com/pixelfed/pixelfed
Add /api/v1/followed_tags api endpoint
parent
fc1a385cfd
commit
175a848665
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\MastoApi;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Cache;
|
||||
use App\Services\HashtagService;
|
||||
|
||||
class FollowedTagResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$tag = HashtagService::get($this->hashtag_id);
|
||||
|
||||
if(!$tag || !isset($tag['name'])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
'name' => $tag['name'],
|
||||
'url' => config('app.url') . '/i/web/hashtag/' . $tag['slug'],
|
||||
'history' => [],
|
||||
'following' => true,
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue