Add server deletion to a queue.
This action allows servers to be deleted, but only be soft-deleted for 10 minutes. After that time period the server will be completely removed from the database and daemon. This allows some safety if a server is accidentally deleted. Force deleting a server will still work. If the daemon is in-accessible the server will fail to be deleted. When server is soft-deleted admins can still view its information page in the admin CP, however the server will be suspended and inaccessible on the front-end or though the daemon. Admins can manually delete the server ahead of the delete timer, or if it failed to delete previously they can do an immediate retry.
This commit is contained in:
parent
dbec99498d
commit
6fd7c78f0c
12 changed files with 377 additions and 38 deletions
|
@ -26,12 +26,15 @@ namespace Pterodactyl\Models;
|
|||
use Auth;
|
||||
use Pterodactyl\Models\Subuser;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
|
||||
class Server extends Model
|
||||
{
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
|
@ -44,17 +47,21 @@ class Server extends Model
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'daemonSecret',
|
||||
'sftp_password'
|
||||
];
|
||||
protected $hidden = ['daemonSecret', 'sftp_password'];
|
||||
|
||||
/**
|
||||
* The attributes that should be mutated to dates.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
/**
|
||||
* Fields that are not mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = ['id', 'installed', 'created_at', 'updated_at'];
|
||||
protected $guarded = ['id', 'installed', 'created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
/**
|
||||
* Cast values to correct type.
|
||||
|
@ -92,6 +99,7 @@ class Server extends Model
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
self::$user = Auth::user();
|
||||
}
|
||||
|
||||
|
@ -181,10 +189,6 @@ class Server extends Model
|
|||
|
||||
$result = $query->first();
|
||||
|
||||
if (!$result) {
|
||||
throw new DisplayException('No server was found belonging to this user.');
|
||||
}
|
||||
|
||||
if(!is_null($result)) {
|
||||
$result->daemonSecret = self::getUserDaemonSecret($result);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue