From ab2d1315a07d57fb6fb747fe6558a535b4ce6ae7 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 30 Sep 2022 22:23:58 -0600 Subject: [PATCH 1/8] Update CollectionController --- app/Http/Controllers/CollectionController.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/Http/Controllers/CollectionController.php b/app/Http/Controllers/CollectionController.php index e168e4ff7..fca16f033 100644 --- a/app/Http/Controllers/CollectionController.php +++ b/app/Http/Controllers/CollectionController.php @@ -175,6 +175,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 +197,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']) { From c40b2f091f1f8be7c90c0b814ea59ca8fdd4c6b6 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 30 Sep 2022 23:48:11 -0600 Subject: [PATCH 2/8] Update CollectionService --- app/Services/CollectionService.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/Services/CollectionService.php b/app/Services/CollectionService.php index 215e8cf46..c2dfed7ab 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,12 +112,12 @@ 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(), + 'updated_at' => $collection->updated_at, 'published_at' => $collection->published_at ]; Cache::put(self::CACHE_KEY . 'get:' . $id, $res, 86400); @@ -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']; From 3bf792072aef1dd378216c526133890575f3c297 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 1 Oct 2022 00:07:28 -0600 Subject: [PATCH 3/8] Update CollectionService --- app/Http/Controllers/Api/ApiV1Controller.php | 3 +++ app/Http/Controllers/CollectionController.php | 8 ++++++++ app/Services/CollectionService.php | 8 ++++---- 3 files changed, 15 insertions(+), 4 deletions(-) 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 fca16f033..39b015ac8 100644 --- a/app/Http/Controllers/CollectionController.php +++ b/app/Http/Controllers/CollectionController.php @@ -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); } @@ -305,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 c2dfed7ab..8960cdd13 100644 --- a/app/Services/CollectionService.php +++ b/app/Services/CollectionService.php @@ -84,8 +84,8 @@ class CollectionService 'description' => $collection->description, 'thumb' => url('/storage/no-preview.png'), 'url' => $collection->url(), - 'updated_at' => $collection->updated_at, - 'published_at' => $collection->published_at, + 'updated_at' => str_replace('+00:00', 'Z', $collection->updated_at->format(DATE_RFC3339_EXTENDED)), + 'published_at' => str_replace('+00:00', 'Z', $collection->published_at->format(DATE_RFC3339_EXTENDED)), ]; }); @@ -117,8 +117,8 @@ class CollectionService 'description' => $collection->description, 'thumb' => self::getThumb($id), 'url' => $collection->url(), - 'updated_at' => $collection->updated_at, - 'published_at' => $collection->published_at + 'updated_at' => str_replace('+00:00', 'Z', $collection->updated_at->format(DATE_RFC3339_EXTENDED)), + 'published_at' => str_replace('+00:00', 'Z', $collection->published_at->format(DATE_RFC3339_EXTENDED)), ]; Cache::put(self::CACHE_KEY . 'get:' . $id, $res, 86400); $res['post_count'] = self::count($id); From eac3220ffd77b4abe422a4734da376ccad37619d Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 1 Oct 2022 00:14:26 -0600 Subject: [PATCH 4/8] Update CollectionService, revert timestamp change --- app/Services/CollectionService.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Services/CollectionService.php b/app/Services/CollectionService.php index 8960cdd13..288e1b7d1 100644 --- a/app/Services/CollectionService.php +++ b/app/Services/CollectionService.php @@ -84,8 +84,8 @@ class CollectionService 'description' => $collection->description, 'thumb' => url('/storage/no-preview.png'), 'url' => $collection->url(), - 'updated_at' => str_replace('+00:00', 'Z', $collection->updated_at->format(DATE_RFC3339_EXTENDED)), - 'published_at' => str_replace('+00:00', 'Z', $collection->published_at->format(DATE_RFC3339_EXTENDED)), + 'updated_at' => $collection->updated_at, + 'published_at' => $collection->published_at, ]; }); @@ -117,8 +117,8 @@ class CollectionService 'description' => $collection->description, 'thumb' => self::getThumb($id), 'url' => $collection->url(), - 'updated_at' => str_replace('+00:00', 'Z', $collection->updated_at->format(DATE_RFC3339_EXTENDED)), - 'published_at' => str_replace('+00:00', 'Z', $collection->published_at->format(DATE_RFC3339_EXTENDED)), + '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); From 6e76cf4b68760bf781ea34dfeba41dffd5aade2a Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 1 Oct 2022 03:45:53 -0600 Subject: [PATCH 5/8] Update CollectionController, limit max title and description length --- app/Http/Controllers/CollectionController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/CollectionController.php b/app/Http/Controllers/CollectionController.php index 39b015ac8..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; From 6e4272a8ff59009f1204e43d6e984da9f3fae76f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 1 Oct 2022 03:48:38 -0600 Subject: [PATCH 6/8] Update collection components, fix title/description padding/overflow bug and add title/description limit and input counter --- .../js/components/CollectionComponent.vue | 42 +++++++++++++++---- .../js/components/CollectionCompose.vue | 10 ++++- 2 files changed, 42 insertions(+), 10 deletions(-) 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 @@
- +
-
-

{{title || 'Untitled Collection'}}

-

{{description}}

+
+

{{title || 'Untitled Collection'}}

+
{{description}}

@@ -77,7 +77,7 @@ style="width:100%; height: 400px; object-fit: cover;" >

- +