From ec2cfaf54e172e55af3ac65d95d9140359c29401 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 16 Feb 2022 02:43:27 -0700 Subject: [PATCH] Update ComposeController, add collection support to compose endpoint --- app/Http/Controllers/ComposeController.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ComposeController.php b/app/Http/Controllers/ComposeController.php index dee58b3df..d420c79a1 100644 --- a/app/Http/Controllers/ComposeController.php +++ b/app/Http/Controllers/ComposeController.php @@ -7,6 +7,8 @@ use Auth, Cache, DB, Storage, URL; use Carbon\Carbon; use App\{ Avatar, + Collection, + CollectionItem, Hashtag, Like, Media, @@ -449,7 +451,8 @@ class ComposeController extends Controller 'place' => 'nullable', 'comments_disabled' => 'nullable', 'tagged' => 'nullable', - 'license' => 'nullable|integer|min:1|max:16' + 'license' => 'nullable|integer|min:1|max:16', + 'collections' => 'sometimes|array|min:1|max:5', // 'optimize_media' => 'nullable' ]); @@ -572,6 +575,20 @@ class ComposeController extends Controller MediaTagService::sendNotification($mt); } + if($request->filled('collections')) { + $collections = Collection::whereProfileId($profile->id) + ->find($request->input('collections')) + ->each(function($collection) use($status) { + CollectionItem::firstOrCreate([ + 'collection_id' => $collection->id, + 'object_type' => 'App\Status', + 'object_id' => $status->id + ], [ + 'order' => $collection->items()->count() + ]); + }); + } + NewStatusPipeline::dispatch($status); Cache::forget('user:account:id:'.$profile->user_id); Cache::forget('_api:statuses:recent_9:'.$profile->id);