mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 08:44:49 +00:00
commit
c4556b5963
9 changed files with 25350 additions and 25170 deletions
|
@ -33,14 +33,14 @@ class CollectionController extends Controller
|
||||||
return view('collection.create', compact('collection'));
|
return view('collection.create', compact('collection'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show(Request $request, int $collection)
|
public function show(Request $request, int $id)
|
||||||
{
|
{
|
||||||
$collection = Collection::with('profile')->whereNotNull('published_at')->findOrFail($collection);
|
$user = $request->user();
|
||||||
if($collection->profile->status != null) {
|
$collection = Collection::findOrFail($id);
|
||||||
abort(404);
|
if($collection->published_at == null || $collection->visibility != 'public') {
|
||||||
|
if(!$user || $user->profile_id != $collection->profile_id) {
|
||||||
|
abort_unless($user && $user->is_admin, 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'));
|
||||||
}
|
}
|
||||||
|
@ -144,20 +144,23 @@ class CollectionController extends Controller
|
||||||
|
|
||||||
public function get(Request $request, $id)
|
public function get(Request $request, $id)
|
||||||
{
|
{
|
||||||
$profile = Auth::check() ? Auth::user()->profile : [];
|
$user = $request->user();
|
||||||
|
$collection = Collection::findOrFail($id);
|
||||||
$collection = Collection::whereVisibility('public')->findOrFail($id);
|
if($collection->published_at == null || $collection->visibility != 'public') {
|
||||||
if($collection->published_at == null) {
|
if(!$user || $user->profile_id != $collection->profile_id) {
|
||||||
if(!Auth::check() || $profile->id !== $collection->profile_id) {
|
abort_unless($user && $user->is_admin, 404);
|
||||||
abort(404);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $collection->id,
|
'id' => (string) $collection->id,
|
||||||
|
'visibility' => $collection->visibility,
|
||||||
'title' => $collection->title,
|
'title' => $collection->title,
|
||||||
'description' => $collection->description,
|
'description' => $collection->description,
|
||||||
'visibility' => $collection->visibility
|
'thumb' => $collection->posts()->first()->thumb(),
|
||||||
|
'url' => $collection->url(),
|
||||||
|
'post_count' => $collection->posts()->count(),
|
||||||
|
'published_at' => $collection->published_at
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,26 +186,28 @@ class CollectionController extends Controller
|
||||||
|
|
||||||
public function getUserCollections(Request $request, int $id)
|
public function getUserCollections(Request $request, int $id)
|
||||||
{
|
{
|
||||||
|
$user = $request->user();
|
||||||
|
$pid = $user ? $user->profile_id : null;
|
||||||
|
|
||||||
$profile = Profile::whereNull('status')
|
$profile = Profile::whereNull('status')
|
||||||
->whereNull('domain')
|
->whereNull('domain')
|
||||||
->findOrFail($id);
|
->findOrFail($id);
|
||||||
|
|
||||||
if($profile->is_private) {
|
if($profile->is_private) {
|
||||||
abort_if(!Auth::check(), 404);
|
abort_if(!$pid, 404);
|
||||||
abort_if(!$profile->followedBy(Auth::user()->profile) && $profile->id != Auth::user()->profile_id, 404);
|
abort_if(!$profile->id != $pid, 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $profile
|
$visibility = $pid == $profile->id ? ['public', 'private'] : ['public'];
|
||||||
->collections()
|
|
||||||
->has('posts')
|
return Collection::whereProfileId($profile->id)
|
||||||
->with('posts')
|
->whereIn('visibility', $visibility)
|
||||||
->whereVisibility('public')
|
->orderByDesc('id')
|
||||||
->whereNotNull('published_at')
|
|
||||||
->orderByDesc('published_at')
|
|
||||||
->paginate(9)
|
->paginate(9)
|
||||||
->map(function($collection) {
|
->map(function($collection) {
|
||||||
return [
|
return [
|
||||||
'id' => (string) $collection->id,
|
'id' => (string) $collection->id,
|
||||||
|
'visibility' => $collection->visibility,
|
||||||
'title' => $collection->title,
|
'title' => $collection->title,
|
||||||
'description' => $collection->description,
|
'description' => $collection->description,
|
||||||
'thumb' => $collection->posts()->first()->thumb(),
|
'thumb' => $collection->posts()->first()->thumb(),
|
||||||
|
|
|
@ -207,7 +207,7 @@ class PublicApiController extends Controller
|
||||||
->paginate($limit);
|
->paginate($limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
$resource = new Fractal\Resource\Collection($replies, new StatusTransformer(), 'data');
|
$resource = new Fractal\Resource\Collection($replies, new StatusStatelessTransformer(), 'data');
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($replies));
|
$resource->setPaginator(new IlluminatePaginatorAdapter($replies));
|
||||||
$res = $this->fractal->createData($resource)->toArray();
|
$res = $this->fractal->createData($resource)->toArray();
|
||||||
return response()->json($res, 200, [], JSON_PRETTY_PRINT);
|
return response()->json($res, 200, [], JSON_PRETTY_PRINT);
|
||||||
|
|
|
@ -61,8 +61,8 @@ return [
|
||||||
],
|
],
|
||||||
|
|
||||||
'oauth' => [
|
'oauth' => [
|
||||||
'token_expiration' => env('OAUTH_TOKEN_DAYS', 15),
|
'token_expiration' => env('OAUTH_TOKEN_DAYS', 365),
|
||||||
'refresh_expiration' => env('OAUTH_REFRESH_DAYS', 30),
|
'refresh_expiration' => env('OAUTH_REFRESH_DAYS', 400),
|
||||||
'pat' => [
|
'pat' => [
|
||||||
'enabled' => env('OAUTH_PAT_ENABLED', false),
|
'enabled' => env('OAUTH_PAT_ENABLED', false),
|
||||||
'id' => env('OAUTH_PAT_ID'),
|
'id' => env('OAUTH_PAT_ID'),
|
||||||
|
@ -77,5 +77,5 @@ return [
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
||||||
'enable_cc' => env('ENABLE_CONFIG_CACHE', false)
|
'enable_cc' => env('ENABLE_CONFIG_CACHE', false),
|
||||||
];
|
];
|
||||||
|
|
2886
package-lock.json
generated
2886
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -20,7 +20,7 @@
|
||||||
"resolve-url-loader": "^2.3.2",
|
"resolve-url-loader": "^2.3.2",
|
||||||
"sass": "^1.32.11",
|
"sass": "^1.32.11",
|
||||||
"sass-loader": "^7.3.1",
|
"sass-loader": "^7.3.1",
|
||||||
"vue": "^2.6.11",
|
"vue": "^2.6.14",
|
||||||
"vue-masonry-css": "^1.0.3",
|
"vue-masonry-css": "^1.0.3",
|
||||||
"vue-router": "^3.5.1",
|
"vue-router": "^3.5.1",
|
||||||
"vue-template-compiler": "^2.6.11",
|
"vue-template-compiler": "^2.6.11",
|
||||||
|
@ -31,6 +31,7 @@
|
||||||
"@fancyapps/fancybox": "^3.5.7",
|
"@fancyapps/fancybox": "^3.5.7",
|
||||||
"@trevoreyre/autocomplete-vue": "^2.2.0",
|
"@trevoreyre/autocomplete-vue": "^2.2.0",
|
||||||
"animate.css": "^4.1.0",
|
"animate.css": "^4.1.0",
|
||||||
|
"bigpicture": "^2.6.1",
|
||||||
"blurhash": "^1.1.3",
|
"blurhash": "^1.1.3",
|
||||||
"bootstrap-vue": "^2.16.0",
|
"bootstrap-vue": "^2.16.0",
|
||||||
"chart.js": "^2.7.2",
|
"chart.js": "^2.7.2",
|
||||||
|
|
BIN
public/js/collections.js
vendored
BIN
public/js/collections.js
vendored
Binary file not shown.
BIN
public/js/compose.js
vendored
BIN
public/js/compose.js
vendored
Binary file not shown.
BIN
public/js/spa.js
vendored
BIN
public/js/spa.js
vendored
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue