Add environment variable to check if the server runs job or not
- to prevent job run more than once
This commit is contained in:
@@ -253,3 +253,4 @@ ONEWAYSMS_AUTH_USER=APIUK330HDAFO
|
|||||||
ONEWAYSMS_AUTH_PASS=APIUK330HDAFOUK330
|
ONEWAYSMS_AUTH_PASS=APIUK330HDAFOUK330
|
||||||
|
|
||||||
ADMIN_PHONE_NUMBER=60178916936
|
ADMIN_PHONE_NUMBER=60178916936
|
||||||
|
ACTIVE_JOB_SERVER=true
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class WhatsappUnsoldCommodityNotification extends Job
|
|||||||
$message = $settings->where('key', 'message')->first()->value;
|
$message = $settings->where('key', 'message')->first()->value;
|
||||||
$isAllKomoditiSold = KomuditiPurchase::on('mysql7')->latest()->first()->unit_komuditi === 0;
|
$isAllKomoditiSold = KomuditiPurchase::on('mysql7')->latest()->first()->unit_komuditi === 0;
|
||||||
$isWabotCredentialNotComplete = env('WABOT_API') === null || env('WABOT_INSTANCES_ID') === null || env('WABOT_TOKEN_KEYS') === null;
|
$isWabotCredentialNotComplete = env('WABOT_API') === null || env('WABOT_INSTANCES_ID') === null || env('WABOT_TOKEN_KEYS') === null;
|
||||||
|
$isNotActiveJobServer = env('ACTIVE_JOB_SERVER') !== 'true';
|
||||||
|
|
||||||
$pic_key = 'pic_' . strtolower(Carbon::now()->englishDayOfWeek);
|
$pic_key = 'pic_' . strtolower(Carbon::now()->englishDayOfWeek);
|
||||||
$pic = json_decode($settings->where('key', $pic_key)->first()->value);
|
$pic = json_decode($settings->where('key', $pic_key)->first()->value);
|
||||||
@@ -49,6 +50,10 @@ class WhatsappUnsoldCommodityNotification extends Job
|
|||||||
}
|
}
|
||||||
}, $pic);
|
}, $pic);
|
||||||
|
|
||||||
|
if ($isNotActiveJobServer) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ($isWabotCredentialNotComplete) {
|
if ($isWabotCredentialNotComplete) {
|
||||||
Log::error('Wabot credential not complete');
|
Log::error('Wabot credential not complete');
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user