Merge branch 'podcast' into dev

This commit is contained in:
Marco Cavalli 2025-07-18 11:36:27 +02:00
commit c14c0149ec
18 changed files with 525 additions and 140 deletions

View file

@ -7,8 +7,10 @@ use App\Helpers\LengthFormatter;
use App\Lib\RabbitMQSender;
use App\Models\File;
use App\Models\TrackType;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
class FileController extends Controller
@ -54,9 +56,19 @@ class FileController extends Controller
$user = Auth::user();
$apiKey = $request->header('php-auth-user');
//Accept request only from logged-in users
if (!$user) {
throw new \Exception("You must be logged in");
if ($apiKey != 'some_secret_api_key') {
throw new \Exception("You must be logged in");
}
//ToDo: check how to work in Legacy, getting user in this way is quite horrible
try {
$user = User::where('type','=','P')->orderBy('id','ASC')->first();
} catch (\Exception $e) {
Log::error($e->getMessage());
}
}
//Mime type list: https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
@ -138,6 +150,11 @@ class FileController extends Controller
$fields['track_type_id'] = TrackType::where('code','MUSICA')->first()->id;
}
//Force BPM to int
if (isset($fields['bpm'])) {
$fields['bpm'] = intval($fields['bpm']);
}
//return json_encode(['req' => $fields,'id' => $id]);
$file->fill($fields)->save();