mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 06:17:28 -08:00
* 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:
parent
dbd177576e
commit
3f334406d1
|
@ -4,6 +4,7 @@ namespace App\Notifications;
|
||||||
|
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use App\Models\SnipeModel;
|
use App\Models\SnipeModel;
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
@ -56,9 +57,13 @@ class CheckinAccessoryNotification extends Notification
|
||||||
$notifyBy[] = 'slack';
|
$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';
|
$notifyBy[] = 'mail';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Notifications;
|
||||||
|
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
@ -55,8 +56,11 @@ class CheckinAssetNotification extends Notification
|
||||||
$notifyBy[] = 'slack';
|
$notifyBy[] = 'slack';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the target is a user and that its appropriate to send them an email
|
/**
|
||||||
if ((($this->target->email!='') && ($this->target_type == 'App\Models\User')) && (($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');
|
\Log::debug('use email');
|
||||||
$notifyBy[] = 'mail';
|
$notifyBy[] = 'mail';
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Notifications;
|
||||||
|
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use App\Models\SnipeModel;
|
use App\Models\SnipeModel;
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
@ -53,8 +54,11 @@ class CheckinLicenseNotification extends Notification
|
||||||
$notifyBy[] = 'slack';
|
$notifyBy[] = 'slack';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
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 != '')
|
||||||
{
|
{
|
||||||
$notifyBy[] = 'mail';
|
$notifyBy[] = 'mail';
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Notifications;
|
||||||
|
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use App\Models\SnipeModel;
|
use App\Models\SnipeModel;
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
@ -59,10 +60,34 @@ class CheckoutAccessoryNotification extends Notification
|
||||||
$notifyBy[] = 'slack';
|
$notifyBy[] = 'slack';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the target is a user and that its appropriate to send them an email
|
|
||||||
if ((($this->target->email!='') && ($this->target_type == 'App\Models\User')) && (($this->item->requireAcceptance() == '1') || ($this->item->getEula())))
|
/**
|
||||||
{
|
* Only send notifications to users that have email addresses
|
||||||
$notifyBy[] = 'mail';
|
*/
|
||||||
|
if ($this->target instanceof User && $this->target->email != '') {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send an email if the asset requires acceptance,
|
||||||
|
* so the user can accept or decline the asset
|
||||||
|
*/
|
||||||
|
if ($this->item->requireAcceptance()) {
|
||||||
|
$notifyBy[1] = 'mail';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send an email if the item has a EULA, since the user should always receive it
|
||||||
|
*/
|
||||||
|
if ($this->item->getEula()) {
|
||||||
|
$notifyBy[1] = 'mail';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send an email if an email should be sent at checkin/checkout
|
||||||
|
*/
|
||||||
|
if ($this->item->checkin_email()) {
|
||||||
|
$notifyBy[1] = 'mail';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $notifyBy;
|
return $notifyBy;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Notifications;
|
namespace App\Notifications;
|
||||||
|
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Messages\SlackMessage;
|
use Illuminate\Notifications\Messages\SlackMessage;
|
||||||
|
@ -67,11 +68,35 @@ class CheckoutAssetNotification extends Notification
|
||||||
$notifyBy[] = 'slack';
|
$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 notifications to users that have email addresses
|
||||||
{
|
*/
|
||||||
$notifyBy[] = 'mail';
|
if ($this->target instanceof User && $this->target->email != '') {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send an email if the asset requires acceptance,
|
||||||
|
* so the user can accept or decline the asset
|
||||||
|
*/
|
||||||
|
if ($this->item->requireAcceptance()) {
|
||||||
|
$notifyBy[1] = 'mail';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send an email if the item has a EULA, since the user should always receive it
|
||||||
|
*/
|
||||||
|
if ($this->item->getEula()) {
|
||||||
|
$notifyBy[1] = 'mail';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send an email if an email should be sent at checkin/checkout
|
||||||
|
*/
|
||||||
|
if ($this->item->checkin_email()) {
|
||||||
|
$notifyBy[1] = 'mail';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return $notifyBy;
|
return $notifyBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Notifications;
|
||||||
|
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use App\Models\SnipeModel;
|
use App\Models\SnipeModel;
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
@ -56,10 +57,33 @@ class CheckoutConsumableNotification extends Notification
|
||||||
$notifyBy[] = 'slack';
|
$notifyBy[] = 'slack';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the target is a user and that its appropriate to send them an email
|
/**
|
||||||
if ((($this->target->email!='') && ($this->target_type == 'App\Models\User')) && (($this->item->requireAcceptance() == '1') || ($this->item->getEula())))
|
* Only send notifications to users that have email addresses
|
||||||
{
|
*/
|
||||||
$notifyBy[] = 'mail';
|
if ($this->target instanceof User && $this->target->email != '') {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send an email if the asset requires acceptance,
|
||||||
|
* so the user can accept or decline the asset
|
||||||
|
*/
|
||||||
|
if ($this->item->requireAcceptance()) {
|
||||||
|
$notifyBy[1] = 'mail';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send an email if the item has a EULA, since the user should always receive it
|
||||||
|
*/
|
||||||
|
if ($this->item->getEula()) {
|
||||||
|
$notifyBy[1] = 'mail';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send an email if an email should be sent at checkin/checkout
|
||||||
|
*/
|
||||||
|
if ($this->item->checkin_email()) {
|
||||||
|
$notifyBy[1] = 'mail';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $notifyBy;
|
return $notifyBy;
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Notifications;
|
||||||
|
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use App\Models\SnipeModel;
|
use App\Models\SnipeModel;
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
@ -57,12 +58,34 @@ class CheckoutLicenseNotification extends Notification
|
||||||
$notifyBy[] = 'slack';
|
$notifyBy[] = 'slack';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($this->target_type == \App\Models\User::class) && (($this->item->requireAcceptance() == '1') || ($this->item->getEula())))
|
/**
|
||||||
{
|
* Only send notifications to users that have email addresses
|
||||||
$notifyBy[] = 'mail';
|
*/
|
||||||
|
if ($this->target instanceof User && $this->target->email != '') {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send an email if the asset requires acceptance,
|
||||||
|
* so the user can accept or decline the asset
|
||||||
|
*/
|
||||||
|
if ($this->item->requireAcceptance()) {
|
||||||
|
$notifyBy[1] = 'mail';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send an email if the item has a EULA, since the user should always receive it
|
||||||
|
*/
|
||||||
|
if ($this->item->getEula()) {
|
||||||
|
$notifyBy[1] = 'mail';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send an email if an email should be sent at checkin/checkout
|
||||||
|
*/
|
||||||
|
if ($this->item->checkin_email()) {
|
||||||
|
$notifyBy[1] = 'mail';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return $notifyBy;
|
return $notifyBy;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue