mirror of
https://github.com/Deathgarden-Rebirth/Deathgarden_Rebirth-Rewrite.git
synced 2026-09-12 05:05:24 -05:00
Add additional mod functionality
This commit is contained in:
@@ -16,7 +16,7 @@ public function getFileWithPatchline(string $patchlineName, string $hash) : Bina
|
||||
{
|
||||
$patchline = Patchline::tryFromName(str($patchlineName)->upper());
|
||||
|
||||
$gameFile = GameFile::select(['name'])->wherePatchline($patchline)->whereHash($hash)->latest()->first();
|
||||
$gameFile = GameFile::select(['filename'])->wherePatchline($patchline)->whereHash($hash)->latest()->first();
|
||||
$disk = Storage::disk('patches');
|
||||
|
||||
if($gameFile === null)
|
||||
@@ -49,7 +49,33 @@ public function getGameFileList(string $patchlineName = null) : JsonResponse
|
||||
return response()->json(['error' => 'Unauthorized'], 401);
|
||||
}
|
||||
|
||||
$gameFiles = GameFile::select(['name', 'hash', 'game_path', 'action'])->where('patchline', $patchline->value)->latest()->get();
|
||||
$gameFiles = GameFile::select(['filename', 'hash', 'game_path', 'action'])
|
||||
->where('patchline', $patchline->value)
|
||||
->where('is_additional', 0)->latest()->get();
|
||||
|
||||
if (count($gameFiles) <= 0)
|
||||
return response()->json(['error' => 'No files found'], 404);
|
||||
|
||||
return response()->json($gameFiles, 200);
|
||||
}
|
||||
|
||||
public function getGameModFileList(string $patchlineName = null) : JsonResponse
|
||||
{
|
||||
$patchline = Patchline::tryFromName(str($patchlineName)->upper()) ?? Patchline::LIVE;
|
||||
|
||||
if (!$patchline) {
|
||||
return response()->json(['error' => 'Invalid patchline'], 404);
|
||||
}
|
||||
|
||||
$neededRole = $patchline->getNeededRole();
|
||||
|
||||
if ($neededRole !== null && ( !Auth::check() || !Auth::user()->hasRole($neededRole->value))) {
|
||||
return response()->json(['error' => 'Unauthorized'], 401);
|
||||
}
|
||||
|
||||
$gameFiles = GameFile::select(['name', 'description', 'filename', 'hash', 'game_path', 'action'])
|
||||
->where('patchline', $patchline->value)
|
||||
->where('is_additional', 1)->latest()->get();
|
||||
|
||||
if (count($gameFiles) <= 0)
|
||||
return response()->json(['error' => 'No files found'], 404);
|
||||
|
||||
Reference in New Issue
Block a user