mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-11 14:40:46 +00:00
Update DiscoverController
This commit is contained in:
parent
e8b2eb6394
commit
5b713a1e0f
1 changed files with 11 additions and 4 deletions
|
@ -6,6 +6,7 @@ use App\{
|
|||
DiscoverCategory,
|
||||
Follower,
|
||||
Hashtag,
|
||||
HashtagFollow,
|
||||
Profile,
|
||||
Status,
|
||||
StatusHashtag,
|
||||
|
@ -37,7 +38,8 @@ class DiscoverController extends Controller
|
|||
|
||||
public function showTags(Request $request, $hashtag)
|
||||
{
|
||||
abort_if(!Auth::check(), 403);
|
||||
abort_if(!config('instance.discover.tags.is_public') && !Auth::check(), 403);
|
||||
|
||||
$tag = Hashtag::whereSlug($hashtag)->firstOrFail();
|
||||
$tagCount = StatusHashtagService::count($tag->id);
|
||||
return view('discover.tags.show', compact('tag', 'tagCount'));
|
||||
|
@ -127,10 +129,12 @@ class DiscoverController extends Controller
|
|||
|
||||
public function getHashtags(Request $request)
|
||||
{
|
||||
abort_if(!Auth::check(), 403);
|
||||
$auth = Auth::check();
|
||||
abort_if(!config('instance.discover.tags.is_public') && $auth, 403);
|
||||
|
||||
$this->validate($request, [
|
||||
'hashtag' => 'required|alphanum|min:2|max:124',
|
||||
'page' => 'nullable|integer|min:1|max:19'
|
||||
'page' => 'nullable|integer|min:1|max:' . ($auth ? 19 : 3)
|
||||
]);
|
||||
|
||||
$page = $request->input('page') ?? '1';
|
||||
|
@ -138,7 +142,10 @@ class DiscoverController extends Controller
|
|||
$tag = $request->input('hashtag');
|
||||
|
||||
$hashtag = Hashtag::whereName($tag)->firstOrFail();
|
||||
$res = StatusHashtagService::get($hashtag->id, $page, $end);
|
||||
$res['tags'] = StatusHashtagService::get($hashtag->id, $page, $end);
|
||||
if($page == 1) {
|
||||
$res['follows'] = HashtagFollow::whereUserId(Auth::id())->whereHashtagId($hashtag->id)->exists();
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue