diff --git a/app/Console/Commands/calculatemarkettax.php b/app/Console/Commands/calculatemarkettax.php
index dddc20fff..62bdb498c 100644
--- a/app/Console/Commands/calculatemarkettax.php
+++ b/app/Console/Commands/calculatemarkettax.php
@@ -112,7 +112,7 @@ class CalculateMarketTax extends Command
$mail->recipient_type = 'character';
$mail->save();
- SendEveMail::dispatch($mail)->delay(now()->addSeconds(5));
+ SendEveMail::dispatch($mail);
/*
diff --git a/app/Jobs/SendEveMail.php b/app/Jobs/SendEveMail.php
index 12b289ac8..ee48b9c74 100644
--- a/app/Jobs/SendEveMail.php
+++ b/app/Jobs/SendEveMail.php
@@ -91,7 +91,7 @@ class SendEveMail implements ShouldQueue
'character_id'=> 93738489,
]);
} catch(RequestFailedException $e) {
- //
+ return null;
}
$mail->delete();
diff --git a/app/Library/Finances/Helper/FinanceHelper.php b/app/Library/Finances/Helper/FinanceHelper.php
index e1fafd858..1d75344a4 100644
--- a/app/Library/Finances/Helper/FinanceHelper.php
+++ b/app/Library/Finances/Helper/FinanceHelper.php
@@ -8,9 +8,11 @@
namespace App\Library\Finances\Helper;
use DB;
+use App\Jobs\SendEveMail;
use App\Models\User\UserToCorporation;
use App\Models\Esi\EsiToken;
+use App\Models\Mail\EveMail;
use App\Library\Esi\Esi;
use App\Library\Finances\MarketTax;
@@ -33,33 +35,16 @@ class FinanceHelper {
$scope = EsiScope::where(['character_id' => $charId, 'scope' => 'esi-wallet.read_corporation_wallet.v1'])->get(['scope']);
//If the token is not found, send the user an eve mail, and just exit out of the function
if(!isset($token[0]->refresh_token) || !isset($scope[0]->scope)) {
- //Retrieve the token for main character to send mails from
- $token = EsiToken::where(['character_id' => 93738489])->first();
+ //Register a mail to be dispatched as a job
+ $mail = new EveMail;
+ $mail->sender = 93738489;
+ $mail->subject = 'W4RP Services ESI API';
+ $mail->body = 'You need to register an ESI API on the services site for esi-wallet.read_corporation_wallet.v1
This is also labeled Corporation Wallets';
+ $mail->recipient = (int)$info->character_id;
+ $mail->recipient_type = 'character';
+ $mail->save();
- $config = config('esi');
- $authentication = new EsiAuthentication([
- 'client_id' => $config['client_id'],
- 'secret' => $config['secret'],
- 'refresh_token' => $token->refresh_token,
- ]);
- $esi = new Eseye($authentication);
- $subject = 'Services ESI API';
- $body = 'You need to register an ESI API on the services site for esi-wallet.read_corporation_wallet.v1
This is also labeled Corporation Wallets';
- try {
- $esi->setBody([
- 'approved_cost' => 50000,
- 'body' => $body,
- 'recipients' => [[
- 'recipient_id' => (int)$info->character_id,
- 'recipient_type' => 'character',
- ]],
- 'subject' => $subject,
- ])->invoke('post', '/characters/{character_id}/mail/', [
- 'character_id'=> 93738489,
- ]);
- } catch(RequestFailedException $e) {
- return null;
- }
+ SendEveMail::dispatch($mail);
return null;
}