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