updated moon mailer to record mail sent when it's sent to eve api

This commit is contained in:
2020-01-31 20:20:43 -06:00
parent 606348f5db
commit 026f9b6a1d
2 changed files with 16 additions and 14 deletions

View File

@@ -111,9 +111,6 @@ class MoonMailerCommand extends Command
//Increment the delay for the mail to not hit rate limits //Increment the delay for the mail to not hit rate limits
$delay += 30; $delay += 30;
//After the mail is dispatched, saved the sent mail record
$this->SaveSentRecord($mail->sender, $mail->subject, $mail->body, $mail->recipient, $mail->recipient_type);
//Update the moon as not being paid for the next month? //Update the moon as not being paid for the next month?
foreach($rentals as $rental) { foreach($rentals as $rental) {
$previous = new Carbon($rental->Paid_Until); $previous = new Carbon($rental->Paid_Until);
@@ -138,16 +135,6 @@ class MoonMailerCommand extends Command
]); ]);
} }
private function SaveSentRecord($sender, $subject, $body, $recipient, $recipientType) {
$sentmail = new SentMail;
$sentmail->sender = $sender;
$sentmail->subject = $subject;
$sentmail->body = $body;
$sentmail->recipient = $recipient;
$sentmail->recipient_type = $recipientType;
$sentmail->save();
}
private function GetMoonList($moons) { private function GetMoonList($moons) {
//Declare the variable to be used as a global part of the function //Declare the variable to be used as a global part of the function
$list = array(); $list = array();

View File

@@ -19,6 +19,7 @@ use App\Models\Esi\EsiScope;
use App\Models\Esi\EsiToken; use App\Models\Esi\EsiToken;
use App\Models\Mail\EveMail; use App\Models\Mail\EveMail;
use App\Models\Jobs\JobStatus; use App\Models\Jobs\JobStatus;
use App\Models\Mail\SentMail;
class ProcessSendEveMailJob implements ShouldQueue class ProcessSendEveMailJob implements ShouldQueue
{ {
@@ -38,6 +39,7 @@ class ProcessSendEveMailJob implements ShouldQueue
*/ */
public $retries = 3; public $retries = 3;
private $sender;
private $body; private $body;
private $recipient; private $recipient;
private $recipient_type; private $recipient_type;
@@ -53,6 +55,7 @@ class ProcessSendEveMailJob implements ShouldQueue
$this->recipient = $mail->recipient; $this->recipient = $mail->recipient;
$this->recipient_type = $mail->recipient_type; $this->recipient_type = $mail->recipient_type;
$this->subject = $mail->subject; $this->subject = $mail->subject;
$this->sender = $mail->sender;
$this->connection = 'redis'; $this->connection = 'redis';
} }
@@ -90,13 +93,15 @@ class ProcessSendEveMailJob implements ShouldQueue
]], ]],
'subject' => $this->subject, 'subject' => $this->subject,
])->invoke('post', '/characters/{character_id}/mail/', [ ])->invoke('post', '/characters/{character_id}/mail/', [
'character_id'=> $config['primary'], 'character_id'=> $this->sender,
]); ]);
} catch(RequestFailedException $e) { } catch(RequestFailedException $e) {
Log::warning($e); Log::warning($e);
return null; return null;
} }
$this->SaveSentRecord($this->sender, $this->subject, $this->body, $this->recipient, $this->recipient_type);
$this->delete(); $this->delete();
} }
@@ -110,4 +115,14 @@ class ProcessSendEveMailJob implements ShouldQueue
{ {
Log::critical($exception); Log::critical($exception);
} }
private function SaveSentRecord($sender, $subject, $body, $recipient, $recipientType) {
$sentmail = new SentMail;
$sentmail->sender = $sender;
$sentmail->subject = $subject;
$sentmail->body = $body;
$sentmail->recipient = $recipient;
$sentmail->recipient_type = $recipientType;
$sentmail->save();
}
} }