Fixing #5470: Checkin emails not working (#5838)

* Always send checkin notifications to users

This fixes the routing of the notifications, to only send „checkin“ emails if the „mail on checkin“ flag on the category was set. (and we checkout to a user with a non-empty email)

* Fixes checkout notification routing

Notifications to users should be send if the category of the resource (accessory/asset/consumable/license):

a) requires the user to confirm acceptance
b) should send notifications on checkin/checkout

* adds a check for EULAs

Adds back a check for the EULA, since the user should receive the EULA if it was set (regardless of other setings on the category, etc)
This commit is contained in:
Till Deeke
2018-07-16 23:09:04 +02:00
committed by snipe
parent dbd177576e
commit 3f334406d1
7 changed files with 134 additions and 24 deletions
@@ -4,6 +4,7 @@ namespace App\Notifications;
use App\Models\Setting;
use App\Models\SnipeModel;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
@@ -56,9 +57,13 @@ class CheckinAccessoryNotification extends Notification
$notifyBy[] = 'slack';
}
// Make sure the target is a user and that its appropriate to send them an email
if (($this->target_type == \App\Models\User::class) && (($this->item->requireAcceptance() == '1') || ($this->item->getEula())))
/**
* Only send checkin notifications to users if the category
* has the corresponding checkbox checked.
*/
if ($this->item->checkin_email() && $this->target instanceof User && $this->target->email != '')
{
\Log::debug('use email');
$notifyBy[] = 'mail';
}