Update Staging Deploy
This commit is contained in:
@@ -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