diff --git a/CHANGELOG.md b/CHANGELOG.md index 5815f9632..4864e2eca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -89,6 +89,8 @@ - Update ApiV1Controller, add collection_ids parameter to /api/v1/statuses endpoint ([7ae21fc3](https://github.com/pixelfed/pixelfed/commit/7ae21fc3)) - Update ApiV1Controller, add comments_disabled param to /api/v1/statuses endpoint ([95b58610](https://github.com/pixelfed/pixelfed/commit/95b58610)) - Update ap helpers to handle disabled comments ([92f56c9b](https://github.com/pixelfed/pixelfed/commit/92f56c9b)) +- Update CollectionController, limit max title and description length ([6e76cf4b](https://github.com/pixelfed/pixelfed/commit/6e76cf4b)) +- Update collection components, fix title/description padding/overflow bug and add title/description limit and input counter ([6e4272a8](https://github.com/pixelfed/pixelfed/commit/6e4272a8)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.3 (2022-05-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.2...v0.11.3) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index 9411cc0a9..8eb1f43e4 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -2648,6 +2648,9 @@ class ApiV1Controller extends Controller $status->id, $count ); + $collection->updated_at = now(); + $collection->save(); + CollectionService::setCollection($collection->id, $collection); }); } diff --git a/app/Http/Controllers/CollectionController.php b/app/Http/Controllers/CollectionController.php index e168e4ff7..79284e20f 100644 --- a/app/Http/Controllers/CollectionController.php +++ b/app/Http/Controllers/CollectionController.php @@ -65,8 +65,8 @@ class CollectionController extends Controller { abort_if(!Auth::check(), 403); $this->validate($request, [ - 'title' => 'nullable', - 'description' => 'nullable', + 'title' => 'nullable|max:50', + 'description' => 'nullable|max:500', 'visibility' => 'nullable|string|in:public,private,draft' ]); @@ -84,8 +84,8 @@ class CollectionController extends Controller { abort_if(!Auth::check(), 403); $this->validate($request, [ - 'title' => 'nullable', - 'description' => 'nullable', + 'title' => 'nullable|max:50', + 'description' => 'nullable|max:500', 'visibility' => 'required|alpha|in:public,private,draft' ]); $profile = Auth::user()->profile; @@ -168,6 +168,10 @@ class CollectionController extends Controller $count ); + $collection->updated_at = now(); + $collection->save(); + CollectionService::setCollection($collection->id, $collection); + return StatusService::get($status->id); } @@ -175,6 +179,11 @@ class CollectionController extends Controller { $user = $request->user(); $collection = CollectionService::getCollection($id); + + if(!$collection) { + return response()->json([], 404); + } + if($collection['published_at'] == null || $collection['visibility'] != 'public') { abort_unless($user, 404); if($user->profile_id != $collection['pid']) { @@ -192,6 +201,11 @@ class CollectionController extends Controller { $user = $request->user(); $collection = CollectionService::getCollection($id); + + if(!$collection) { + return response()->json([], 404); + } + if($collection['published_at'] == null || $collection['visibility'] != 'public') { abort_unless($user, 404); if($user->profile_id != $collection['pid']) { @@ -295,6 +309,10 @@ class CollectionController extends Controller $item->delete(); + $collection->updated_at = now(); + $collection->save(); + CollectionService::setCollection($collection->id, $collection); + return 200; } } diff --git a/app/Services/CollectionService.php b/app/Services/CollectionService.php index 215e8cf46..288e1b7d1 100644 --- a/app/Services/CollectionService.php +++ b/app/Services/CollectionService.php @@ -79,17 +79,23 @@ class CollectionService return [ 'id' => (string) $collection->id, 'pid' => (string) $collection->profile_id, - 'username' => $account['username'], 'visibility' => $collection->visibility, 'title' => $collection->title, 'description' => $collection->description, - 'thumb' => '/storage/no-preview.png', + 'thumb' => url('/storage/no-preview.png'), 'url' => $collection->url(), - 'published_at' => $collection->published_at + 'updated_at' => $collection->updated_at, + 'published_at' => $collection->published_at, ]; }); if($collection) { + $account = AccountService::get($collection['pid']); + if(!$account) { + return false; + } + $collection['avatar'] = $account['avatar']; + $collection['username'] = $account['username']; $collection['thumb'] = self::getThumb($id); $collection['post_count'] = self::count($id); } @@ -106,13 +112,13 @@ class CollectionService $res = [ 'id' => (string) $collection->id, 'pid' => (string) $collection->profile_id, - 'username' => $account['username'], 'visibility' => $collection->visibility, 'title' => $collection->title, 'description' => $collection->description, 'thumb' => self::getThumb($id), 'url' => $collection->url(), - 'published_at' => $collection->published_at + 'updated_at' => $collection->updated_at, + 'published_at' => $collection->published_at, ]; Cache::put(self::CACHE_KEY . 'get:' . $id, $res, 86400); $res['post_count'] = self::count($id); @@ -129,15 +135,15 @@ class CollectionService { $item = self::getItems($id, 0, 1); if(!$item || empty($item)) { - return '/storage/no-preview.png'; + return url('/storage/no-preview.png'); } $status = StatusService::get($item[0]); if(!$status) { - return '/storage/no-preview.png'; + return url('/storage/no-preview.png'); } if(!isset($status['media_attachments']) || empty($status['media_attachments'])) { - return '/storage/no-preview.png'; + return url('/storage/no-preview.png'); } return $status['media_attachments'][0]['url']; diff --git a/public/js/collectioncompose.js b/public/js/collectioncompose.js index 69d6aba85..5fcb3adea 100644 Binary files a/public/js/collectioncompose.js and b/public/js/collectioncompose.js differ diff --git a/public/js/collections.js b/public/js/collections.js index 905dd45d3..5ccf259cd 100644 Binary files a/public/js/collections.js and b/public/js/collections.js differ diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 72e63e7b4..35782727f 100644 Binary files a/public/mix-manifest.json and b/public/mix-manifest.json differ diff --git a/resources/assets/js/components/CollectionComponent.vue b/resources/assets/js/components/CollectionComponent.vue index 3480fa9ee..dd7ebf433 100644 --- a/resources/assets/js/components/CollectionComponent.vue +++ b/resources/assets/js/components/CollectionComponent.vue @@ -25,11 +25,11 @@