1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pixelfed_ynh.git synced 2024-09-03 20:06:04 +02:00

Update ComposeController, fix add to collection logic

This commit is contained in:
Daniel Supernault 2023-02-16 23:03:15 -07:00
parent abd52f4d3a
commit 9f8957b939
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -41,6 +41,7 @@ use App\Jobs\VideoPipeline\{
VideoThumbnail VideoThumbnail
}; };
use App\Services\AccountService; use App\Services\AccountService;
use App\Services\CollectionService;
use App\Services\NotificationService; use App\Services\NotificationService;
use App\Services\MediaPathService; use App\Services\MediaPathService;
use App\Services\MediaBlocklistService; use App\Services\MediaBlocklistService;
@ -585,13 +586,24 @@ class ComposeController extends Controller
$collections = Collection::whereProfileId($profile->id) $collections = Collection::whereProfileId($profile->id)
->find($request->input('collections')) ->find($request->input('collections'))
->each(function($collection) use($status) { ->each(function($collection) use($status) {
$count = $collection->items()->count();
CollectionItem::firstOrCreate([ CollectionItem::firstOrCreate([
'collection_id' => $collection->id, 'collection_id' => $collection->id,
'object_type' => 'App\Status', 'object_type' => 'App\Status',
'object_id' => $status->id 'object_id' => $status->id
], [ ], [
'order' => $collection->items()->count() 'order' => $count
]); ]);
CollectionService::addItem(
$collection->id,
$status->id,
$count
);
$collection->updated_at = now();
$collection->save();
CollectionService::setCollection($collection->id, $collection);
}); });
} }