Merge pull request #5105 from pixelfed/staging

Staging
This commit is contained in:
daniel 2024-05-22 02:22:07 -06:00 committed by GitHub
commit 2414c340ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 136 additions and 111 deletions

View file

@ -10,6 +10,7 @@
- Update AdminCuratedRegisterController, fix existing account approval ([cbb96cfd](https://github.com/pixelfed/pixelfed/commit/cbb96cfd))
- Update ActivityPubFetchService, fix Friendica bug ([e4edc6f1](https://github.com/pixelfed/pixelfed/commit/e4edc6f1))
- Update ProfileController, fix atom feed cache ttl. Fixes #5093 ([921e2965](https://github.com/pixelfed/pixelfed/commit/921e2965))
- Update CollectionsController, add new self route ([bc2495c6](https://github.com/pixelfed/pixelfed/commit/bc2495c6))
- ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.12.1 (2024-05-07)](https://github.com/pixelfed/pixelfed/compare/v0.12.0...v0.12.1)

View file

@ -2,25 +2,15 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Auth;
use App\{
Collection,
CollectionItem,
Profile,
Status
};
use League\Fractal;
use App\Transformer\Api\{
AccountTransformer,
StatusTransformer,
};
use League\Fractal\Serializer\ArraySerializer;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use App\Collection;
use App\CollectionItem;
use App\Services\AccountService;
use App\Services\CollectionService;
use App\Services\FollowerService;
use App\Services\StatusService;
use App\Status;
use Auth;
use Illuminate\Http\Request;
class CollectionController extends Controller
{
@ -31,10 +21,11 @@ class CollectionController extends Controller
$collection = Collection::firstOrCreate([
'profile_id' => $profile->id,
'published_at' => null
'published_at' => null,
]);
$collection->visibility = 'draft';
$collection->save();
return view('collection.create', compact('collection'));
}
@ -52,12 +43,14 @@ class CollectionController extends Controller
}
}
}
return view('collection.show', compact('collection'));
}
public function index(Request $request)
{
abort_if(! Auth::check(), 403);
return $request->all();
}
@ -67,7 +60,7 @@ class CollectionController extends Controller
$this->validate($request, [
'title' => 'nullable|max:50',
'description' => 'nullable|max:500',
'visibility' => 'nullable|string|in:public,private,draft'
'visibility' => 'nullable|string|in:public,private,draft',
]);
$pid = $request->user()->profile_id;
@ -78,6 +71,7 @@ class CollectionController extends Controller
$collection->save();
CollectionService::deleteCollection($id);
return CollectionService::setCollection($collection->id, $collection);
}
@ -87,7 +81,7 @@ class CollectionController extends Controller
$this->validate($request, [
'title' => 'nullable|max:50',
'description' => 'nullable|max:500',
'visibility' => 'required|alpha|in:public,private,draft'
'visibility' => 'required|alpha|in:public,private,draft',
]);
$profile = Auth::user()->profile;
$collection = Collection::whereProfileId($profile->id)->findOrFail($id);
@ -99,6 +93,7 @@ class CollectionController extends Controller
$collection->visibility = $request->input('visibility');
$collection->published_at = now();
$collection->save();
return CollectionService::setCollection($collection->id, $collection);
}
@ -126,7 +121,7 @@ class CollectionController extends Controller
$this->validate($request, [
'collection_id' => 'required|int|min:1|exists:collections,id',
'post_id' => 'required|int|min:1'
'post_id' => 'required|int|min:1',
]);
$profileId = $request->user()->profile_id;
@ -161,7 +156,7 @@ class CollectionController extends Controller
$item = CollectionItem::firstOrCreate([
'collection_id' => $collection->id,
'object_type' => 'App\Status',
'object_id' => $status->id
'object_id' => $status->id,
], [
'order' => $count,
]);
@ -280,7 +275,7 @@ class CollectionController extends Controller
abort_if(! $request->user(), 403);
$this->validate($request, [
'collection_id' => 'required|int|min:1|exists:collections,id',
'post_id' => 'required|int|min:1'
'post_id' => 'required|int|min:1',
]);
$profileId = $request->user()->profile_id;
@ -319,4 +314,31 @@ class CollectionController extends Controller
return 200;
}
public function getSelfCollections(Request $request)
{
abort_if(! $request->user(), 404);
$user = $request->user();
$pid = $user->profile_id;
$profile = AccountService::get($pid, true);
if (! $profile || ! isset($profile['id'])) {
return response()->json([], 404);
}
return Collection::whereProfileId($pid)
->orderByDesc('id')
->paginate(9)
->map(function ($collection) {
$c = CollectionService::getCollection($collection->id);
$c['items'] = collect(CollectionService::getItems($collection->id))
->map(function ($id) {
return StatusService::get($id, false);
})->filter()->values();
return $c;
})
->filter()
->values();
}
}

View file

@ -133,6 +133,7 @@ Route::group(['prefix' => 'api'], function() use($middleware) {
Route::post('update/{id}', 'CollectionController@store')->middleware($middleware);
Route::delete('delete/{id}', 'CollectionController@delete')->middleware($middleware);
Route::post('remove', 'CollectionController@deleteId')->middleware($middleware);
Route::get('self', 'CollectionController@getSelfCollections')->middleware($middleware);
});
Route::group(['prefix' => 'direct'], function () use($middleware) {
@ -264,6 +265,7 @@ Route::group(['prefix' => 'api'], function() use($middleware) {
Route::post('update/{id}', 'CollectionController@store')->middleware($middleware);
Route::delete('delete/{id}', 'CollectionController@delete')->middleware($middleware);
Route::post('remove', 'CollectionController@deleteId')->middleware($middleware);
Route::get('self', 'CollectionController@getSelfCollections')->middleware($middleware);
});
Route::group(['prefix' => 'compose'], function () use($middleware) {