mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Refactor mailers
This commit is contained in:
parent
bfea83c8fd
commit
a99c4dfee0
@ -52,12 +52,6 @@ class TokenAuth
|
||||
return response()->json($error, 403);
|
||||
}
|
||||
|
||||
$truth = app()->make(TruthSource::class);
|
||||
|
||||
$truth->setCompanyUser($company_token->cu);
|
||||
$truth->setUser($company_token->user);
|
||||
$truth->setCompany($company_token->company);
|
||||
$truth->setCompanyToken($company_token);
|
||||
|
||||
/*
|
||||
|
|
||||
@ -67,7 +61,19 @@ class TokenAuth
|
||||
|
|
||||
*/
|
||||
|
||||
$truth = app()->make(TruthSource::class);
|
||||
|
||||
$truth->setCompanyUser($company_token->cu);
|
||||
$truth->setUser($company_token->user);
|
||||
$truth->setCompany($company_token->company);
|
||||
$truth->setCompanyToken($company_token);
|
||||
|
||||
/*
|
||||
| This method binds the db to the jobs created using this
|
||||
| session
|
||||
*/
|
||||
app('queue')->createPayloadUsing(function () use ($company_token) {
|
||||
nlog("setting DB ". $company_token->company->db);
|
||||
return ['db' => $company_token->company->db];
|
||||
});
|
||||
|
||||
|
@ -37,6 +37,7 @@ class MultiDBProvider extends ServiceProvider
|
||||
JobProcessing::class,
|
||||
function ($event) {
|
||||
if (isset($event->job->payload()['db'])) {
|
||||
nlog("Settings DB: " . $event->job->payload()['db']);
|
||||
MultiDB::setDb($event->job->payload()['db']);
|
||||
}
|
||||
}
|
||||
|
65
app/Services/Email/MailEntity.php
Normal file
65
app/Services/Email/MailEntity.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Services\Email;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Company;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class MailEntity implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected Company $company;
|
||||
|
||||
public function __construct(protected $invitation, private ?string $db, private ?string $reminder_template = null, private ?string $template_data = null, private bool $override = false)
|
||||
{
|
||||
|
||||
$this->invitation = $invitation;
|
||||
|
||||
$this->db = $db;
|
||||
|
||||
$this->reminder_template = $reminder_template;
|
||||
|
||||
$this->template_data = $template_data;
|
||||
|
||||
$this->override = $override;
|
||||
|
||||
// $this->entity_string = $this->resolveEntityString();
|
||||
|
||||
// $this->entity = $invitation->{$this->entity_string};
|
||||
|
||||
// $this->settings = $invitation->contact->client->getMergedSettings();
|
||||
|
||||
// $this->reminder_template = $reminder_template ?: $this->entity->calculateTemplate($this->entity_string);
|
||||
|
||||
// $this->html_engine = new HtmlEngine($invitation);
|
||||
|
||||
// $this->template_data = $template_data;
|
||||
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
MultiDB::setDb($this->db);
|
||||
|
||||
//construct mailable
|
||||
|
||||
//construct mailer
|
||||
|
||||
}
|
||||
|
||||
}
|
80
app/Services/Email/MailObject.php
Normal file
80
app/Services/Email/MailObject.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Services\Email;
|
||||
|
||||
use Illuminate\Mail\Mailables\Address;
|
||||
|
||||
/**
|
||||
* MailObject.
|
||||
*/
|
||||
class MailObject
|
||||
{
|
||||
|
||||
public ?string $db = null;
|
||||
|
||||
public array $to = [];
|
||||
|
||||
public ?Address $from = null;
|
||||
|
||||
public array $reply_to = [];
|
||||
|
||||
public array $cc = [];
|
||||
|
||||
public array $bcc = [];
|
||||
|
||||
public ?string $subject = null;
|
||||
|
||||
public ?string $body = null;
|
||||
|
||||
public array $attachments = [];
|
||||
|
||||
public string $company_key;
|
||||
|
||||
public ?object $settings = null;
|
||||
|
||||
public bool $whitelabel = false;
|
||||
|
||||
public ?string $logo = null;
|
||||
|
||||
public ?string $signature = null;
|
||||
|
||||
public ?string $greeting = null;
|
||||
|
||||
public ?int $client_id = null;
|
||||
|
||||
public ?int $vendor_id = null;
|
||||
|
||||
public ?int $user_id = null;
|
||||
|
||||
public ?int $client_contact_id = null;
|
||||
|
||||
public ?int $vendor_contact_id = null;
|
||||
|
||||
public ?string $email_template_body = null;
|
||||
|
||||
public ?string $email_template_subject = null;
|
||||
|
||||
public ?string $html_template = null;
|
||||
|
||||
public ?string $text_template = 'email.template.text';
|
||||
|
||||
public array $headers = [];
|
||||
|
||||
public ?string $invitation_key = null;
|
||||
|
||||
public ?int $entity_id = null;
|
||||
|
||||
public ?string $entity_class = null;
|
||||
|
||||
public array $variables = [];
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user