From 32c0019209cbd3f6f9b673cb6510d12d220eb163 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 12 May 2019 22:19:18 -0600 Subject: [PATCH 1/5] Update LabsSettings controller --- app/Http/Controllers/Settings/LabsSettings.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Settings/LabsSettings.php b/app/Http/Controllers/Settings/LabsSettings.php index 1d783e2f7..20e2106df 100644 --- a/app/Http/Controllers/Settings/LabsSettings.php +++ b/app/Http/Controllers/Settings/LabsSettings.php @@ -53,7 +53,9 @@ trait LabsSettings { if($profile->is_suggestable == false) { $profile->is_suggestable = true; $changes = true; - SuggestionService::set($profile->id); + if($profile->statuses->count() > 0) { + SuggestionService::set($profile->id); + } } } else { $profile->is_suggestable = false; From b7a7368c62898eb3069f3e0a5d550e48b694f583 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 12 May 2019 22:19:44 -0600 Subject: [PATCH 2/5] Update SuggestionService --- app/Services/SuggestionService.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Services/SuggestionService.php b/app/Services/SuggestionService.php index 9160b0472..d34ac17a4 100644 --- a/app/Services/SuggestionService.php +++ b/app/Services/SuggestionService.php @@ -45,6 +45,7 @@ class SuggestionService { $ids = Profile::whereNull('domain') ->whereIsSuggestable(true) ->whereIsPrivate(false) + ->whereHas('statuses') ->pluck('id'); foreach($ids as $id) { self::set($id); From f033f84159e4afa70685ecbb49c43ea6a5bedc1f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 12 May 2019 22:32:33 -0600 Subject: [PATCH 3/5] Update StatusController --- app/Http/Controllers/StatusController.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index 35d335e58..b22464404 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -229,14 +229,12 @@ class StatusController extends Controller $this->authCheck(); $this->validate($request, [ - 'item' => 'required|integer', + 'item' => 'required|integer|min:1', ]); $profile = Auth::user()->profile; $status = Status::withCount('shares')->findOrFail($request->input('item')); - Cache::forget('transform:status:'.$status->url()); - $count = $status->shares_count; $exists = Status::whereProfileId(Auth::user()->profile->id) From 7974ad39c950263b05a26a8191457aec1644c55a Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 12 May 2019 22:32:56 -0600 Subject: [PATCH 4/5] Update LikeController --- app/Http/Controllers/LikeController.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/Http/Controllers/LikeController.php b/app/Http/Controllers/LikeController.php index 9ee452d32..2b87353d0 100644 --- a/app/Http/Controllers/LikeController.php +++ b/app/Http/Controllers/LikeController.php @@ -20,14 +20,12 @@ class LikeController extends Controller public function store(Request $request) { $this->validate($request, [ - 'item' => 'required|integer', + 'item' => 'required|integer|min:1', ]); $profile = Auth::user()->profile; $status = Status::withCount('likes')->findOrFail($request->input('item')); - Cache::forget('transform:status:'.$status->url()); - $count = $status->likes_count; if ($status->likes()->whereProfileId($profile->id)->count() !== 0) { @@ -48,8 +46,6 @@ class LikeController extends Controller ->take(1000) ->pluck('status_id'); - Cache::put('api:like-ids:user:'.$profile->id, $likes, now()->addMinutes(1440)); - if ($request->ajax()) { $response = ['code' => 200, 'msg' => 'Like saved', 'count' => $count]; } else { From 93aa65d1231fd7fd75976cb557bec79f43a363ba Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 12 May 2019 22:35:54 -0600 Subject: [PATCH 5/5] Update CommentController --- app/Http/Controllers/CommentController.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/CommentController.php b/app/Http/Controllers/CommentController.php index 0a8e3b662..20685da00 100644 --- a/app/Http/Controllers/CommentController.php +++ b/app/Http/Controllers/CommentController.php @@ -43,8 +43,8 @@ class CommentController extends Controller abort(403); } $this->validate($request, [ - 'item' => 'required|integer', - 'comment' => 'required|string|max:500', + 'item' => 'required|integer|min:1', + 'comment' => 'required|string|max:'.(int) config('pixelfed.max_caption_length'), ]); $comment = $request->input('comment'); $statusId = $request->item; @@ -57,8 +57,6 @@ class CommentController extends Controller return; } - Cache::forget('transform:status:'.$status->url()); - $reply = DB::transaction(function() use($comment, $status, $profile) { $autolink = Autolink::create()->autolink($comment); $reply = new Status();