fix: prevent flood of absence expiry notifcation emails
Signed-off-by: miguel456 <me@nogueira.codes>
This commit is contained in:
parent
35d112a5ca
commit
4a2061fbf9
@ -60,7 +60,9 @@ class AbsenceService
|
||||
User::whereHas('roles', function ($q) {
|
||||
$q->where('name', 'admin');
|
||||
})->get()->each(function ($user, $key) use ($absence) {
|
||||
$user->notify((new NewAbsenceRequest($absence)));
|
||||
if ($user->isNot($absence->requester->id)) {
|
||||
$user->notify((new NewAbsenceRequest($absence)));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -89,8 +91,7 @@ class AbsenceService
|
||||
'new_status' => 'APPROVED'
|
||||
]);
|
||||
|
||||
return $absence
|
||||
->setApproved()
|
||||
$absence->setApproved()
|
||||
->requester->notify(new AbsenceRequestApproved($absence));
|
||||
}
|
||||
|
||||
@ -110,8 +111,7 @@ class AbsenceService
|
||||
'new_status' => 'DECLINED'
|
||||
]);
|
||||
|
||||
return $absence
|
||||
->setDeclined()
|
||||
$absence->setDeclined()
|
||||
->requester->notify(new AbsenceRequestDeclined($absence));
|
||||
}
|
||||
|
||||
@ -130,8 +130,7 @@ class AbsenceService
|
||||
'new_status' => 'CANCELLED'
|
||||
]);
|
||||
|
||||
return $absence
|
||||
->setCancelled()
|
||||
$absence->setCancelled()
|
||||
->requester->notify(new AbsenceRequestCancelled($absence));
|
||||
}
|
||||
|
||||
@ -148,8 +147,7 @@ class AbsenceService
|
||||
'new_status' => 'ENDED'
|
||||
]);
|
||||
|
||||
return $absence
|
||||
->setEnded()
|
||||
$absence->setEnded()
|
||||
->requester->notify(new AbsenceRequestEnded($absence));
|
||||
}
|
||||
|
||||
@ -174,7 +172,7 @@ class AbsenceService
|
||||
{
|
||||
foreach (Absence::all() as $absence)
|
||||
{
|
||||
if (!Carbon::parse($absence->predicted_end)->isFuture() && $absence->status !== 'ENDED') {
|
||||
if (!Carbon::parse($absence->predicted_end)->isFuture() && $absence->isActionable()) {
|
||||
$this->endAbsence($absence);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user