Cleanup mount code; automatically include the mount in the configuration

This commit is contained in:
Dane Everitt 2020-09-13 09:59:54 -07:00
parent 8c6c271916
commit 9a21584c42
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
8 changed files with 69 additions and 20 deletions

View file

@ -9,6 +9,7 @@
namespace Pterodactyl\Services\Servers;
use Pterodactyl\Models\Mount;
use Pterodactyl\Models\Server;
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
@ -66,22 +67,9 @@ class ServerConfigurationStructureService
*
* @param \Pterodactyl\Models\Server $server
* @return array
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
protected function returnCurrentFormat(Server $server)
{
$mounts = $server->mounts;
foreach ($mounts as $mount) {
unset($mount->id);
unset($mount->uuid);
unset($mount->name);
unset($mount->description);
$mount->read_only = $mount->read_only == 1;
unset($mount->user_mountable);
unset($mount->pivot);
}
return [
'uuid' => $server->uuid,
'suspended' => (bool) $server->suspended,
@ -108,7 +96,13 @@ class ServerConfigurationStructureService
],
'mappings' => $server->getAllocationMappings(),
],
'mounts' => $mounts,
'mounts' => $server->mounts->map(function (Mount $mount) {
return [
'source' => $mount->source,
'target' => $mount->target,
'read_only' => $mount->read_only,
];
}),
];
}