Update Staging Deploy
This commit is contained in:
@@ -90,4 +90,9 @@ class EntryHelpers {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public static function enableOnlinePatcherBasedOnExtension(string $filename): bool
|
||||
{
|
||||
return Str::endsWith(Str::lower($filename), ['.ips', '.bps', '.xdelta', '.zip' ]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,22 @@ class FormHelpers {
|
||||
'release_site_helper' => "Project entry on site/blog/forum/Github.",
|
||||
'youtube_video' => "YouTube video",
|
||||
],
|
||||
'homebrew' => [
|
||||
'page_title' => "Submit an homebrew",
|
||||
'about_the' => "About the homebrew",
|
||||
'version' => "Patch version",
|
||||
'status' => "Status",
|
||||
'release_date' => "Release date",
|
||||
'release_date_helper' => "If only initial release exist, the release date.",
|
||||
'description' => "Description",
|
||||
'about_game' => "Game Information",
|
||||
'attachments' => "Attachments",
|
||||
'authors' => "Team members",
|
||||
'related_links' => "Related links",
|
||||
'release_site' => "Release site",
|
||||
'release_site_helper' => "Project entry on site/blog/forum/Github.",
|
||||
'youtube_video' => "YouTube video",
|
||||
],
|
||||
];
|
||||
|
||||
public static function getEntryFormWords( string $section ){
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Helpers\EntryHelpers;
|
||||
use App\Models\EntryFile;
|
||||
use App\Services\FileServersService;
|
||||
use Illuminate\Http\Client\ConnectionException;
|
||||
@@ -52,7 +53,7 @@ class FileServerController extends Controller {
|
||||
'filesize' => $data['file']['size'],
|
||||
'favorite_server' => $data['favorite_server'],
|
||||
'favorite_at' => time(),
|
||||
'state' => 'public'
|
||||
'state' => 'public',
|
||||
], now()->addHours(2) );
|
||||
|
||||
$data['finished'] = true;
|
||||
|
||||
@@ -49,7 +49,7 @@ class SubmissionController extends Controller
|
||||
if( section_must_be( 'romhacks', $section ) ){
|
||||
$data['modifications'] = Modification::orderBy('name')->get();
|
||||
}
|
||||
if( section_must_be( [ 'romhacks', 'translations' ], $section ) ){
|
||||
if( section_must_be( [ 'romhacks', 'translations', 'homebrew' ], $section ) ){
|
||||
$data['statuses'] = Status::orderBy('id')->get();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\EntryFile;
|
||||
use App\Services\FileServersService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ToolsController extends Controller
|
||||
@@ -10,11 +12,21 @@ class ToolsController extends Controller
|
||||
public function patcher()
|
||||
{
|
||||
|
||||
return view('tools.patcher');
|
||||
}
|
||||
|
||||
public function directPatch( Request $request, int $entry_id, EntryFile $file )
|
||||
{
|
||||
if( $file->entry_id != $entry_id ) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$service = app(FileServersService::class);
|
||||
|
||||
$patches = [
|
||||
'file' => 'ZELDA.ips',
|
||||
'name' => "Meltin",
|
||||
'description' => 'Blablabla',
|
||||
'outputName' => 'Game...'
|
||||
'file' => $service->getDownloadFileUrl( $file ),
|
||||
'name' => $file->entry->title,
|
||||
'outputName' => $file->filename
|
||||
];
|
||||
|
||||
return view('tools.patcher', compact('patches'));
|
||||
|
||||
@@ -64,7 +64,7 @@ class StoreEntryRequest extends FormRequest
|
||||
$rules['files_state.*'] = 'string|in:public,private,archived';
|
||||
}
|
||||
|
||||
if( section_must_not_be( 'translations', $section ) ){
|
||||
if( section_must_not_be( ['translations','homebrew'], $section ) ){
|
||||
$rules['entry_title'] = "required|string|max:255";
|
||||
} else {
|
||||
$rules['entry_title'] = "nullable|string|max:255";
|
||||
@@ -124,6 +124,12 @@ class StoreEntryRequest extends FormRequest
|
||||
}
|
||||
}
|
||||
|
||||
if( $isEdit ){
|
||||
$rules['files_metadata'] = 'array|nullable';
|
||||
$rules['files_metadata.*.online_patcher'] = 'nullable|boolean';
|
||||
$rules['files_metadata.*.secondary_online_patcher'] = 'nullable|boolean|required_with:files_metadata.*.online_patcher';
|
||||
}
|
||||
|
||||
if( $isEdit && $this->user()->can('moderate', $this->route('entry') ) ){
|
||||
$rules['staff_comment'] = 'nullable|string';
|
||||
$rules['owner_user_id'] = [ 'required', 'integer', new XfUserExists ];
|
||||
|
||||
@@ -162,7 +162,7 @@ class SubmissionsService {
|
||||
$entry = Entry::create( $fields );
|
||||
|
||||
// STEP 7 : Save entry fields.
|
||||
$this->Step7_SaveEntryFiles( $entry->id );
|
||||
$this->Step7_SaveEntryFiles( $entry );
|
||||
|
||||
// STEP 8 : Save hashes.
|
||||
$this->Step8_SaveHashes( $entry->id );
|
||||
@@ -275,25 +275,35 @@ class SubmissionsService {
|
||||
* @return void
|
||||
* @throws SubmissionException
|
||||
*/
|
||||
private function Step7_SaveEntryFiles( int $entryId, ?array $uuidData = null ): void
|
||||
private function Step7_SaveEntryFiles( Entry $entry, ?array $uuidData = null ): void
|
||||
{
|
||||
if( !$uuidData )
|
||||
$uuidData = $this->request->input('files_uuid', [] );
|
||||
|
||||
$metadataArray = $this->request->input('files_metadata', []);
|
||||
|
||||
foreach ( $uuidData ?? [] as $uuid ) {
|
||||
$fileData = Cache::pull("uploaded_file_{$uuid}");
|
||||
if( !$fileData )
|
||||
throw new SubmissionException( "File {$uuid} has expired. Please delete all your files and retry. If it's an edition, delete all your new files and retry." );
|
||||
|
||||
$onlinePatcher = (bool)($metadataArray[$uuid]['online_patcher'] ?? false);
|
||||
if( !$onlinePatcher )
|
||||
$onlinePatcher = EntryHelpers::enableOnlinePatcherBasedOnExtension( $fileData['filename'] );
|
||||
|
||||
$secondaryOnlinePatcher = (bool)($metadataArray[$uuid]['secondary_online_patcher'] ?? false);
|
||||
|
||||
EntryFile::create([
|
||||
'entry_id' => $entryId,
|
||||
'entry_id' => $entry->id,
|
||||
'file_uuid' => $uuid,
|
||||
'filename' => $fileData['filename'],
|
||||
'filepath' => $fileData['filepath'],
|
||||
'favorite_server' => $fileData['favorite_server'],
|
||||
'favorite_at' => \DateTimeImmutable::createFromTimestamp( $fileData['favorite_at'] ),
|
||||
'filesize' => $fileData['filesize'],
|
||||
'state' => 'public'
|
||||
'state' => 'public',
|
||||
'online_patcher' => $onlinePatcher,
|
||||
'secondary_online_patcher' => $secondaryOnlinePatcher,
|
||||
]);
|
||||
|
||||
}
|
||||
@@ -361,7 +371,6 @@ class SubmissionsService {
|
||||
*/
|
||||
private function Step10_SaveRomhacksModifications( Entry $entry ): void
|
||||
{
|
||||
|
||||
// TODO: Replace by edit version
|
||||
|
||||
foreach ( $this->request->input('modifications', [] ) ?? [] as $modificationId ) {
|
||||
@@ -494,7 +503,7 @@ class SubmissionsService {
|
||||
'user_id' => $user_id,
|
||||
'complete_title' => $completeTitle,
|
||||
'comments_thread_id' => $this->request->input('comments_thread_id'),
|
||||
'featured' => $this->request->input('featured'),
|
||||
'featured' => $this->request->input('featured') ?? false,
|
||||
];
|
||||
|
||||
if( \Auth::user()->can('moderate', $this->entry) ){
|
||||
@@ -600,12 +609,23 @@ class SubmissionsService {
|
||||
$needAddition = array_diff( $requestUuids, $existingUuids );
|
||||
|
||||
if( !empty( $needAddition ) ){
|
||||
$this->Step7_SaveEntryFiles( $this->entry->id, $needAddition ); // Same code.
|
||||
$this->Step7_SaveEntryFiles( $this->entry, $needAddition ); // Same code.
|
||||
}
|
||||
|
||||
$metadataArray = $this->request->input('files_metadata', []);
|
||||
$stateMap = array_combine( $requestUuids, $requestStates );
|
||||
|
||||
foreach( $stateMap as $uuid => $state ){
|
||||
EntryFile::where('file_uuid', $uuid)->where('entry_id', $entryId)->where('state', '!=', 'archived')->update(['state' => $state]);
|
||||
|
||||
$onlinePatcher = (bool)($metadataArray[$uuid]['online_patcher'] ?? false);
|
||||
$secondaryOnlinePatcher = (bool)($metadataArray[$uuid]['secondary_online_patcher'] ?? false);
|
||||
|
||||
EntryFile::where('file_uuid', $uuid)->where('entry_id', $entryId)->where('state', '!=', 'archived')
|
||||
->update([
|
||||
'state' => $state,
|
||||
'online_patcher' => $onlinePatcher,
|
||||
'secondary_online_patcher' => $secondaryOnlinePatcher,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user