mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Fixes for mails
This commit is contained in:
parent
1d17b8c339
commit
8346875f88
@ -369,16 +369,21 @@ class UserController extends BaseController
|
||||
*/
|
||||
public function update(UpdateUserRequest $request, User $user)
|
||||
{
|
||||
|
||||
$old_company_user = $user->company_user;
|
||||
$old_user = $user;
|
||||
$old_user = json_encode($user);
|
||||
$old_user_email = $user->getOriginal('email');
|
||||
|
||||
$new_email = $request->input('email');
|
||||
$new_user = $this->user_repo->save($request->all(), $user);
|
||||
$new_user = $user->fresh();
|
||||
|
||||
$user = $this->user_repo->save($request->all(), $user);
|
||||
$user = $user->fresh();
|
||||
|
||||
if ($old_user->email != $new_email)
|
||||
UserEmailChanged::dispatch($new_user, $old_user, auth()->user()->company());
|
||||
nlog($old_user);
|
||||
|
||||
if ($old_user_email != $new_email)
|
||||
UserEmailChanged::dispatch($new_user, json_decode($old_user), auth()->user()->company());
|
||||
|
||||
|
||||
if(
|
||||
strcasecmp($old_company_user->permissions, $user->company_user->permissions) != 0 ||
|
||||
|
@ -80,6 +80,7 @@ class NinjaMailerJob implements ShouldQueue
|
||||
} catch (\Exception $e) {
|
||||
|
||||
nlog("error failed with {$e->getMessage()}");
|
||||
nlog($e);
|
||||
|
||||
if($this->nmo->entity)
|
||||
$this->entityEmailFailed($e->getMessage());
|
||||
@ -120,7 +121,7 @@ class NinjaMailerJob implements ShouldQueue
|
||||
|
||||
switch ($this->nmo->settings->email_sending_method) {
|
||||
case 'default':
|
||||
config(['mail.driver' => config('mail.default')]);
|
||||
//config(['mail.driver' => config('mail.default')]);
|
||||
break;
|
||||
case 'gmail':
|
||||
$this->setGmailMailer();
|
||||
|
@ -44,7 +44,7 @@ class UserEmailChanged implements ShouldQueue
|
||||
* @param string $old_email
|
||||
* @param Company $company
|
||||
*/
|
||||
public function __construct(User $new_user, User $old_user, Company $company)
|
||||
public function __construct(User $new_user, $old_user, Company $company)
|
||||
{
|
||||
$this->new_user = $new_user;
|
||||
$this->old_user = $old_user;
|
||||
@ -54,9 +54,10 @@ class UserEmailChanged implements ShouldQueue
|
||||
|
||||
public function handle()
|
||||
{
|
||||
if ($this->company->is_disabled) {
|
||||
nlog("notifying user of email change");
|
||||
|
||||
if ($this->company->is_disabled)
|
||||
return true;
|
||||
}
|
||||
|
||||
//Set DB
|
||||
MultiDB::setDb($this->company->db);
|
||||
@ -91,8 +92,8 @@ class UserEmailChanged implements ShouldQueue
|
||||
'title' => ctrans('texts.email_address_changed'),
|
||||
'message' => ctrans(
|
||||
'texts.email_address_changed_message',
|
||||
['old_email' => $this->old_email,
|
||||
'new_email' => $this->new_email,
|
||||
['old_email' => $this->old_user->email,
|
||||
'new_email' => $this->new_user->email,
|
||||
]
|
||||
),
|
||||
'url' => config('ninja.app_url'),
|
||||
|
@ -52,7 +52,7 @@ class CreditEmailedNotification implements ShouldQueue
|
||||
foreach ($event->invitation->company->company_users as $company_user) {
|
||||
$user = $company_user->user;
|
||||
|
||||
$notification = new EntitySentNotification($event->invitation, 'credit');
|
||||
// $notification = new EntitySentNotification($event->invitation, 'credit');
|
||||
|
||||
$methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'credit', ['all_notifications', 'credit_sent']);
|
||||
|
||||
@ -66,9 +66,9 @@ class CreditEmailedNotification implements ShouldQueue
|
||||
$first_notification_sent = false;
|
||||
}
|
||||
|
||||
$notification->method = $methods;
|
||||
// $notification->method = $methods;
|
||||
|
||||
$user->notify($notification);
|
||||
// $user->notify($notification);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ class InvoiceEmailedNotification implements ShouldQueue
|
||||
$user = $company_user->user;
|
||||
|
||||
/* This is only here to handle the alternate message channels - ie Slack */
|
||||
$notification = new EntitySentNotification($event->invitation, 'invoice');
|
||||
// $notification = new EntitySentNotification($event->invitation, 'invoice');
|
||||
|
||||
/* Returns an array of notification methods */
|
||||
$methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'invoice', ['all_notifications', 'invoice_sent']);
|
||||
@ -76,10 +76,10 @@ class InvoiceEmailedNotification implements ShouldQueue
|
||||
}
|
||||
|
||||
/* Override the methods in the Notification Class */
|
||||
$notification->method = $methods;
|
||||
// $notification->method = $methods;
|
||||
|
||||
/* Notify on the alternate channels */
|
||||
$user->notify($notification);
|
||||
// Notify on the alternate channels
|
||||
// $user->notify($notification);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ use App\Notifications\Admin\EntitySentNotification;
|
||||
use App\Utils\Traits\Notifications\UserNotifies;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class InvoiceFailedEmailNotification implements ShouldQueue
|
||||
class InvoiceFailedEmailNotification
|
||||
{
|
||||
use UserNotifies;
|
||||
|
||||
@ -54,7 +54,7 @@ class InvoiceFailedEmailNotification implements ShouldQueue
|
||||
foreach ($event->invitation->company->company_users as $company_user) {
|
||||
$user = $company_user->user;
|
||||
|
||||
$notification = new EntitySentNotification($event->invitation, 'invoice');
|
||||
// $notification = new EntitySentNotification($event->invitation, 'invoice');
|
||||
|
||||
$methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'invoice', ['all_notifications', 'invoice_sent']);
|
||||
|
||||
@ -68,9 +68,9 @@ class InvoiceFailedEmailNotification implements ShouldQueue
|
||||
$first_notification_sent = false;
|
||||
}
|
||||
|
||||
$notification->method = $methods;
|
||||
// $notification->method = $methods;
|
||||
|
||||
$user->notify($notification);
|
||||
// $user->notify($notification);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class InvitationViewedListener implements ShouldQueue
|
||||
$entity_name = lcfirst(class_basename($event->entity));
|
||||
$invitation = $event->invitation;
|
||||
|
||||
$notification = new EntityViewedNotification($invitation, $entity_name);
|
||||
// $notification = new EntityViewedNotification($invitation, $entity_name);
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new NinjaMailer( (new EntityViewedObject($invitation, $entity_name))->build() );
|
||||
@ -68,16 +68,16 @@ class InvitationViewedListener implements ShouldQueue
|
||||
|
||||
}
|
||||
|
||||
$notification->method = $methods;
|
||||
// $notification->method = $methods;
|
||||
|
||||
$company_user->user->notify($notification);
|
||||
// $company_user->user->notify($notification);
|
||||
}
|
||||
|
||||
if (isset($invitation->company->slack_webhook_url)) {
|
||||
$notification->method = ['slack'];
|
||||
// if (isset($invitation->company->slack_webhook_url)) {
|
||||
// $notification->method = ['slack'];
|
||||
|
||||
// Notification::route('slack', $invitation->company->slack_webhook_url)
|
||||
// ->notify($notification);
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
@ -69,19 +69,19 @@ class PaymentNotification implements ShouldQueue
|
||||
NinjaMailerJob::dispatch($nmo);
|
||||
}
|
||||
|
||||
$notification = new NewPaymentNotification($payment, $payment->company);
|
||||
$notification->method = $methods;
|
||||
// $notification = new NewPaymentNotification($payment, $payment->company);
|
||||
// $notification->method = $methods;
|
||||
|
||||
if ($user) {
|
||||
$user->notify($notification);
|
||||
}
|
||||
// if ($user) {
|
||||
// $user->notify($notification);
|
||||
// }
|
||||
}
|
||||
|
||||
/*Company Notifications*/
|
||||
if (isset($payment->company->slack_webhook_url)) {
|
||||
Notification::route('slack', $payment->company->slack_webhook_url)
|
||||
->notify(new NewPaymentNotification($payment, $payment->company, true));
|
||||
}
|
||||
// if (isset($payment->company->slack_webhook_url)) {
|
||||
// Notification::route('slack', $payment->company->slack_webhook_url)
|
||||
// ->notify(new NewPaymentNotification($payment, $payment->company, true));
|
||||
// }
|
||||
|
||||
/*Google Analytics Track Revenue*/
|
||||
if (isset($payment->company->google_analytics_key)) {
|
||||
|
@ -53,7 +53,7 @@ class QuoteEmailedNotification implements ShouldQueue
|
||||
foreach ($event->invitation->company->company_users as $company_user) {
|
||||
$user = $company_user->user;
|
||||
|
||||
$notification = new EntitySentNotification($event->invitation, 'quote');
|
||||
// $notification = new EntitySentNotification($event->invitation, 'quote');
|
||||
|
||||
$methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'quote', ['all_notifications', 'quote_sent']);
|
||||
|
||||
@ -68,9 +68,9 @@ class QuoteEmailedNotification implements ShouldQueue
|
||||
$first_notification_sent = false;
|
||||
}
|
||||
|
||||
$notification->method = $methods;
|
||||
// $notification->method = $methods;
|
||||
|
||||
$user->notify($notification);
|
||||
// $user->notify($notification);
|
||||
}
|
||||
}
|
||||
}
|
@ -131,6 +131,7 @@ class EntityFailedSendObject
|
||||
'client' => $this->contact->present()->name(),
|
||||
'invoice' => $this->entity->number,
|
||||
'error' => $this->message,
|
||||
'contact' => $this->contact->present()->name(),
|
||||
]
|
||||
),
|
||||
'url' => $this->invitation->getAdminLink(),
|
||||
|
@ -22,10 +22,9 @@ use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
//@deprecated
|
||||
class EntitySentNotification extends Notification implements ShouldQueue
|
||||
class EntitySentNotification extends Notification
|
||||
{
|
||||
//use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
|
@ -21,9 +21,8 @@ use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class EntityViewedNotification extends Notification implements ShouldQueue
|
||||
class EntityViewedNotification extends Notification
|
||||
{
|
||||
//use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
|
@ -21,9 +21,8 @@ use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class NewPaymentNotification extends Notification implements ShouldQueue
|
||||
class NewPaymentNotification extends Notification
|
||||
{
|
||||
// use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
|
Loading…
Reference in New Issue
Block a user