From 88eb858316577e9d5abd638e4408e968c416e4b9 Mon Sep 17 00:00:00 2001 From: Maximo Castro Date: Fri, 15 Jan 2021 15:49:08 -0400 Subject: [PATCH 1/3] Improve --- tests/integration/Mail/MailTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/integration/Mail/MailTest.php b/tests/integration/Mail/MailTest.php index 29bd26b5..aaa5f445 100644 --- a/tests/integration/Mail/MailTest.php +++ b/tests/integration/Mail/MailTest.php @@ -14,6 +14,7 @@ class MailTest extends PhalconUnitTestCase public function testSimpleEmail() { //send email + $this->getDI()->get('mail') ->to('bakaphpmail@getnada.com') ->subject('Test Normal Email Queue') @@ -29,6 +30,7 @@ public function testSimpleEmail() public function testTemplateMail() { //send email + $this->getDI()->get('mail') ->to('bakaphpmail@getnada.com') ->subject('Test Template Email queue') @@ -45,6 +47,7 @@ public function testTemplateMail() public function testEmailSmtpConfig() { //send email + $this->getDI()->get('mail') ->to('bakaphpmail@getnada.com') ->subject('Test Template Email queue') @@ -62,6 +65,7 @@ public function testEmailSmtpConfig() public function testSimpleEmailNow() { //send email + $mailer = $this->getDI()->get('mail'); $mailer->to('info@mctekk.com') From 81c63eff0082126b5e2b26cc04e93f2a3f1e74f5 Mon Sep 17 00:00:00 2001 From: Maximo Castro Date: Sat, 23 Jan 2021 01:36:35 -0400 Subject: [PATCH 2/3] Update Mgiration --- .../20190510224738_init_blameable.php | 3 ++ .../20200711231533_add_custom_fieldsv2.php | 50 ++++++++++--------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/storage/db/migrations/20190510224738_init_blameable.php b/storage/db/migrations/20190510224738_init_blameable.php index 5623fde3..253fb5d2 100644 --- a/storage/db/migrations/20190510224738_init_blameable.php +++ b/storage/db/migrations/20190510224738_init_blameable.php @@ -24,6 +24,7 @@ public function change() 'limit' => MysqlAdapter::INT_BIG, 'signed' => false, 'identity' => 'enable', + 'precision' => '20', ]) ->addColumn('entity_id', 'string', [ 'null' => false, @@ -103,12 +104,14 @@ public function change() 'limit' => MysqlAdapter::INT_BIG, 'signed' => false, 'identity' => 'enable', + 'precision' => '20', ]) ->addColumn('audits_id', 'biginteger', [ 'null' => false, 'limit' => MysqlAdapter::INT_BIG, 'signed' => false, 'after' => 'id', + 'precision' => '20', ]) ->addColumn('field_name', 'string', [ 'null' => false, diff --git a/storage/db/migrations/20200711231533_add_custom_fieldsv2.php b/storage/db/migrations/20200711231533_add_custom_fieldsv2.php index 5e95de89..bf2e5cf2 100644 --- a/storage/db/migrations/20200711231533_add_custom_fieldsv2.php +++ b/storage/db/migrations/20200711231533_add_custom_fieldsv2.php @@ -7,14 +7,14 @@ class AddCustomFieldsv2 extends Phinx\Migration\AbstractMigration public function change() { $this->table('audits_details', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) + 'id' => false, + 'primary_key' => ['id'], + 'engine' => 'InnoDB', + 'encoding' => 'utf8mb4', + 'collation' => 'utf8mb4_general_ci', + 'comment' => '', + 'row_format' => 'DYNAMIC', + ]) ->changeColumn('old_value', 'text', [ 'null' => true, 'limit' => 65535, @@ -46,14 +46,14 @@ public function change() ->save(); $this->table('leads', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_unicode_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) + 'id' => false, + 'primary_key' => ['id'], + 'engine' => 'InnoDB', + 'encoding' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'comment' => '', + 'row_format' => 'DYNAMIC', + ]) ->changeColumn('email', 'string', [ 'null' => true, 'limit' => 255, @@ -64,18 +64,19 @@ public function change() ->save(); $this->table('apps_custom_fields', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_unicode_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) + 'id' => false, + 'primary_key' => ['id'], + 'engine' => 'InnoDB', + 'encoding' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'comment' => '', + 'row_format' => 'DYNAMIC', + ]) ->addColumn('id', 'biginteger', [ 'null' => false, 'limit' => MysqlAdapter::INT_BIG, 'identity' => 'enable', + 'precision' => '20', ]) ->addColumn('companies_id', 'integer', [ 'null' => false, @@ -99,6 +100,7 @@ public function change() 'default' => '0', 'limit' => MysqlAdapter::INT_BIG, 'after' => 'model_name', + 'precision' => '20', ]) ->addColumn('name', 'string', [ 'null' => false, From 26c10db48ec0f3d24059d819a7f5c1a2580c1efa Mon Sep 17 00:00:00 2001 From: Maximo Castro Date: Sat, 23 Jan 2021 22:34:13 -0400 Subject: [PATCH 3/3] Fix mail queue --- src/Mail/Jobs/Mail.php | 17 +++++++++-------- src/Mail/Message.php | 8 +++++++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/Mail/Jobs/Mail.php b/src/Mail/Jobs/Mail.php index 0bf6760d..7611a075 100644 --- a/src/Mail/Jobs/Mail.php +++ b/src/Mail/Jobs/Mail.php @@ -7,25 +7,26 @@ use Baka\Mail\Message; use Phalcon\Di; use Swift_Mailer; +use Swift_Message; use Swift_SmtpTransport; class Mail extends Job implements QueueableJobInterface { protected object $config; protected array $options; - protected Message $message; + protected Swift_Message $message; /** * Setup the mail job construct. * - * @param Message $message + * @param Swift_Message $message * @param array $options */ - public function __construct(Message $message, array $options = []) + public function __construct(Swift_Message $message, array $options = []) { $this->message = $message; - $this->config = $message->getManager()->getConfigure(); - $this->options = $options; + $this->config = $options['config']; + $this->options = $options['options']; } /** @@ -46,12 +47,12 @@ public function handle() $username = $auth['username']; $password = $auth['password']; - //ovewrite host + //overwrite host if (array_key_exists('host', $auth)) { $host = $auth['host']; } - //ovewrite port + //overwrite port if (array_key_exists('port', $auth)) { $port = $auth['port']; } @@ -65,7 +66,7 @@ public function handle() $swift = Swift_Mailer::newInstance($transport); $failures = []; - if ($swift->send($this->message->getMessage(), $failures)) { + if ($swift->send($this->message, $failures)) { Di::getDefault()->get('log')->info('Email successfully sent to', [$this->message->getTo()]); } else { Di::getDefault()->get('log')->error('Email error sending ', [$failures]); diff --git a/src/Mail/Message.php b/src/Mail/Message.php index 01e6848d..4269d678 100644 --- a/src/Mail/Message.php +++ b/src/Mail/Message.php @@ -74,7 +74,13 @@ public function send() $this->failedRecipients = []; $options = $this->auth ? ['auth' => $this->smtp] : []; - Mail::dispatch($this, $options); + Mail::dispatch( + $this->getMessage(), + [ + 'options' => $options, + 'config' => $this->getManager()->getConfigure() + ] + ); } /**