[Fix] Not all tickets deleted on user deletion (#711)

This commit is contained in:
Dennis 2023-02-05 17:10:48 +01:00 committed by GitHub
commit 4657b3419b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -94,23 +94,16 @@ class User extends Authenticatable implements MustVerifyEmail
});
static::deleting(function (User $user) {
$user->servers()->chunk(10, function ($servers) {
foreach ($servers as $server) {
$server->delete();
}
// delete every server the user owns without using chunks
$user->servers()->each(function ($server) {
$server->delete();
});
$user->payments()->chunk(10, function ($payments) {
foreach ($payments as $payment) {
$payment->delete();
}
});
$user->payments()->delete();
$user->tickets()->chunk(10, function ($tickets) {
foreach ($tickets as $ticket) {
$ticket->delete();
}
});
$user->tickets()->delete();
$user->ticketBlackList()->delete();
@ -238,17 +231,17 @@ class User extends Authenticatable implements MustVerifyEmail
public function getAvatar()
{
//TODO loading the images to confirm they exist is causing to much load time. alternative has to be found :) maybe onerror tag on the <img tags>
// if ($this->discordUser()->exists()) {
// if(@getimagesize($this->discordUser->getAvatar())) {
// $avatar = $this->discordUser->getAvatar();
// } else {
// $avatar = "https://www.gravatar.com/avatar/" . md5(strtolower(trim($this->email)));
// }
// } else {
// $avatar = "https://www.gravatar.com/avatar/" . md5(strtolower(trim($this->email)));
// }
// if ($this->discordUser()->exists()) {
// if(@getimagesize($this->discordUser->getAvatar())) {
// $avatar = $this->discordUser->getAvatar();
// } else {
// $avatar = "https://www.gravatar.com/avatar/" . md5(strtolower(trim($this->email)));
// }
// } else {
// $avatar = "https://www.gravatar.com/avatar/" . md5(strtolower(trim($this->email)));
// }
return 'https://www.gravatar.com/avatar/'.md5(strtolower(trim($this->email)));
return 'https://www.gravatar.com/avatar/' . md5(strtolower(trim($this->email)));
}
/**
@ -298,9 +291,8 @@ class User extends Authenticatable implements MustVerifyEmail
public function getActivitylogOptions(): LogOptions
{
return LogOptions::defaults()
-> logOnly(['role', 'name', 'server_limit', 'pterodactyl_id', 'email'])
-> logOnlyDirty()
-> dontSubmitEmptyLogs();
->logOnly(['role', 'name', 'server_limit', 'pterodactyl_id', 'email'])
->logOnlyDirty()
->dontSubmitEmptyLogs();
}
}