mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for email templates
This commit is contained in:
parent
0d6b8140a0
commit
95e4cc7afc
@ -65,7 +65,7 @@ class SendEmailRequest extends Request
|
||||
$input['entity_id'] = $this->decodePrimaryKey($input['entity_id']);
|
||||
}
|
||||
|
||||
if (array_key_exists('entity', $input)) {
|
||||
if (isset($input['entity'])) {
|
||||
$input['entity'] = "App\Models\\".ucfirst(Str::camel($input['entity']));
|
||||
}
|
||||
|
||||
@ -83,15 +83,13 @@ class SendEmailRequest extends Request
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
|
||||
if (Ninja::isHosted() && !auth()->user()->account->account_sms_verified) {
|
||||
$this->error_message = ctrans('texts.authorization_sms_failure');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*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']) && $input['entity_id']) {
|
||||
if (isset($input['entity']) && array_key_exists('entity_id', $input) && is_string($input['entity']) && $input['entity_id']) {
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
@ -108,6 +106,9 @@ class SendEmailRequest extends Request
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->error_message = "Invalid entity or entity_id";
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -46,6 +46,32 @@ class InvoiceEmailTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
public function testTemplateValidation()
|
||||
{
|
||||
$data = [
|
||||
"body" => "hey what's up",
|
||||
"entity" => 'invoice',
|
||||
"entity_id"=> $this->invoice->hashed_id,
|
||||
"subject"=> 'Reminder $number',
|
||||
"template"=> "first_custom"
|
||||
];
|
||||
|
||||
$response = false;
|
||||
|
||||
// try {
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->postJson('/api/v1/emails', $data);
|
||||
// } catch (ValidationException $e) {
|
||||
// $message = json_decode($e->validator->getMessageBag(), 1);
|
||||
// nlog($message);
|
||||
// }
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
}
|
||||
|
||||
public function test_cc_email_implementation()
|
||||
{
|
||||
$data = [
|
||||
|
Loading…
x
Reference in New Issue
Block a user