removed job models for eve mail as it's no longer needed. updated all functions to the new programming method

This commit is contained in:
2020-05-11 00:00:13 -05:00
parent da39f990a5
commit ab9f6e5b52
11 changed files with 23 additions and 93 deletions

View File

@@ -15,7 +15,6 @@ use Commands\Library\CommandHelper;
//Models
use App\Models\Flex\FlexStructure;
use App\Models\Mail\SentMail;
use App\Models\Jobs\JobSendEveMail;
class FlexStructureCommand extends Command
{
@@ -93,19 +92,14 @@ class FlexStructureCommand extends Command
$body .= "Warped Intentions Leadership<br>";
//Dispatch the mail job
$mail = new JobSendEveMail;
$mail->sender = $config['primary'];
$mail->subject = "Warped Intentions Flex Structures Payment Due for " . $today->englishMonth;
$mail->body = $body;
$mail->recipient = (int)$structure->requestor_id;
$mail->recipient_type = 'character';
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
$subject = "Warped Intentions Flex Structures Payment Due for " . $today->englishMonth;
ProcessSendEveMailJob::dispatch($body, (int)$structure->requestor_id, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
//Increment the delay for the mail to not hit the rate limits
$delay += 60;
//After the mail is dispatched, save the sent mail record
$this->SaveSentRecord($mail->sender, $mail->subject, $mail->body, $mail->recipient, $mail->recipient_type);
$this->SaveSentRecord($config['primary'], $subject, $body, (int)$structure->requestor_id, 'character');
}
//Mark the job as finished

View File

@@ -17,7 +17,6 @@ use Seat\Eseye\Exceptions\RequestFailedException;
//Models
use App\Models\Moon\RentalMoon;
use App\Models\MoonRent\MoonRental;
use App\Models\Jobs\JobSendEveMail;
use App\Models\Mail\SentMail;
class MoonMailerCommand extends Command
@@ -101,13 +100,8 @@ class MoonMailerCommand extends Command
$body .= "Warped Intentions Leadership<br>";
//Dispatch the mail job
$mail = new JobSendEveMail;
$mail->sender = $config['primary'];
$mail->subject = "Warped Intentions Moon Rental Payment Due for " . $today->englishMonth;
$mail->body = $body;
$mail->recipient = (int)$contact->Contact;
$mail->recipient_type = 'character';
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
$subject = "Warped Intentions Moon Rental Payment Due for " . $today->englishMonth;
ProcessSendEveMailJob::dispatch($body, (int)$contact->Contact, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
//Increment the delay for the mail to not hit rate limits
$delay += 30;

View File

@@ -18,7 +18,6 @@ use App\Models\User\UserPermission;
use App\Models\Contracts\Contract;
use App\Models\Contracts\Bid;
use App\Models\Contracts\AcceptedBid;
use App\Models\Jobs\JobSendEveMail;
class ContractAdminController extends Controller
{
@@ -152,15 +151,8 @@ class ContractAdminController extends Controller
$body .= 'Please remit contract when the items are ready to Spatial Forces. Description should be the contract identification number. Request ISK should be the bid amount.';
$body .= 'Sincerely,<br>Spatial Forces Contracting Department';
//Setup the mail job
$mail = new JobSendEveMail;
$mail->subject = $subject;
$mail->recipient_type = 'character';
$mail->recipient = $bid['character_id'];
$mail->body = $body;
$mail->sender = $config['primary'];
//Dispatch the mail job
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail')->delay(Carbon::now()->addSeconds(5));
ProcessSendEveMailJob::dispatch($body, $bid['character_id'], 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(5));
//Tidy up the contract by doing a few things.
$this->TidyContract($contract, $bid);
@@ -187,12 +179,8 @@ class ContractAdminController extends Controller
//Get the esi config
$config = config('esi');
$mail = new JobSendEveMail;
$mail->sender = $config['primary'];
$mail->subject = 'New Alliance Production Contract Available';
$mail->recipient = $config['alliance'];
$mail->recipient_type = 'alliance';
$mail->body = "A new contract is available for the alliance contracting system. Please check out <a href='https://services.w4rp.space'>Services Site</a> if you want to bid on the production contract.<br><br>Sincerely,<br>Warped Intentions Leadership";
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail')->delay(Carbon::now()->addSeconds(5));
$subject = 'New Alliance Production Contract Available';
$body = "A new contract is available for the alliance contracting system. Please check out <a href='https://services.w4rp.space'>Services Site</a> if you want to bid on the production contract.<br><br>Sincerely,<br>Warped Intentions Leadership";
ProcessSendEveMailJob::dispatch($body, $config['alliance'], 'alliance', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(5));
}
}

View File

@@ -9,7 +9,6 @@ use Log;
//Models
use App\Models\Logistics\AnchorStructure;
use App\Models\Jobs\JobSendEveMail;
class StructureRequestAdminController extends Controller
{

View File

@@ -15,7 +15,6 @@ use App\Library\Lookups\LookupHelper;
//Models
use App\Models\Logistics\AnchorStructure;
use App\Models\Jobs\JobSendEveMail;
use App\Models\User\UserPermission;
class StructureRequestController extends Controller
@@ -72,13 +71,8 @@ class StructureRequestController extends Controller
$body .= "Warped Intentions Leadership<br>";
//Dispatch the mail job
$mail = new JobSendEveMail;
$mail->sender = $config['primary'];
$mail->subject = "New Structure Anchor Request";
$mail->body = $body;
$mail->recipient = (int)$fc->character_id;
$mail->recipient_type = 'character';
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
$subject = "New Structure Anchor Request";
ProcessSendEveMailJob::dispatch($body, (int)$fc->character_id, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
$delay += 15;
}

View File

@@ -17,7 +17,6 @@ use App\Models\Moon\Price;
use App\Models\MoonRent\MoonRental;
use App\Models\Moon\AllianceMoon;
use App\Models\Moon\AllianceMoonRequest;
use App\Models\Jobs\JobSendEveMail;
//Library
use App\Library\Moons\MoonCalc;
@@ -130,13 +129,7 @@ class MoonsAdminController extends Controller
}
//Setup the mail model
$mail = new JobSendEveMail;
$mail->sender = $config['primary'];
$mail->subject = 'Warped Intentions Moon Request';
$mail->body = $body;
$mail->recipient = (int)$moon->requestor_id;
$mail->recipient_type = 'character';
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail')->delay(Carbon::now()->addSeconds(5));
ProcessSendEveMailJob::dispatch($body, (int)$moon->requestor_id, 'character', 'Warped Intentions Moon Request', $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(5));
return redirect('/moons/admin/display/request')->with('success', 'Moon has been processed, and mail has been sent out.');
}

View File

@@ -21,7 +21,6 @@ use Seat\Eseye\Exceptions\RequestFailedException;
//Models
use App\Models\Moon\RentalMoon;
use App\Models\MoonRent\MoonRental;
use App\Models\Jobs\JobSendEveMail;
use App\Models\Mail\SentMail;
class MoonRentalInvoiceCreate implements ShouldQueue
@@ -117,13 +116,8 @@ class MoonRentalInvoiceCreate implements ShouldQueue
//Dispatch a new mail job
$mail = new JobSendEveMail;
$mail->sender = $config['primary'];
$mail->subject = "Warped Intentions Moon Rental Payment Due for " . $today->englishMonth;
$mail->body = $body;
$mail->recipient = (int)$contact->Contact;
$mail->recipient_type = 'character';
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail')->delay(Carbon::now()->addSeconds($this->delay));
$subject = "Warped Intentions Moon Rental Payment Due for " . $today->englishMonth;
ProcessSendEveMailJob::dispatch($body, (int)$contact->Contact, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($this->delay));
MoonRentalUpdate::dispatch($this->rentals)->onQueue('moons');
}

View File

@@ -22,7 +22,6 @@ use App\Models\Esi\EsiScope;
use App\Models\Esi\EsiToken;
use App\Models\Jobs\JobStatus;
use App\Models\Mail\SentMail;
use App\Models\Jobs\JobSendEveMail;
class ProcessSendEveMailJob implements ShouldQueue
{
@@ -53,12 +52,12 @@ class ProcessSendEveMailJob implements ShouldQueue
*
* @return void
*/
public function __construct(JobSendEveMail $mail) {
$this->body = $mail->body;
$this->recipient = $mail->recipient;
$this->recipient_type = $mail->recipient_type;
$this->subject = $mail->subject;
$this->sender = $mail->sender;
public function __construct($body, $recipient, $recipient_type, $subject, $sender) {
$this->body = $body;
$this->recipient = $recipient;
$this->recipient_type = $recipient_type;
$this->subject = $subject;
$this->sender = $sender;
$this->connection = 'redis';
}

View File

@@ -8,7 +8,6 @@ use Carbon\Carbon;
//Models
use App\Models\Esi\EsiToken;
use App\Models\Esi\EsiScope;
use App\Models\Jobs\JobSendEveMail;
//Jobs
use App\Jobs\ProcessSendEveMailJob;
@@ -41,14 +40,10 @@ class Esi {
$check = EsiScope::where(['character_id' => $charId, 'scope' => $scope])->count();
if($check == 0) {
//Compose a mail to send to the user if the scope is not found
$mail = new JobSendEveMail;
$mail->sender = $config['primary'];
$mail->subject = 'W4RP Services - Incorrect ESI Scope';
$mail->body = "Please register on https://services.w4rp.space with the scope: " . $scope;
$mail->recipient = (int)$charId;
$mail->recipient_type = 'character';
$subject = 'W4RP Services - Incorrect ESI Scope';
$body = "Please register on https://services.w4rp.space with the scope: " . $scope;
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail')->delay(Carbon::now()->addSeconds(5));
ProcessSendEveMailJob::dispatch($body, (int)$charId, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(5));
return false;
}

View File

@@ -16,7 +16,6 @@ use App\Jobs\ProcessSendEveMailJob;
//Models
use App\Models\Esi\EsiToken;
use App\Models\Esi\EsiScope;
use App\Models\Jobs\JobSendEveMail;
//Library
use App\Library\Esi\Esi;

View File

@@ -1,19 +0,0 @@
<?php
namespace App\Models\Jobs;
use Illuminate\Database\Eloquent\Model;
class JobSendEveMail extends Model
{
//Timestamps
public $timestamps = false;
protected $fillable = [
'sender',
'recipient',
'recipient_type',
'subject',
'body',
];
}