mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Refactoring emails
This commit is contained in:
parent
4bfff15612
commit
48d1a6726c
@ -17,8 +17,12 @@ use App\Jobs\Company\CreateCompany;
|
||||
use App\Jobs\Company\CreateCompanyPaymentTerms;
|
||||
use App\Jobs\Company\CreateCompanyTaskStatuses;
|
||||
use App\Jobs\Company\CreateCompanyToken;
|
||||
use App\Jobs\Mail\NinjaMailer;
|
||||
use App\Jobs\Mail\NinjaMailerJob;
|
||||
use App\Jobs\Mail\NinjaMailerObject;
|
||||
use App\Jobs\User\CreateUser;
|
||||
use App\Jobs\Util\VersionCheck;
|
||||
use App\Mail\Admin\AccountCreatedObject;
|
||||
use App\Models\Account;
|
||||
use App\Notifications\Ninja\NewAccountCreated;
|
||||
use App\Utils\Ninja;
|
||||
@ -88,7 +92,16 @@ class CreateAccount
|
||||
|
||||
$spaa9f78->fresh();
|
||||
|
||||
$sp035a66->notification(new NewAccountCreated($spaa9f78, $sp035a66))->ninja();
|
||||
//todo implement SLACK notifications
|
||||
//$sp035a66->notification(new NewAccountCreated($spaa9f78, $sp035a66))->ninja();
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new NinjaMailer((new AccountCreatedObject($spaa9f78, $sp035a66))->build());
|
||||
$nmo->company = $sp035a66;
|
||||
$nmo->to_user = $spaa9f78;
|
||||
$nmo->settings = $sp035a66->settings;
|
||||
|
||||
NinjaMailerJob::dispatchNow($nmo);
|
||||
|
||||
VersionCheck::dispatchNow();
|
||||
|
||||
|
@ -67,11 +67,12 @@ class NinjaMailerJob implements ShouldQueue
|
||||
|
||||
//send email
|
||||
try {
|
||||
nlog("trying to send");
|
||||
Mail::to($this->nmo->to_user->email)
|
||||
->send($this->nmo->mailable);
|
||||
} catch (\Exception $e) {
|
||||
//$this->failed($e);
|
||||
|
||||
nlog("error failed with {$e->getMessage()}");
|
||||
if ($this->nmo->to_user instanceof ClientContact) {
|
||||
$this->logMailError($e->getMessage(), $this->nmo->to_user->client);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class SendVerificationNotification implements ShouldQueue
|
||||
try {
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new NinjaMailer(new VerifyUserObject($event->user, $event->company));
|
||||
$nmo->mailable = new NinjaMailer((new VerifyUserObject($event->user, $event->company))->build());
|
||||
$nmo->company = $event->company;
|
||||
$nmo->to_user = $event->user;
|
||||
$nmo->settings = $event->company->settings;
|
||||
|
52
app/Mail/Admin/AccountCreatedObject.php
Normal file
52
app/Mail/Admin/AccountCreatedObject.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Mail\Admin;
|
||||
|
||||
class AccountCreatedObject
|
||||
{
|
||||
|
||||
public $user;
|
||||
|
||||
public $company;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct($user, $company)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->company = $company;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
|
||||
$data = [
|
||||
'title' => ctrans('texts.new_signup'),
|
||||
'message' => ctrans('texts.new_signup_text', ['user' => $this->user->present()->name(), 'email' => $this->user->email, 'ip' => $this->user->ip]),
|
||||
'url' => config('ninja.web_url'),
|
||||
'button' => ctrans('texts.account_login'),
|
||||
'signature' => $this->company->settings->email_signature,
|
||||
'settings' => $this->company->settings,
|
||||
'logo' => $this->company->present()->logo(),
|
||||
];
|
||||
|
||||
|
||||
$mail_obj = new \stdClass;
|
||||
$mail_obj->subject = ctrans('texts.new_signup');
|
||||
$mail_obj->data = $data;
|
||||
$mail_obj->markdown = 'email.admin.generic';
|
||||
$mail_obj->tag = $this->company->company_key;
|
||||
|
||||
return $mail_obj;
|
||||
}
|
||||
}
|
@ -42,6 +42,8 @@ class VerifyUserObject
|
||||
'url' => url("/user/confirm/{$this->user->confirmation_code}"),
|
||||
'button' => ctrans('texts.button_confirmation_message'),
|
||||
'settings' => $this->company->settings,
|
||||
'logo' => $this->company->present()->logo(),
|
||||
'signature' => $this->company->settings->email_signature,
|
||||
];
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user