mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-05 18:23:48 +00:00
browsing api update
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=base64:w38JvwR4OwWaggjhc23zHJeOh/7hiHTf512npivEVNE=
|
||||
APP_KEY=base64:7BmLEVLO3kx5hHcR3MlXZIg89wr5pMu9NOipcxttmaU=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
APP_DEMO=false
|
||||
|
||||
@@ -33,10 +33,10 @@ Route::get('/zip/{shared}', VisitorZipController::class);
|
||||
Route::group(['prefix' => 'browse'], function () {
|
||||
Route::post('/authenticate/{shared}', VisitorUnlockLockedShareController::class);
|
||||
Route::get('/navigation/{shared}', VisitorNavigationFolderTreeController::class);
|
||||
Route::get('/search/{shared}', VisitorSearchFilesAndFoldersController::class);
|
||||
Route::get('/folders/{id}/{shared}', VisitorBrowseFolderController::class);
|
||||
Route::get('/file/{shared}', VisitorShowFileController::class);
|
||||
Route::get('/share/{share}', [ShareController::class, 'show']);
|
||||
});
|
||||
|
||||
Route::get('/search/{shared}', VisitorSearchFilesAndFoldersController::class);
|
||||
Route::get('/og-site/{share}', WebCrawlerOpenGraphController::class);
|
||||
|
||||
@@ -13,7 +13,6 @@ use Domain\Folders\Resources\FolderCollection;
|
||||
class BrowseFolderController
|
||||
{
|
||||
public function __invoke(
|
||||
Request $request,
|
||||
string $id,
|
||||
): array {
|
||||
$root_id = Str::isUuid($id) ? $id : null;
|
||||
|
||||
@@ -6,26 +6,31 @@ use Domain\Folders\Models\Folder;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Domain\Files\Resources\FilesCollection;
|
||||
use Domain\Folders\Resources\FolderCollection;
|
||||
use Str;
|
||||
|
||||
class BrowseTrashContentController
|
||||
{
|
||||
public function __invoke(string $id): array
|
||||
{
|
||||
$user_id = Auth::id();
|
||||
$root_id = $id === 'undefined' ? null : $id;
|
||||
$requestedFolder = $root_id ? Folder::withTrashed()->findOrFail($root_id) : null;
|
||||
$userId = Auth::id();
|
||||
$rootId = Str::isUuid($id) ? $id : null;
|
||||
|
||||
if ($root_id) {
|
||||
$requestedFolder = $rootId
|
||||
? Folder::withTrashed()
|
||||
->findOrFail($rootId)
|
||||
: null;
|
||||
|
||||
if ($rootId) {
|
||||
// Get folders and files
|
||||
$folders = Folder::onlyTrashed()
|
||||
->with('parent')
|
||||
->where('parent_id', $root_id)
|
||||
->where('parent_id', $rootId)
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
$files = File::onlyTrashed()
|
||||
->with('parent')
|
||||
->where('parent_id', $root_id)
|
||||
->where('parent_id', $rootId)
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
@@ -40,12 +45,12 @@ class BrowseTrashContentController
|
||||
// Get folders and files
|
||||
$folders_trashed = Folder::onlyTrashed()
|
||||
->with(['trashedFolders', 'parent'])
|
||||
->where('user_id', $user_id)
|
||||
->where('user_id', $userId)
|
||||
->get(['parent_id', 'id', 'name']);
|
||||
|
||||
$folders = Folder::onlyTrashed()
|
||||
->with(['parent'])
|
||||
->where('user_id', $user_id)
|
||||
->where('user_id', $userId)
|
||||
->whereIn('id', filter_folders_ids($folders_trashed))
|
||||
->sortable()
|
||||
->get();
|
||||
@@ -53,7 +58,7 @@ class BrowseTrashContentController
|
||||
// Get files trashed
|
||||
$files_trashed = File::onlyTrashed()
|
||||
->with(['parent'])
|
||||
->where('user_id', $user_id)
|
||||
->where('user_id', $userId)
|
||||
->where(function ($query) use ($folders_trashed) {
|
||||
$query->whereNull('parent_id');
|
||||
$query->orWhereNotIn('parent_id', array_values(array_unique(recursiveFind($folders_trashed->toArray(), 'id'))));
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\Sharing;
|
||||
|
||||
use Tests\TestCase;
|
||||
@@ -23,7 +24,7 @@ class UserShareTest extends TestCase
|
||||
$this
|
||||
->actingAs($user)
|
||||
->get('/api/share/123456789/qr')
|
||||
->assertCreated();
|
||||
->assertOk();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,12 +41,13 @@ class UserShareTest extends TestCase
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/share', [
|
||||
->postJson("/api/share/$file->id", [
|
||||
'isPassword' => false,
|
||||
'permission' => 'editor',
|
||||
'type' => 'file',
|
||||
'id' => $file->id,
|
||||
])->assertStatus(201)->assertJsonFragment([
|
||||
])->assertStatus(201)
|
||||
->assertJsonFragment([
|
||||
'item_id' => $file->id,
|
||||
'type' => 'file',
|
||||
]);
|
||||
@@ -74,12 +76,13 @@ class UserShareTest extends TestCase
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/share', [
|
||||
->postJson("/api/share/$folder->id", [
|
||||
'isPassword' => false,
|
||||
'permission' => 'editor',
|
||||
'type' => 'folder',
|
||||
'id' => $folder->id,
|
||||
])->assertStatus(201)->assertJsonFragment([
|
||||
])->assertStatus(201)
|
||||
->assertJsonFragment([
|
||||
'item_id' => $folder->id,
|
||||
'type' => 'folder',
|
||||
]);
|
||||
@@ -108,7 +111,7 @@ class UserShareTest extends TestCase
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/share', [
|
||||
->postJson("/api/share/$folder->id", [
|
||||
'isPassword' => true,
|
||||
'password' => 'secret',
|
||||
'permission' => 'editor',
|
||||
@@ -148,7 +151,7 @@ class UserShareTest extends TestCase
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/share', [
|
||||
->postJson("/api/share/$folder->id", [
|
||||
'isPassword' => false,
|
||||
'permission' => 'editor',
|
||||
'type' => 'folder',
|
||||
@@ -176,7 +179,7 @@ class UserShareTest extends TestCase
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/share', [
|
||||
->postJson("/api/share/$folder->id", [
|
||||
'isPassword' => false,
|
||||
'permission' => 'editor',
|
||||
'type' => 'folder',
|
||||
@@ -204,7 +207,7 @@ class UserShareTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson('/api/share', [
|
||||
$this->postJson("/api/share/$folder->id", [
|
||||
'isPassword' => false,
|
||||
'permission' => 'editor',
|
||||
'type' => 'folder',
|
||||
@@ -216,7 +219,7 @@ class UserShareTest extends TestCase
|
||||
'john@doe.com',
|
||||
'jane@doe.com',
|
||||
],
|
||||
])->assertStatus(204);
|
||||
])->assertStatus(200);
|
||||
|
||||
Notification::assertTimesSent(2, SharedSendViaEmail::class);
|
||||
}
|
||||
@@ -235,7 +238,7 @@ class UserShareTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson('/api/share', [
|
||||
$this->postJson("/api/share/$folder->id", [
|
||||
'isPassword' => false,
|
||||
'permission' => 'editor',
|
||||
'type' => 'folder',
|
||||
@@ -246,7 +249,7 @@ class UserShareTest extends TestCase
|
||||
'tokens' => [
|
||||
$folder->shared->token,
|
||||
],
|
||||
])->assertStatus(204);
|
||||
])->assertStatus(200);
|
||||
|
||||
$this->assertDatabaseMissing('shares', [
|
||||
'item_id' => $folder->id,
|
||||
|
||||
Reference in New Issue
Block a user