A lot of things

This commit is contained in:
2026-06-16 16:21:43 +02:00
parent 4f9f6c63b3
commit 7e1e26f20b
126 changed files with 7917 additions and 204 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Services;
use App\Models\EntryFile;
use App\Models\LogXfUser;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Http;
@@ -110,7 +111,6 @@ class FileServersService {
'filename' => $filename,
'current_chunk' => $currentChunk,
'total_chunks' => $totalChunks,
// TODO : Must replace User ID
'zeus' => $this->generateZeusToken( \Auth::user()->user_id, $server['base_url'], "Uploadchunk" ),
]);
@@ -129,4 +129,43 @@ class FileServersService {
return $data;
}
public function deleteFile(
string $filePath,
string $fileName,
int $userId
): bool {
foreach( $this->servers as $serverKey => $server ){
$response = Http::withHeaders([])
->post( $server['delete_file'], [
'filepath' => $filePath,
'filename' => $fileName,
'zeus' => $this->generateZeusToken( $userId, $server['base_url'], "Deletefile" ),
]);
if (!$response->successful()) {
throw new \RuntimeException( $response->body() );
}
$data = $response->json();
if( isset( $data['status'] ) && $data['status'] === 'deleted' ){
continue;
} else {
return false;
}
}
activity('entry-file')
->causedBy(LogXfUser::find($userId))
->withProperties([
'filepath' => $filePath,
'filename' => $fileName,
])
->event('file_deletion')
->log('File deleted');
return true;
}
}