updated hardcoded character with env variable

This commit is contained in:
2019-06-25 00:01:28 -05:00
parent 079169d8aa
commit 0f7e2d5bad
11 changed files with 46 additions and 14 deletions

1
.env
View File

@@ -45,6 +45,7 @@ ESI_CLIENT_ID=e5848fea3618427a8ee0dccb6a04fc62
ESI_SECRET_KEY=TdnNGRM8RTNSifZdaIc9yHTTkYPgYEEXHRIbT6oY
ESI_USERAGENT='W4RP Services'
ESI_CALLBACK_URI='http://services.w4rp.space/callback'
ESI_PRIMARY_CHAR=93738489
EVEONLINE_CLIENT_ID=e5848fea3618427a8ee0dccb6a04fc62
EVEONLINE_CLIENT_SECRET=TdnNGRM8RTNSifZdaIc9yHTTkYPgYEEXHRIbT6oY

View File

@@ -59,21 +59,23 @@ class GetAssetsCommand extends Command
//Add the entry into the jobs table saying the job is starting
$task->SetStartStatus();
//Setup the esi authentication container
$config = config('esi');
//Declare some variables
$charId = 93738849;
$corpId = 98287666;
//ESI Scope Check
$esiHelper = new Esi();
$assetScope = $esiHelper->HaveEsiScope(93738489, 'esi-assets.read_corporation_assets.v1');
$assetScope = $esiHelper->HaveEsiScope($config['primary'], 'esi-assets.read_corporation_assets.v1');
if($assetScope == false) {
Log::critical("Scope check for esi failed.");
return null;
}
//Setup the esi authentication container
$config = config('esi');
//Get the refresh token from the database
$token = EsiToken::where(['character_id' => $charId])->get(['refresh_token']);
$authentication = new EsiAuthentication([

View File

@@ -56,14 +56,17 @@ class HoldingFinancesCommand extends Command
//Setup the Finances container
$finance = new FinanceHelper();
//Get the esi configuration
$config = config('esi');
//Get the total pages for the journal for the holding corporation
$pages = $finance->GetJournalPageCount(1, 93738489);
$pages = $finance->GetJournalPageCount(1, $config['primary']);
//Dispatch a single job for each page to process
for($i = 1; $i <= $pages; $i++) {
$job = new JobProcessWalletJournal;
$job->division = 1;
$job->charId = 93738489;
$job->charId = $config['primary'];
$job->page = $i;
ProcessWalletJournalJob::dispatch($job)->onQueue('journal');
}

View File

@@ -72,6 +72,9 @@ class MoonMailerCommand extends Command
$today->minute = 0;
$today->hour = 0;
//Get the esi configuration
$config = config('esi');
//Get all contacts from the rentals group
$contacts = MoonRental::select('Contact')->groupBy('Contact')->get();
@@ -99,7 +102,7 @@ class MoonMailerCommand extends Command
//Dispatch the mail job
$mail = new EveMail;
$mail->sender = 93738489;
$mail->sender = $config['primary'];
$mail->subject = "Warped Intentions Moon Rental Payment Due";
$mail->body = $body;
$mail->recipient = (int)$contact->Contact;

View File

@@ -60,8 +60,11 @@ class GetStructuresCommand extends Command
//Add the entry into the jobs table saying the job is starting
$task->SetStartStatus();
//Get the esi config
$config = config('esi');
//Declare some variables
$charId = 93738489;
$charId = $config['primary'];
$corpId = 98287666;
$sHelper = new StructureHelper($charId, $corpId);
$structures = null;

View File

@@ -140,6 +140,9 @@ class ContractAdminController extends Controller
$mail = new Mail;
$tries = 1;
//Get the esi config
$config = config('esi');
$contract = Contract::where(['contract_id' => $request->contract_id])->first()->toArray();
$bid = Bid::where(['id' => $request->accept, 'contract_id' => $request->contract_id])->first()->toArray();
@@ -158,7 +161,7 @@ class ContractAdminController extends Controller
$mail->recipient_type = 'character';
$mail->recipient = $bid['character_id'];
$mail->body = $body;
$mail->sender = 93738489;
$mail->sender = $config['primary'];
//Dispatch the mail job
SendEveMailJob::dispatch($mail)->onQueue('mail');
@@ -187,10 +190,13 @@ class ContractAdminController extends Controller
//Get all the users with a specific permission set
$users = UserPermission::where(['permission' => 'contract.canbid'])->get()->toArray();
//Get the esi config
$config = config('esi');
//Cycle through the users with the correct permission and send a mail to go out with the queue system.
foreach($users as $user) {
$mail = new EveMail;
$mail->sender = 93738489;
$mail->sender = $config['primary'];
$mail->subject = 'New Alliance Contract Available';
$mail->recipient = $user['character_id'];
$mail->recipient_type = 'character';

View File

@@ -69,8 +69,11 @@ class SendEveMailJob implements ShouldQueue
*/
public function handle()
{
//Get the esi configuration
$config = config('esi');
//Retrieve the token for main character to send mails from
$token = EsiToken::where(['character_id'=> 93738489])->get();
$token = EsiToken::where(['character_id'=> $config['primary']])->get();
//Create the ESI authentication container
$config = config('esi');

View File

@@ -35,6 +35,9 @@ class Esi {
* @return true,false
*/
public function HaveEsiScope($charId, $scope) {
//Get the esi config
$config = config('esi');
//Check for an esi scope
$checks = DB::table('EsiScopes')->where('character_id', $charId)->get();
foreach($checks as $check) {
@@ -44,7 +47,7 @@ class Esi {
}
$mail = new EveMail;
$mail->sender = 93738489;
$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;

View File

@@ -16,8 +16,11 @@ use Seat\Eseye\Exceptions\RequestFailedException;
class Mail {
public function SendMail($recipient, $rType, $subject, $body) {
//Get the esi config
$config = config('esi');
//Retrieve the token for main character to send mails from
$token = EsiToken::where(['character_id' => 93738489])->first();
$token = EsiToken::where(['character_id' => $config['primary']])->first();
//Create the ESI authentication container
$config = config('esi');
$authentication = new EsiAuthentication([
@@ -36,7 +39,7 @@ class Mail {
]],
'subject' => $subject,
])->invoke('post', '/characters/{character_id}/mail/', [
'character_id'=> 93738489,
'character_id'=> $config['primary'],
]);
} catch(RequestFailedException $e) {
return 1;

View File

@@ -316,10 +316,14 @@ class FinanceHelper {
}
private function TokenNotFound($token, $scope, $charId) {
//Get the esi config
$config = config('esi');
if(!isset($token[0]->refresh_token) || !isset($scope[0]->scope)) {
//Register a mail to be dispatched as a job
$mail = new EveMail;
$mail->sender = 93738489;
$mail->sender = $config['primary'];
$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<br>This is also labeled Corporation Wallets';
$mail->recipient = (int)$charId;

View File

@@ -4,5 +4,6 @@
'secret' => env('ESI_SECRET_KEY'),
'useragent' => env('ESI_USERAGENT'),
'callback' => env('ESI_CALLBACK_URI'),
'primary' => env('ESI_PRIMARY_CHAR'),
];
?>