mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Update ComposeController, add collection support to compose endpoint
This commit is contained in:
parent
0f6bf484d6
commit
ec2cfaf54e
1 changed files with 18 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue