Merge pull request #7809 from turbo124/v5-develop

v5.5.21
This commit is contained in:
David Bomba 2022-09-09 17:24:12 +10:00 committed by GitHub
commit 29d6a56296
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 109 additions and 63 deletions

View File

@ -1 +1 @@
5.5.20
5.5.21

View File

@ -0,0 +1,59 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\DataMapper\Analytics;
use Turbo124\Beacon\ExampleMetric\GenericMixedMetric;
class EmailCount extends GenericMixedMetric
{
/**
* The type of Sample.
*
* Monotonically incrementing counter
*
* - counter
*
* @var string
*/
public $type = 'mixed_metric';
/**
* The name of the counter.
* @var string
*/
public $name = 'account.daily_email_count';
/**
* The datetime of the counter measurement.
*
* date("Y-m-d H:i:s")
*
* @var DateTime
*/
public $datetime;
/**
* The Class failure name
* set to 0.
*
* @var string
*/
public $string_metric5 = 'account_key';
public $int_metric1 = 1;
public function __construct($int_metric1, $string_metric5)
{
$this->int_metric1 = $int_metric1;
$this->string_metric5 = $string_metric5;
}
}

View File

@ -306,7 +306,7 @@ class PreviewController extends BaseController
if (Ninja::isHosted()) {
LightLogs::create(new LivePreview())
->increment()
->queue();
->batch();
}
$response = Response::make($file_path, 200);

View File

@ -69,7 +69,7 @@ class QueryLogging
}
LightLogs::create(new DbQuery($request->method(), substr(urldecode($request->url()),0,180), $count, $time, $ip))
->queue();
->batch();
}
return $response;

View File

@ -123,7 +123,7 @@ class NinjaMailerJob implements ShouldQueue
->send($this->nmo->mailable);
LightLogs::create(new EmailSuccess($this->nmo->company->company_key))
->queue();
->batch();
/* Count the amount of emails sent across all the users accounts */
Cache::increment($this->company->account->key);

View File

@ -217,7 +217,7 @@ class ProcessPostmarkWebhook implements ShouldQueue
$this->request['MessageID']
);
LightLogs::create($bounce)->queue();
LightLogs::create($bounce)->batch();
SystemLogger::dispatch($this->request, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_BOUNCED, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company);
@ -263,7 +263,7 @@ class ProcessPostmarkWebhook implements ShouldQueue
$this->request['MessageID']
);
LightLogs::create($spam)->queue();
LightLogs::create($spam)->batch();
SystemLogger::dispatch($this->request, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_SPAM_COMPLAINT, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company);

View File

@ -61,7 +61,7 @@ class VendorTemplateEmail extends Mailable
}
if ($this->build_email->getTemplate() == 'custom') {
$this->build_email->setBody(str_replace('$body', $this->build_email->getBody(), $this->client->getSetting('email_style_custom')));
$this->build_email->setBody(str_replace('$body', $this->build_email->getBody(), $this->company->getSetting('email_style_custom')));
}
$settings = $this->company->settings;

View File

@ -64,7 +64,7 @@ class Vendor extends BaseModel
protected $touches = [];
protected $with = [
'company',
'contacts.company',
];
protected $presenter = VendorPresenter::class;

View File

@ -45,10 +45,7 @@ class VendorContact extends Authenticatable implements HasLocalePreference
'hashed_id',
];
protected $with = [
// 'vendor',
// 'company'
];
protected $with = [];
protected $casts = [
'updated_at' => 'timestamp',

View File

@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@ -87,16 +88,16 @@ class TemplateEngine
{
return $this->setEntity()
->setSettingsObject()
->setTemplates()
->replaceValues()
->renderTemplate();
->setSettingsObject()
->setTemplates()
->replaceValues()
->renderTemplate();
}
private function setEntity()
{
if (strlen($this->entity) > 1 && strlen($this->entity_id) > 1) {
$class = 'App\Models\\'.ucfirst(Str::camel($this->entity));
$class = 'App\Models\\' . ucfirst(Str::camel($this->entity));
$this->entity_obj = $class::withTrashed()->where('id', $this->decodePrimaryKey($this->entity_id))->company()->first();
} else {
$this->mockEntity();
@ -107,11 +108,10 @@ class TemplateEngine
private function setSettingsObject()
{
if($this->entity == 'purchaseOrder' || $this->entity == 'purchase_order'){
if ($this->entity == 'purchaseOrder' || $this->entity == 'purchase_order') {
$this->settings_entity = auth()->user()->company();
$this->settings = $this->settings_entity->settings;
}
elseif ($this->entity_obj->client()->exists()) {
} elseif ($this->entity_obj->client()->exists()) {
$this->settings_entity = $this->entity_obj->client;
$this->settings = $this->settings_entity->getMergedSettings();
} else {
@ -155,13 +155,11 @@ class TemplateEngine
$this->raw_body = $this->body;
$this->raw_subject = $this->subject;
if($this->entity == 'purchaseOrder'){
$this->fakerValues();
}
elseif ($this->entity_obj->client()->exists()) {
if ($this->entity_obj->client()->exists()) {
$this->entityValues($this->entity_obj->client->primary_contact()->first());
}
else {
} elseif ($this->entity_obj->vendor()->exists()) {
$this->entityValues($this->entity_obj->vendor->primary_contact()->first());
} else {
$this->fakerValues();
}
@ -184,16 +182,16 @@ class TemplateEngine
]);
$this->body = $converter->convert($this->body)->getContent();
}
private function entityValues($contact)
{
if($this->entity == 'purchaseOrder')
if (in_array($this->entity, ['purchaseOrder', 'purchase_order']))
$this->labels_and_values = (new VendorHtmlEngine($this->entity_obj->invitations->first()))->generateLabelsAndValues();
else
$this->labels_and_values = (new HtmlEngine($this->entity_obj->invitations->first()))->generateLabelsAndValues();
$this->body = strtr($this->body, $this->labels_and_values['labels']);
$this->body = strtr($this->body, $this->labels_and_values['values']);
@ -217,16 +215,15 @@ class TemplateEngine
$data['footer'] = '';
$data['logo'] = auth()->user()->company()->present()->logo();
if($this->entity_obj->client()->exists())
if ($this->entity_obj->client()->exists())
$data = array_merge($data, Helpers::sharedEmailVariables($this->entity_obj->client));
else{
else {
$data['signature'] = $this->settings->email_signature;
$data['settings'] = $this->settings;
$data['whitelabel'] = $this->entity_obj ? $this->entity_obj->company->account->isPaid() : true;
$data['company'] = $this->entity_obj ? $this->entity_obj->company : '';
$data['settings'] = $this->settings;
}
@ -235,7 +232,6 @@ class TemplateEngine
// In order to parse variables such as $signature in the body,
// we need to replace strings with the values from HTMLEngine.
$wrapper = strtr($wrapper, $this->labels_and_values['values']);
/*If no custom design exists, send back a blank!*/
@ -269,7 +265,7 @@ class TemplateEngine
private function mockEntity()
{
if(!$this->entity && $this->template && str_contains($this->template, 'purchase_order'))
if (!$this->entity && $this->template && str_contains($this->template, 'purchase_order'))
$this->entity = 'purchaseOrder';
DB::connection(config('database.default'))->beginTransaction();
@ -289,7 +285,7 @@ class TemplateEngine
'send_email' => true,
]);
if (! $this->entity || $this->entity == 'invoice') {
if (!$this->entity || $this->entity == 'invoice') {
$this->entity_obj = Invoice::factory()->create([
'user_id' => auth()->user()->id,
'company_id' => auth()->user()->company()->id,
@ -321,40 +317,37 @@ class TemplateEngine
if($this->entity == 'purchaseOrder')
{
if ($this->entity == 'purchaseOrder') {
$vendor = Vendor::factory()->create([
'user_id' => auth()->user()->id,
'company_id' => auth()->user()->company()->id,
]);
'user_id' => auth()->user()->id,
'company_id' => auth()->user()->company()->id,
]);
$contact = VendorContact::factory()->create([
'user_id' => auth()->user()->id,
'company_id' => auth()->user()->company()->id,
'vendor_id' => $vendor->id,
'is_primary' => 1,
'send_email' => true,
]);
'user_id' => auth()->user()->id,
'company_id' => auth()->user()->company()->id,
'vendor_id' => $vendor->id,
'is_primary' => 1,
'send_email' => true,
]);
$this->entity_obj = PurchaseOrder::factory()->create([
'user_id' => auth()->user()->id,
'company_id' => auth()->user()->company()->id,
'vendor_id' => $vendor->id,
]);
$invitation = PurchaseOrderInvitation::factory()->create([
'user_id' => auth()->user()->id,
'company_id' => auth()->user()->company()->id,
'purchase_order_id' => $this->entity_obj->id,
'vendor_contact_id' => $contact->id,
'user_id' => auth()->user()->id,
'company_id' => auth()->user()->company()->id,
'vendor_id' => $vendor->id,
]);
$invitation = PurchaseOrderInvitation::factory()->create([
'user_id' => auth()->user()->id,
'company_id' => auth()->user()->company()->id,
'purchase_order_id' => $this->entity_obj->id,
'vendor_contact_id' => $contact->id,
]);
}
if($vendor)
{
if ($vendor) {
$this->entity_obj->setRelation('invitations', $invitation);
$this->entity_obj->setRelation('vendor', $vendor);
@ -362,10 +355,7 @@ class TemplateEngine
$this->entity_obj->load('vendor');
$vendor->setRelation('company', auth()->user()->company());
$vendor->load('company');
}
else
{
} else {
$this->entity_obj->setRelation('invitations', $invitation);
$this->entity_obj->setRelation('client', $client);
$this->entity_obj->setRelation('company', auth()->user()->company());

View File

@ -14,8 +14,8 @@ return [
'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
'app_version' => '5.5.20',
'app_tag' => '5.5.20',
'app_version' => '5.5.21',
'app_tag' => '5.5.21',
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', ''),