diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 0f8cfd3c58..fb42d547e9 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -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 || diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index 598c0cfcd0..a040556d38 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -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(); diff --git a/app/Jobs/User/UserEmailChanged.php b/app/Jobs/User/UserEmailChanged.php index b4021fe1cb..621287a492 100644 --- a/app/Jobs/User/UserEmailChanged.php +++ b/app/Jobs/User/UserEmailChanged.php @@ -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'), diff --git a/app/Listeners/Credit/CreditEmailedNotification.php b/app/Listeners/Credit/CreditEmailedNotification.php index 610eda58dd..dd7f3bd5e0 100644 --- a/app/Listeners/Credit/CreditEmailedNotification.php +++ b/app/Listeners/Credit/CreditEmailedNotification.php @@ -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); } } } diff --git a/app/Listeners/Invoice/InvoiceEmailedNotification.php b/app/Listeners/Invoice/InvoiceEmailedNotification.php index d14da9e7ed..1bffd1d376 100644 --- a/app/Listeners/Invoice/InvoiceEmailedNotification.php +++ b/app/Listeners/Invoice/InvoiceEmailedNotification.php @@ -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); } } } diff --git a/app/Listeners/Invoice/InvoiceFailedEmailNotification.php b/app/Listeners/Invoice/InvoiceFailedEmailNotification.php index bf5e0aeb83..aeda48fbfb 100644 --- a/app/Listeners/Invoice/InvoiceFailedEmailNotification.php +++ b/app/Listeners/Invoice/InvoiceFailedEmailNotification.php @@ -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); } } } diff --git a/app/Listeners/Misc/InvitationViewedListener.php b/app/Listeners/Misc/InvitationViewedListener.php index 1cb7083cc2..953ec7d44a 100644 --- a/app/Listeners/Misc/InvitationViewedListener.php +++ b/app/Listeners/Misc/InvitationViewedListener.php @@ -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); - } + // } } } diff --git a/app/Listeners/Payment/PaymentNotification.php b/app/Listeners/Payment/PaymentNotification.php index 7b5420c83d..8503e6eee5 100644 --- a/app/Listeners/Payment/PaymentNotification.php +++ b/app/Listeners/Payment/PaymentNotification.php @@ -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)) { diff --git a/app/Listeners/Quote/QuoteEmailedNotification.php b/app/Listeners/Quote/QuoteEmailedNotification.php index 62b88518d9..7cb0995f63 100644 --- a/app/Listeners/Quote/QuoteEmailedNotification.php +++ b/app/Listeners/Quote/QuoteEmailedNotification.php @@ -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); } } } \ No newline at end of file diff --git a/app/Mail/Admin/EntityFailedSendObject.php b/app/Mail/Admin/EntityFailedSendObject.php index e1b74dc736..bc7d228fba 100644 --- a/app/Mail/Admin/EntityFailedSendObject.php +++ b/app/Mail/Admin/EntityFailedSendObject.php @@ -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(), diff --git a/app/Notifications/Admin/EntitySentNotification.php b/app/Notifications/Admin/EntitySentNotification.php index b499d83136..617fab502b 100644 --- a/app/Notifications/Admin/EntitySentNotification.php +++ b/app/Notifications/Admin/EntitySentNotification.php @@ -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. * diff --git a/app/Notifications/Admin/EntityViewedNotification.php b/app/Notifications/Admin/EntityViewedNotification.php index 5fbdad38de..42493551b2 100644 --- a/app/Notifications/Admin/EntityViewedNotification.php +++ b/app/Notifications/Admin/EntityViewedNotification.php @@ -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. diff --git a/app/Notifications/Admin/NewPaymentNotification.php b/app/Notifications/Admin/NewPaymentNotification.php index 5becc897ab..61ad0c1912 100644 --- a/app/Notifications/Admin/NewPaymentNotification.php +++ b/app/Notifications/Admin/NewPaymentNotification.php @@ -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.