mirror of https://github.com/pixelfed/pixelfed.git
Update CollectionController
This commit is contained in:
parent
14bd847d4e
commit
0d120f5c38
|
@ -38,6 +38,9 @@ class CollectionController extends Controller
|
||||||
if($collection->profile->status != null) {
|
if($collection->profile->status != null) {
|
||||||
abort(404);
|
abort(404);
|
||||||
}
|
}
|
||||||
|
if($collection->visibility !== 'public') {
|
||||||
|
abort_if(!Auth::check() || Auth::user()->profile_id != $collection->profile_id, 404);
|
||||||
|
}
|
||||||
return view('collection.show', compact('collection'));
|
return view('collection.show', compact('collection'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,8 +54,8 @@ class CollectionController extends Controller
|
||||||
{
|
{
|
||||||
abort_if(!Auth::check(), 403);
|
abort_if(!Auth::check(), 403);
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'title' => 'required',
|
'title' => 'nullable',
|
||||||
'description' => 'required',
|
'description' => 'nullable',
|
||||||
'visibility' => 'required|alpha|in:public,private'
|
'visibility' => 'required|alpha|in:public,private'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -66,11 +69,19 @@ class CollectionController extends Controller
|
||||||
return 200;
|
return 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function publish(int $id)
|
public function publish(Request $request, int $id)
|
||||||
{
|
{
|
||||||
abort_if(!Auth::check(), 403);
|
abort_if(!Auth::check(), 403);
|
||||||
|
$this->validate($request, [
|
||||||
|
'title' => 'nullable',
|
||||||
|
'description' => 'nullable',
|
||||||
|
'visibility' => 'required|alpha|in:public,private'
|
||||||
|
]);
|
||||||
$profile = Auth::user()->profile;
|
$profile = Auth::user()->profile;
|
||||||
$collection = Collection::whereProfileId($profile->id)->findOrFail($id);
|
$collection = Collection::whereProfileId($profile->id)->findOrFail($id);
|
||||||
|
$collection->title = e($request->input('title'));
|
||||||
|
$collection->description = e($request->input('description'));
|
||||||
|
$collection->visibility = e($request->input('visibility'));
|
||||||
$collection->published_at = now();
|
$collection->published_at = now();
|
||||||
$collection->save();
|
$collection->save();
|
||||||
|
|
||||||
|
@ -126,7 +137,7 @@ class CollectionController extends Controller
|
||||||
{
|
{
|
||||||
$profile = Auth::check() ? Auth::user()->profile : [];
|
$profile = Auth::check() ? Auth::user()->profile : [];
|
||||||
|
|
||||||
$collection = Collection::findOrFail($id);
|
$collection = Collection::whereVisibility('public')->findOrFail($id);
|
||||||
if($collection->published_at == null) {
|
if($collection->published_at == null) {
|
||||||
if(!Auth::check() || $profile->id !== $collection->profile_id) {
|
if(!Auth::check() || $profile->id !== $collection->profile_id) {
|
||||||
abort(404);
|
abort(404);
|
||||||
|
@ -143,9 +154,10 @@ class CollectionController extends Controller
|
||||||
|
|
||||||
public function getItems(Request $request, int $id)
|
public function getItems(Request $request, int $id)
|
||||||
{
|
{
|
||||||
$profile = Auth::user()->profile;
|
|
||||||
|
|
||||||
$collection = Collection::findOrFail($id);
|
$collection = Collection::findOrFail($id);
|
||||||
|
if($collection->visibility !== 'public') {
|
||||||
|
abort_if(!Auth::check() || Auth::user()->profile_id != $collection->profile_id, 404);
|
||||||
|
}
|
||||||
$posts = $collection->posts()->orderBy('order', 'asc')->paginate(18);
|
$posts = $collection->posts()->orderBy('order', 'asc')->paginate(18);
|
||||||
|
|
||||||
$fractal = new Fractal\Manager();
|
$fractal = new Fractal\Manager();
|
||||||
|
|
Loading…
Reference in New Issue