mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-09 16:24:51 +00:00
Update ApiV1Controller, add collection_ids to /api/v1/statuses endpoint
This commit is contained in:
parent
0a82e9466d
commit
7ae21fc396
1 changed files with 26 additions and 1 deletions
|
@ -12,6 +12,8 @@ use Auth, Cache, DB, URL;
|
|||
use App\{
|
||||
Avatar,
|
||||
Bookmark,
|
||||
Collection,
|
||||
CollectionItem,
|
||||
DirectMessage,
|
||||
Follower,
|
||||
FollowRequest,
|
||||
|
@ -59,6 +61,7 @@ use App\Jobs\VideoPipeline\{
|
|||
|
||||
use App\Services\{
|
||||
AccountService,
|
||||
CollectionService,
|
||||
FollowerService,
|
||||
InstanceService,
|
||||
LikeService,
|
||||
|
@ -2481,7 +2484,8 @@ class ApiV1Controller extends Controller
|
|||
'sensitive' => 'nullable',
|
||||
'visibility' => 'string|in:private,unlisted,public',
|
||||
'spoiler_text' => 'sometimes|max:140',
|
||||
'place_id' => 'sometimes|integer|min:1|max:128769'
|
||||
'place_id' => 'sometimes|integer|min:1|max:128769',
|
||||
'collection_ids' => 'sometimes|array|max:3',
|
||||
]);
|
||||
|
||||
if(config('costar.enabled') == true) {
|
||||
|
@ -2618,6 +2622,27 @@ class ApiV1Controller extends Controller
|
|||
Cache::forget('profile:embed:' . $status->profile_id);
|
||||
Cache::forget($limitKey);
|
||||
|
||||
if($request->has('collection_ids') && $ids) {
|
||||
$collections = Collection::whereProfileId($user->profile_id)
|
||||
->find($request->input('collection_ids'))
|
||||
->each(function($collection) use($status) {
|
||||
$count = $collection->items()->count();
|
||||
$item = CollectionItem::firstOrCreate([
|
||||
'collection_id' => $collection->id,
|
||||
'object_type' => 'App\Status',
|
||||
'object_id' => $status->id
|
||||
],[
|
||||
'order' => $count,
|
||||
]);
|
||||
|
||||
CollectionService::addItem(
|
||||
$collection->id,
|
||||
$status->id,
|
||||
$count
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
$res = StatusService::getMastodon($status->id, false);
|
||||
$res['favourited'] = false;
|
||||
$res['language'] = 'en';
|
||||
|
|
Loading…
Reference in a new issue