Migration table for failed jobs

This commit is contained in:
David Bomba 2022-06-25 00:11:10 +10:00
parent 91b658918a
commit 04cabac085
3 changed files with 48 additions and 26 deletions

View File

@ -54,7 +54,6 @@ class GmailTransport extends AbstractTransport
// $token = $message->getHeaders()->get('GmailToken')->getValue();
// $message->getHeaders()->remove('GmailToken');
nlog($message->getHeaders()->get('Tag')->getValue());
$token = '{"access_token":"ya29.a0ARrdaM_XgDGugpxwbHBCDQJgfOvuDfX_6d_PwC-g7e3TUMmym7aquhkVkLvpp92V3bq9LIP-mur289nITVkadeea5UhI667f8KMi836cdZFdYfYwm9yFTshUNozvegkNRtXIrD2LzzAZrIXH7kr1NilP5zyV6w","expires_in":3598,"scope":"openid https:\/\/www.googleapis.com\/auth\/userinfo.profile https:\/\/www.googleapis.com\/auth\/gmail.send https:\/\/www.googleapis.com\/auth\/userinfo.email","token_type":"Bearer","id_token":"eyJhbGciOiJSUzI1NiIsImtpZCI6IjJiMDllNzQ0ZDU4Yzk5NTVkNGYyNDBiNmE5MmY3YjM3ZmVhZDJmZjgiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiIzMjA4NDc1MzU1ODQtNHZvcHZ0OHY5MDY0aHM3a2plM2h0b25yMHZscHVvcm4uYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJhdWQiOiIzMjA4NDc1MzU1ODQtNHZvcHZ0OHY5MDY0aHM3a2plM2h0b25yMHZscHVvcm4uYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJzdWIiOiIxMDgyMDM3MTY1NjYwMjI5MjQ1OTMiLCJlbWFpbCI6InR1cmJvMTI0QGdtYWlsLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJhdF9oYXNoIjoiRjdzT1lvRUw0SU1qN1lGbUtvY0YydyIsIm5hbWUiOiJEYXZpZCBCb21iYSIsInBpY3R1cmUiOiJodHRwczovL2xoMy5nb29nbGV1c2VyY29udGVudC5jb20vYS0vQU9oMTRHaDMxSVFfYXBNME9GLWRKSzEwMnF1OFpIc1YtMHpyV2U2MTdzbEpiTW89czk2LWMiLCJnaXZlbl9uYW1lIjoiRGF2aWQiLCJmYW1pbHlfbmFtZSI6IkJvbWJhIiwibG9jYWxlIjoiZW4tR0IiLCJpYXQiOjE2NTYwNjI4NzUsImV4cCI6MTY1NjA2NjQ3NX0.ZeRLJ9jQA8bhVmyaGOrrk-stxsM4VU8fACmwWL6PNXAoFMbswRvrqj0LUnFk2aaswkHOXAG-BowKRfd2RoZ9SE_JlqFNBzaV09XrhtsdSkos7YrOIme2vu2qLT7fsYpkiwwcc9Dvv_TXJx0WX9sm-XrhPc86AWBJ9n2qpTed2hE_RZW4UnbjgxM2l7mnNXWFWK0uod4GAHHewhvQuz13Qk1Mf5ySxCdnNawzM5uKHso5RC3TH-q4aDIsIA4afTIxQx3qbHbvqzEYgWLukWSKXpU1F7Afwbok83Kh7_SXQVNAkOnmlnuEseG2YzpdtkTColuMTndPxD0Gt5A4WRuq7A","created":1656062875,"refresh_token":"1\/\/0dIt2gfW1if-aCgYIARAAGA0SNwF-L9Ir9GOXDuIyv6dIR-gw9ciugTefnUinn09-wjIhU4V0mC5G6x8mA0qzyV1fWhE6PbZI99Q"}';
@ -65,40 +64,27 @@ nlog($message->getHeaders()->get('Tag')->getValue());
return ['email' => $email->getAddress(), 'type' => 'to'];
}));
$this->gmail->from( collect($message->getFrom())->map(function ($email) {
return ['email' => $email->getAddress(), 'type' => 'from'];
}));
$this->gmail->from($message->getFrom());
$this->gmail->subject($message->getSubject());
$this->gmail->message($message->getHtmlBody());
$this->gmail->cc($message->getCc());
if(is_array($message->getBcc()))
$this->gmail->bcc(array_keys($message->getBcc()));
nlog("c");
nlog($message->getAttachments());
nlog("c1");
// nlog($message->getAttachments());
foreach ($message->getAttachments() as $child)
{
// foreach ($message->getAttachments() as $child)
// {
if($child->getContentType() != 'text/plain')
{
// nlog($child);
// if($child->getContentType() != 'text/plain')
// {
// $this->gmail->attach(TempFile::filePath($child->getBody(), $child->getHeaders()->get('Content-Type')->getParameter('name') ));
$this->gmail->attach(TempFile::filePath($child->getBody(), $child->getHeaders()->get('Content-Type')->getParameter('name') ));
// }
}
// }
}
nlog("d");
$this->gmail->send();
// $this->gmail->service->users_messages->send('me', $this->body,[]);

View File

@ -142,11 +142,11 @@ class InvoiceEmailEngine extends BaseEmailEngine
// Storage::url
foreach ($this->invoice->documents as $document) {
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => $document->type]]);
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL]]);
}
foreach ($this->invoice->company->documents as $document) {
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => $document->type]]);
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL]]);
}
$line_items = $this->invoice->line_items;
@ -164,7 +164,7 @@ class InvoiceEmailEngine extends BaseEmailEngine
->cursor()
->each(function ($expense) {
foreach ($expense->documents as $document) {
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => $document->type]]);
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL]]);
}
});
}
@ -180,7 +180,7 @@ class InvoiceEmailEngine extends BaseEmailEngine
->cursor()
->each(function ($task) {
foreach ($task->documents as $document) {
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => $document->type]]);
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL]]);
}
});
}

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('failed_jobs', function (Blueprint $table) {
$table->string('uuid')->after('id')->nullable()->unique();
});
DB::table('failed_jobs')->whereNull('uuid')->cursor()->each(function ($job) {
DB::table('failed_jobs')
->where('id', $job->id)
->update(['uuid' => (string) Illuminate\Support\Str::uuid()]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
};