mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for Invoice Designs (#3559)
* fixes for tests * Working on Invoice Designs * Update phpunit.yml * Update phpunit.yml * Working on sending an individual email * Update phpunit.yml * Fixes for designs * Update phpunit.yml * Working on sending entity email - individual * Fixes for account creation * Remove Laravel Horizon * remove logging
This commit is contained in:
parent
84e572de07
commit
6df62faa82
8
.github/workflows/phpunit.yml
vendored
8
.github/workflows/phpunit.yml
vendored
@ -20,6 +20,8 @@ jobs:
|
||||
CACHE_DRIVER: file
|
||||
QUEUE_CONNECTION: sync
|
||||
SESSION_DRIVER: file
|
||||
NINJA_ENVIRONMENT: development
|
||||
MULTI_DB_ENABLED: false
|
||||
|
||||
services:
|
||||
mariadb:
|
||||
@ -69,7 +71,7 @@ jobs:
|
||||
php artisan optimize
|
||||
php artisan cache:clear
|
||||
php artisan config:cache
|
||||
|
||||
|
||||
- name: Create DB and schemas
|
||||
run: |
|
||||
mkdir -p database
|
||||
@ -85,7 +87,9 @@ jobs:
|
||||
npm run production
|
||||
|
||||
- name: Run Testsuite
|
||||
run: vendor/bin/phpunit --testdox
|
||||
run: |
|
||||
cat .env
|
||||
vendor/bin/phpunit --testdox
|
||||
env:
|
||||
DB_PORT: ${{ job.services.mysql.ports[3306] }}
|
||||
|
||||
|
@ -40,9 +40,6 @@ class Kernel extends ConsoleKernel
|
||||
//$schedule->job(new RecurringInvoicesCron)->hourly();
|
||||
$schedule->job(new VersionCheck)->daily();
|
||||
|
||||
/* Build queue snapshots */
|
||||
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
||||
|
||||
/* Run queue's in shared hosting with this*/
|
||||
if (Ninja::isSelfHost()) {
|
||||
$schedule->command('queue:work')->everyMinute()->withoutOverlapping();
|
||||
|
@ -144,7 +144,7 @@ class CompanySettings extends BaseSettings
|
||||
public $pdf_email_attachment = false;
|
||||
public $ubl_email_attachment = false;
|
||||
|
||||
public $email_style = 'plain'; //plain, light, dark, custom
|
||||
public $email_style = 'light'; //plain, light, dark, custom
|
||||
public $email_style_custom = ''; //the template itself
|
||||
public $email_subject_invoice = '';
|
||||
public $email_subject_quote = '';
|
||||
|
@ -158,6 +158,10 @@ class Designer
|
||||
//$this->exported_variables['$entity_labels'] = $this->processLabels($this->input_variables['quote_details'], $this->quoteDetails($company));
|
||||
$this->exported_variables['$entity_details'] = $this->processVariables($this->input_variables['quote_details'], $this->quoteDetails($company));
|
||||
}
|
||||
else {
|
||||
$this->exported_variables['$entity_details'] = $this->processVariables($this->input_variables['invoice_details'], $this->quoteDetails($company));
|
||||
}
|
||||
|
||||
|
||||
$this->exported_variables['$product_table_header']= $this->entity->buildTableHeader($this->input_variables['product_columns']);
|
||||
$this->exported_variables['$product_table_body'] = $this->entity->buildTableBody($this->input_variables['product_columns'], $this->design->product, '$product');
|
||||
@ -265,22 +269,24 @@ class Designer
|
||||
|
||||
private function invoiceDetails(Company $company)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'$invoice.number' => '<span class="flex content-between flex-wrap">$invoice.number_label: $invoice.number</span>',
|
||||
'$invoice.po_number' => '<span class="flex content-between flex-wrap">$invoice.po_number_label: $invoice.po_number</span>',
|
||||
'$invoice.date' => '<span class="flex content-between flex-wrap">$invoice.date_label: $invoice.date</span>',
|
||||
'$invoice.due_date' => '<span class="flex content-between flex-wrap">$invoice.due_date_label: $invoice.due_date</span>',
|
||||
'$invoice.balance_due' => '<span class="flex content-between flex-wrap">$invoice.balance_due_label: $invoice.balance_due</span>',
|
||||
'$invoice.total' => '<span class="flex content-between flex-wrap">$invoice.total_label: $invoice.total</span>',
|
||||
'$invoice.partial_due' => '<span class="flex content-between flex-wrap">$invoice.partial_due_label: $invoice.partial_due</span>',
|
||||
'$invoice.custom1' => '<span class="flex content-between flex-wrap">$invoice1_label: $invoice.custom1</span>',
|
||||
'$invoice.custom2' => '<span class="flex content-between flex-wrap">$invoice2_label: $invoice.custom2</span>',
|
||||
'$invoice.custom3' => '<span class="flex content-between flex-wrap">$invoice3_label: $invoice.custom3</span>',
|
||||
'$invoice.custom4' => '<span class="flex content-between flex-wrap">$invoice4_label: $invoice.custom4</span>',
|
||||
'$surcharge1' => '<span class="flex content-between flex-wrap">$surcharge1_label: $surcharge1</span>',
|
||||
'$surcharge2' => '<span class="flex content-between flex-wrap">$surcharge2_label: $surcharge2</span>',
|
||||
'$surcharge3' => '<span class="flex content-between flex-wrap">$surcharge3_label: $surcharge3</span>',
|
||||
'$surcharge4' => '<span class="flex content-between flex-wrap">$surcharge4_label: $surcharge4</span>',
|
||||
'$invoice.number' => '<span class="flex justify-between items-center"><span>$invoice.number_label:</span><span> $invoice.number</span></span>',
|
||||
'$invoice.po_number' => '<span class="flex justify-between items-center"><span>$invoice.po_number_label:</span><span> $invoice.po_number</span></span>',
|
||||
'$invoice.date' => '<span class="flex justify-between items-center"><span>$invoice.date_label:</span><span> $invoice.date</span></span>',
|
||||
'$invoice.due_date' => '<span class="flex justify-between items-center"><span>$invoice.due_date_label:</span><span> $invoice.due_date</span></span>',
|
||||
'$invoice.balance_due' => '<span class="flex justify-between items-center"><span>$invoice.balance_due_label:</span><span> $invoice.balance_due</span></span>',
|
||||
'$invoice.total' => '<span class="flex justify-between items-center"><span>$invoice.total_label:</span><span> $invoice.total</span></span>',
|
||||
'$invoice.partial_due' => '<span class="flex justify-between items-center"><span>$invoice.partial_due_label:</span><span> $invoice.partial_due</span></span>',
|
||||
'$invoice.custom1' => '<span class="flex justify-between items-center"><span>$invoice1_label:</span><span> $invoice.custom1</span></span>',
|
||||
'$invoice.custom2' => '<span class="flex justify-between items-center"><span>$invoice2_label:</span><span> $invoice.custom2</span></span>',
|
||||
'$invoice.custom3' => '<span class="flex justify-between items-center"><span>$invoice3_label:</span><span> $invoice.custom3</span></span>',
|
||||
'$invoice.custom4' => '<span class="flex justify-between items-center"><span>$invoice4_label:</span><span> $invoice.custom4</span></span>',
|
||||
'$surcharge1' => '<span class="flex justify-between items-center"><span>$surcharge1_label:</span><span> $surcharge1</span></span>',
|
||||
'$surcharge2' => '<span class="flex justify-between items-center"><span>$surcharge2_label:</span><span> $surcharge2</span></span>',
|
||||
'$surcharge3' => '<span class="flex justify-between items-center"><span>$surcharge3_label:</span><span> $surcharge3</span></span>',
|
||||
'$surcharge4' => '<span class="flex justify-between items-center"><span>$surcharge4_label:</span><span> $surcharge4</span></span>',
|
||||
|
||||
];
|
||||
|
||||
return $this->processCustomFields($company, $data);
|
||||
@ -289,21 +295,22 @@ class Designer
|
||||
private function quoteDetails(Company $company)
|
||||
{
|
||||
$data = [
|
||||
'$quote.quote_number' => '<span class="flex content-between flex-wrap">$quote.number_label: $quote.number</span>',
|
||||
'$quote.po_number' => '<span class="flex content-between flex-wrap">$quote.po_number_label: $quote.po_number</span>',
|
||||
'$quote.quote_date' => '<span class="flex content-between flex-wrap">$quote.date_label: $quote.date</span>',
|
||||
'$quote.valid_until' => '<span class="flex content-between flex-wrap">$quote.valid_until_label: $quote.valid_until</span>',
|
||||
'$quote.balance_due' => '<span class="flex content-between flex-wrap">$quote.balance_due_label: $quote.balance_due</span>',
|
||||
'$quote.quote_total' => '<span class="flex content-between flex-wrap">$quote.total_label: $quote.total</span>',
|
||||
'$quote.partial_due' => '<span class="flex content-between flex-wrap">$quote.partial_due_label: $quote.partial_due</span>',
|
||||
'$quote.custom1' => '<span class="flex content-between flex-wrap">$quote.custom1_label: $quote.custom1</span>',
|
||||
'$quote.custom2' => '<span class="flex content-between flex-wrap">$quote.custom2_label: $quote.custom2</span>',
|
||||
'$quote.custom3' => '<span class="flex content-between flex-wrap">$quote.custom3_label: $quote.custom3</span>',
|
||||
'$quote.custom4' => '<span class="flex content-between flex-wrap">$quote.custom4_label: $quote.custom4</span>',
|
||||
'$quote.surcharge1' => '<span class="flex content-between flex-wrap">$surcharge1_label: $surcharge1</span>',
|
||||
'$quote.surcharge2' => '<span class="flex content-between flex-wrap">$surcharge2_label: $surcharge2</span>',
|
||||
'$quote.surcharge3' => '<span class="flex content-between flex-wrap">$surcharge3_label: $surcharge3</span>',
|
||||
'$quote.surcharge4' => '<span class="flex content-between flex-wrap">$surcharge4_label: $surcharge4</span>',
|
||||
'$quote.quote_number' => '<span class="flex justify-between items-center"><span>$quote.number_label:</span><span> $quote.number</span></span>',
|
||||
'$quote.po_number' => '<span class="flex justify-between items-center"><span>$quote.po_number_label:</span><span> $quote.po_number</span></span>',
|
||||
'$quote.quote_date' => '<span class="flex justify-between items-center"><span>$quote.date_label:</span><span> $quote.date</span></span>',
|
||||
'$quote.valid_until' => '<span class="flex justify-between items-center"><span>$quote.valid_until_label:</span><span> $quote.valid_until</span></span>',
|
||||
'$quote.balance_due' => '<span class="flex justify-between items-center"><span>$quote.balance_due_label:</span><span> $quote.balance_due</span></span>',
|
||||
'$quote.quote_total' => '<span class="flex justify-between items-center"><span>$quote.total_label:</span><span> $quote.total</span></span>',
|
||||
'$quote.partial_due' => '<span class="flex justify-between items-center"><span>$quote.partial_due_label:</span><span> $quote.partial_due</span></span>',
|
||||
'$quote.custom1' => '<span class="flex justify-between items-center"><span>$quote.custom1_label:</span><span> $quote.custom1</span></span>',
|
||||
'$quote.custom2' => '<span class="flex justify-between items-center"><span>$quote.custom2_label:</span><span> $quote.custom2</span></span>',
|
||||
'$quote.custom3' => '<span class="flex justify-between items-center"><span>$quote.custom3_label:</span><span> $quote.custom3</span></span>',
|
||||
'$quote.custom4' => '<span class="flex justify-between items-center"><span>$quote.custom4_label:</span><span> $quote.custom4</span></span>',
|
||||
'$quote.surcharge1' => '<span class="flex justify-between items-center"><span>$surcharge1_label:</span><span> $surcharge1</span></span>',
|
||||
'$quote.surcharge2' => '<span class="flex justify-between items-center"><span>$surcharge2_label:</span><span> $surcharge2</span></span>',
|
||||
'$quote.surcharge3' => '<span class="flex justify-between items-center"><span>$surcharge3_label:</span><span> $surcharge3</span></span>',
|
||||
'$quote.surcharge4' => '<span class="flex justify-between items-center"><span>$surcharge4_label:</span><span> $surcharge4</span></span>',
|
||||
|
||||
];
|
||||
|
||||
return $this->processCustomFields($company, $data);
|
||||
@ -312,20 +319,21 @@ class Designer
|
||||
private function creditDetails(Company $company)
|
||||
{
|
||||
$data = [
|
||||
'$credit.credit_number' => '<span>$credit.number</span>',
|
||||
'$credit.po_number' => '<span>$credit.po_number</span>',
|
||||
'$credit.credit_date' => '<span>$credit.date</span>',
|
||||
'$credit.credit_balance' => '<span>$credit.balance</span>',
|
||||
'$credit.credit_amount' => '<span>$credit.amount</span>',
|
||||
'$credit.partial_due' => '<span>$credit.partial_due</span>',
|
||||
'$credit.custom1' => '<span>$credit.custom1</span>',
|
||||
'$credit.custom2' => '<span>$credit.custom2</span>',
|
||||
'$credit.custom3' => '<span>$credit.custom3</span>',
|
||||
'$credit.custom4' => '<span>$credit.custom4</span>',
|
||||
'$credit.surcharge1' => '<span>$surcharge1_label: $surcharge1</span>',
|
||||
'$credit.surcharge2' => '<span>$surcharge2_label: $surcharge2</span>',
|
||||
'$credit.surcharge3' => '<span>$surcharge3_label: $surcharge3</span>',
|
||||
'$credit.surcharge4' => '<span>$surcharge4_label: $surcharge4</span>',
|
||||
'$credit.credit_number' => '<span class="flex justify-between items-center">$credit.number_label<span></span><span>$credit.number</span></span>',
|
||||
'$credit.po_number' => '<span class="flex justify-between items-center">$credit.po_number_label<span></span><span>$credit.po_number</span></span>',
|
||||
'$credit.credit_date' => '<span class="flex justify-between items-center">$credit.date_label<span></span><span>$credit.date</span></span>',
|
||||
'$credit.credit_balance' => '<span class="flex justify-between items-center">$credit.balance_label<span></span><span>$credit.balance</span></span>',
|
||||
'$credit.credit_amount' => '<span class="flex justify-between items-center">$credit.amount_label<span></span><span>$credit.amount</span></span>',
|
||||
'$credit.partial_due' => '<span class="flex justify-between items-center">$credit.partial_due_label<span></span><span>$credit.partial_due</span></span>',
|
||||
'$credit.custom1' => '<span class="flex justify-between items-center">$credit.custom1_label<span></span><span>$credit.custom1</span></span>',
|
||||
'$credit.custom2' => '<span class="flex justify-between items-center">$credit.custom2_label<span></span><span>$credit.custom2</span></span>',
|
||||
'$credit.custom3' => '<span class="flex justify-between items-center">$credit.custom3_label<span></span><span>$credit.custom3</span></span>',
|
||||
'$credit.custom4' => '<span class="flex justify-between items-center">$credit.custom4_label<span></span><span>$credit.custom4</span></span>',
|
||||
'$credit.surcharge1' => '<span class="flex justify-between items-center">$surcharge1_label<span></span><span>$surcharge1_label: $surcharge1</span></span>',
|
||||
'$credit.surcharge2' => '<span class="flex justify-between items-center">$surcharge2_label<span></span><span>$surcharge2_label: $surcharge2</span></span>',
|
||||
'$credit.surcharge3' => '<span class="flex justify-between items-center">$surcharge3_label<span></span><span>$surcharge3_label: $surcharge3</span></span>',
|
||||
'$credit.surcharge4' => '<span class="flex justify-between items-center">$surcharge4_label<span></span><span>$surcharge4_label: $surcharge4</span></span>',
|
||||
|
||||
];
|
||||
|
||||
return $this->processCustomFields($company, $data);
|
||||
|
101
app/Http/Controllers/EmailController.php
Normal file
101
app/Http/Controllers/EmailController.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com)
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\Email\SendEmailRequest;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
|
||||
class EmailController extends BaseController
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a template filled with entity variables
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
* @OA\Post(
|
||||
* path="/api/v1/emails",
|
||||
* operationId="sendEmailTemplate",
|
||||
* tags={"emails"},
|
||||
* summary="Sends an email for an entity",
|
||||
* description="Sends an email for an entity",
|
||||
* @OA\Parameter(ref="#/components/parameters/X-Api-Secret"),
|
||||
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
||||
* @OA\RequestBody(
|
||||
* description="The template subject and body",
|
||||
* required=true,
|
||||
* @OA\MediaType(
|
||||
* mediaType="application/json",
|
||||
* @OA\Schema(
|
||||
* type="object",
|
||||
* @OA\Property(
|
||||
* property="subject",
|
||||
* description="The email subject",
|
||||
* type="string",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="body",
|
||||
* description="The email body",
|
||||
* type="string",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="entity",
|
||||
* description="The entity name",
|
||||
* type="string",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="entity_id",
|
||||
* description="The entity_id",
|
||||
* type="string",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="template",
|
||||
* description="The template required",
|
||||
* type="string",
|
||||
* ),
|
||||
* )
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="success",
|
||||
* @OA\Header(header="X-API-Version", ref="#/components/headers/X-API-Version"),
|
||||
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
|
||||
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
|
||||
* @OA\JsonContent(ref="#/components/schemas/Template"),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=422,
|
||||
* description="Validation error",
|
||||
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
||||
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="default",
|
||||
* description="Unexpected Error",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
||||
* ),
|
||||
* )
|
||||
*/
|
||||
public function send(SendEmailRequest $request)
|
||||
{
|
||||
$data = [];
|
||||
|
||||
return response()->json($data, 200);
|
||||
}
|
||||
}
|
88
app/Http/Requests/Email/SendEmailRequest.php
Normal file
88
app/Http/Requests/Email/SendEmailRequest.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com)
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Http\Requests\Email;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class SendEmailRequest extends Request
|
||||
{
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize() : bool
|
||||
{
|
||||
return $this->checkUserAbleToSend();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
"template" => "required",
|
||||
"entity" => "required",
|
||||
"entity_id" => "required",
|
||||
"subject" => "required",
|
||||
"body" => "required",
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
$settings = auth()->user()->company()->settings;
|
||||
|
||||
if(!property_exists($settings, $template))
|
||||
unset($input['template']);
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
|
||||
public function message()
|
||||
{
|
||||
return [
|
||||
'template' => 'Invalid template.',
|
||||
];
|
||||
}
|
||||
|
||||
private function checkUserAbleToSend()
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
/*Make sure we have all the require ingredients to send a template*/
|
||||
if(array_key_exists('entity', $input) && array_key_exists('entity_id', $input) && is_string($input['entity']) && is_string($input['entity_id'])) {
|
||||
|
||||
$company = auth()->user()->company();
|
||||
|
||||
$entity = ucfirst($input['entity']);
|
||||
|
||||
$class = "App\Models\\$entity";
|
||||
|
||||
/* Harvest the entity*/
|
||||
$entity_obj = $class::whereId($this->decodePrimaryKey($input['entity_id']))->company()->first();
|
||||
|
||||
/* Check object, check user and company id is same as users, and check user can edit the object */
|
||||
if($entity_obj && ($company->id == $entity_obj->company_id) && auth()->user()->can('edit', $entity_obj))
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -77,7 +77,7 @@ class StoreQuoteRequest extends Request
|
||||
{
|
||||
return [
|
||||
'documents' => 'mimes:png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx',
|
||||
'client_id' => 'required|exists:clients,id',
|
||||
'client_id' => 'required|exists:clients,id,company_id,'.auth()->user()->company()->id,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class StoreRecurringInvoiceRequest extends Request
|
||||
{
|
||||
return [
|
||||
'documents' => 'mimes:png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx',
|
||||
'client_id' => 'required|exists:clients,id',
|
||||
'client_id' => 'required|exists:clients,id,company_id,'.auth()->user()->company()->id,
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -36,8 +36,7 @@ class StoreRecurringQuoteRequest extends Request
|
||||
{
|
||||
return [
|
||||
'documents' => 'mimes:png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx',
|
||||
'client_id' => 'required|exists:clients,id',
|
||||
|
||||
'client_id' => 'required|exists:clients,id,company_id,'.auth()->user()->company()->id,
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ class CreateAccount
|
||||
{
|
||||
if (config('ninja.environment') == 'selfhost' && Account::all()->count() > 1) {
|
||||
return response()->json(array('message' => Ninja::selfHostedMessage()), 400);
|
||||
} elseif (Ninja::boot()) {
|
||||
} elseif (!Ninja::boot()) {
|
||||
return response()->json(array('message' => Ninja::parse()), 401);
|
||||
}
|
||||
$sp794f3f = Account::create($this->request);
|
||||
|
@ -13,14 +13,14 @@ namespace App\Listeners;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Notifications\Ninja\VerifyUser;
|
||||
use App\Utils\Ninja;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Utils\Ninja;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class SendVerificationNotification implements ShouldQueue
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ use App\Repositories\ActivityRepository;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
|
||||
class ArchivedUserActivity
|
||||
class ArchivedUserActivity implements ShouldQueue
|
||||
{
|
||||
protected $activityRepo;
|
||||
/**
|
||||
|
@ -16,7 +16,7 @@ use App\Repositories\ActivityRepository;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
|
||||
class CreatedUserActivity
|
||||
class CreatedUserActivity implements ShouldQueue
|
||||
{
|
||||
protected $activityRepo;
|
||||
/**
|
||||
|
@ -16,7 +16,7 @@ use App\Repositories\ActivityRepository;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
|
||||
class RestoredUserActivity
|
||||
class RestoredUserActivity implements ShouldQueue
|
||||
{
|
||||
protected $activityRepo;
|
||||
/**
|
||||
|
@ -15,9 +15,14 @@ use App\Models\Activity;
|
||||
use App\Repositories\ActivityRepository;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class UpdateUserLastLogin
|
||||
class UpdateUserLastLogin implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
@ -34,7 +39,7 @@ class UpdateUserLastLogin
|
||||
* @return void
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
{ //\Log::error("listener firing");
|
||||
$user = $event->user;
|
||||
|
||||
$user->last_login = now();
|
||||
|
@ -16,7 +16,7 @@ use App\Repositories\ActivityRepository;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
|
||||
class UpdatedUserActivity
|
||||
class UpdatedUserActivity implements ShouldQueue
|
||||
{
|
||||
protected $activityRepo;
|
||||
/**
|
||||
|
@ -39,6 +39,10 @@ use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Illuminate\Queue\Events\JobFailed;
|
||||
use Illuminate\Queue\Events\JobProcessing;
|
||||
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
@ -72,6 +76,20 @@ class AppServiceProvider extends ServiceProvider
|
||||
Proposal::observe(ProposalObserver::class);
|
||||
Quote::observe(QuoteObserver::class);
|
||||
Task::observe(TaskObserver::class);
|
||||
|
||||
|
||||
// Queue::before(function (JobProcessing $event) {
|
||||
// \Log::info('Event Job '.$event->connectionName);
|
||||
// \Log::info('Event Job '.$event->job);
|
||||
// \Log::info('Event Job '.$event->job->payload());
|
||||
// });
|
||||
// //! Update Posted AT
|
||||
// Queue::after(function (JobProcessed $event) {
|
||||
// \Log::info('Event Job '.$event->connectionName);
|
||||
// \Log::info('Event Job '.$event->job);
|
||||
// \Log::info('Event Job '.$event->job->payload());
|
||||
// });
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,6 +100,8 @@ class AppServiceProvider extends ServiceProvider
|
||||
public function register()
|
||||
{
|
||||
$this->loadHelpers();
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function loadHelpers()
|
||||
|
@ -160,8 +160,19 @@ class EventServiceProvider extends ServiceProvider
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
// public function boot()
|
||||
// {
|
||||
// parent::boot();
|
||||
// }
|
||||
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
{
|
||||
parent::boot();
|
||||
//$events->subscribe('*');
|
||||
// \Event::listen('event.*', function ($eventName, array $data) {
|
||||
// \Log::error("Event Service Provider");
|
||||
// });
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -32,20 +32,27 @@ class MultiDBProvider extends ServiceProvider
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
if ($this->app->runningInConsole()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$this->app['events']->listen(
|
||||
\Illuminate\Queue\Events\JobProcessing::class,
|
||||
function ($event) {
|
||||
|
||||
if (isset($event->job->payload()['db'])) {
|
||||
\Log::error("Provider Setting DB = ".$event->job->payload()['db']);
|
||||
|
||||
//\Log::error("Provider Setting DB = ".$event->job->payload()['db']);
|
||||
//\Log::error('Event Job '.$event->connectionName);
|
||||
// \Log::error(print_r($event->job,1));
|
||||
//\Log::error(print_r($event->job->payload(),1));
|
||||
|
||||
MultiDB::setDb($event->job->payload()['db']);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
if ($this->app->runningInConsole()) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class Ninja
|
||||
|
||||
public static function isNinjaDev()
|
||||
{
|
||||
return config('ninja.app_env') == 'development';
|
||||
return config('ninja.environment') == 'development';
|
||||
}
|
||||
|
||||
public static function getDebugInfo()
|
||||
@ -69,9 +69,9 @@ class Ninja
|
||||
$data = json_decode($data);
|
||||
|
||||
if ($data && property_exists($data, 'message') && $data->message == sha1(config('ninja.license'))) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,14 +156,20 @@ class TemplateEngine
|
||||
$data['footer'] = '';
|
||||
|
||||
if ($email_style == 'custom') {
|
||||
|
||||
$wrapper = $this->settings_entity->getSetting('email_style_custom');
|
||||
$wrapper = $this->renderView($wrapper, $data);
|
||||
|
||||
/*If no custom design exists, send back a blank!*/
|
||||
if(strlen($wrapper) > 1)
|
||||
$wrapper = $this->renderView($wrapper, $data);
|
||||
else
|
||||
$wrapper = '';
|
||||
|
||||
} else {
|
||||
$wrapper = $this->getTemplate();
|
||||
$wrapper = view($this->getTemplatePath($email_style), $data)->render();
|
||||
}
|
||||
|
||||
|
||||
$data = [
|
||||
'subject' => $this->subject,
|
||||
'body' => $this->body,
|
||||
|
@ -32,7 +32,6 @@
|
||||
"intervention/image": "^2.4",
|
||||
"laracasts/presenter": "^0.2.1",
|
||||
"laravel/framework": "^6",
|
||||
"laravel/horizon": "3.7.2",
|
||||
"laravel/slack-notification-channel": "^2.0",
|
||||
"laravel/socialite": "^4.0",
|
||||
"laravel/tinker": "^1.0",
|
||||
|
@ -176,7 +176,6 @@ return [
|
||||
App\Providers\AuthServiceProvider::class,
|
||||
// App\Providers\BroadcastServiceProvider::class,
|
||||
App\Providers\EventServiceProvider::class,
|
||||
App\Providers\HorizonServiceProvider::class,
|
||||
App\Providers\RouteServiceProvider::class,
|
||||
App\Providers\ComposerServiceProvider::class,
|
||||
Codedge\Updater\UpdaterServiceProvider::class,
|
||||
|
@ -1,168 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Horizon Domain
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the subdomain where Horizon will be accessible from. If this
|
||||
| setting is null, Horizon will reside under the same domain as the
|
||||
| application. Otherwise, this value will serve as the subdomain.
|
||||
|
|
||||
*/
|
||||
|
||||
'domain' => null,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Horizon Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the URI path where Horizon will be accessible from. Feel free
|
||||
| to change this path to anything you like. Note that the URI will not
|
||||
| affect the paths of its internal API that aren't exposed to users.
|
||||
|
|
||||
*/
|
||||
|
||||
'path' => 'horizon',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Horizon Redis Connection
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the name of the Redis connection where Horizon will store the
|
||||
| meta information required for it to function. It includes the list
|
||||
| of supervisors, failed jobs, job metrics, and other information.
|
||||
|
|
||||
*/
|
||||
|
||||
'use' => 'default',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Horizon Redis Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This prefix will be used when storing all Horizon data in Redis. You
|
||||
| may modify the prefix when you are running multiple installations
|
||||
| of Horizon on the same server so that they don't have problems.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('HORIZON_PREFIX', 'horizon:'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Horizon Route Middleware
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These middleware will get attached onto each Horizon route, giving you
|
||||
| the chance to add your own middleware to this list or change any of
|
||||
| the existing middleware. Or, you can simply stick with this list.
|
||||
|
|
||||
*/
|
||||
|
||||
'middleware' => ['web'],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Queue Wait Time Thresholds
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows you to configure when the LongWaitDetected event
|
||||
| will be fired. Every connection / queue combination may have its
|
||||
| own, unique threshold (in seconds) before this event is fired.
|
||||
|
|
||||
*/
|
||||
|
||||
'waits' => [
|
||||
'redis:default' => 60,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Job Trimming Times
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you can configure for how long (in minutes) you desire Horizon to
|
||||
| persist the recent and failed jobs. Typically, recent jobs are kept
|
||||
| for one hour while all failed jobs are stored for an entire week.
|
||||
|
|
||||
*/
|
||||
|
||||
'trim' => [
|
||||
'recent' => 60,
|
||||
'completed' => 60,
|
||||
'recent_failed' => 10080,
|
||||
'failed' => 10080,
|
||||
'monitored' => 10080,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Fast Termination
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When this option is enabled, Horizon's "terminate" command will not
|
||||
| wait on all of the workers to terminate unless the --wait option
|
||||
| is provided. Fast termination can shorten deployment delay by
|
||||
| allowing a new instance of Horizon to start while the last
|
||||
| instance will continue to terminate each of its workers.
|
||||
|
|
||||
*/
|
||||
|
||||
'fast_termination' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Memory Limit (MB)
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value describes the maximum amount of memory the Horizon worker
|
||||
| may consume before it is terminated and restarted. You should set
|
||||
| this value according to the resources available to your server.
|
||||
|
|
||||
*/
|
||||
|
||||
'memory_limit' => 512,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Queue Worker Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define the queue worker settings used by your application
|
||||
| in all environments. These supervisors and settings handle all your
|
||||
| queued jobs and will be provisioned by Horizon during deployment.
|
||||
|
|
||||
*/
|
||||
|
||||
'environments' => [
|
||||
'production' => [
|
||||
'supervisor-1' => [
|
||||
'connection' => 'redis',
|
||||
'queue' => ['default'],
|
||||
'balance' => 'simple',
|
||||
'processes' => 2,
|
||||
'memory'=> 512,
|
||||
'timeout'=> 360,
|
||||
'tries' => 3,
|
||||
],
|
||||
],
|
||||
|
||||
'local' => [
|
||||
'supervisor-1' => [
|
||||
'connection' => 'redis',
|
||||
'queue' => ['default'],
|
||||
'balance' => 'simple',
|
||||
'processes' => 3,
|
||||
'memory'=> 512,
|
||||
'timeout'=> 360,
|
||||
'tries' => 3,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
@ -121,6 +121,8 @@ Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'a
|
||||
|
||||
Route::post('claim_license', 'LicenseController@index')->name('license.index');
|
||||
|
||||
Route::post('emails', 'EmailController@send')->name('email.send');
|
||||
|
||||
/*
|
||||
Route::resource('tasks', 'TaskController'); // name = (tasks. index / create / show / update / destroy / edit
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user