mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-25 22:10:47 +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,
|
DiscoverCategory,
|
||||||
Follower,
|
Follower,
|
||||||
Hashtag,
|
Hashtag,
|
||||||
|
HashtagFollow,
|
||||||
Profile,
|
Profile,
|
||||||
Status,
|
Status,
|
||||||
StatusHashtag,
|
StatusHashtag,
|
||||||
|
@ -37,7 +38,8 @@ class DiscoverController extends Controller
|
||||||
|
|
||||||
public function showTags(Request $request, $hashtag)
|
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();
|
$tag = Hashtag::whereSlug($hashtag)->firstOrFail();
|
||||||
$tagCount = StatusHashtagService::count($tag->id);
|
$tagCount = StatusHashtagService::count($tag->id);
|
||||||
return view('discover.tags.show', compact('tag', 'tagCount'));
|
return view('discover.tags.show', compact('tag', 'tagCount'));
|
||||||
|
@ -127,10 +129,12 @@ class DiscoverController extends Controller
|
||||||
|
|
||||||
public function getHashtags(Request $request)
|
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, [
|
$this->validate($request, [
|
||||||
'hashtag' => 'required|alphanum|min:2|max:124',
|
'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';
|
$page = $request->input('page') ?? '1';
|
||||||
|
@ -138,7 +142,10 @@ class DiscoverController extends Controller
|
||||||
$tag = $request->input('hashtag');
|
$tag = $request->input('hashtag');
|
||||||
|
|
||||||
$hashtag = Hashtag::whereName($tag)->firstOrFail();
|
$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;
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue