Catches for system log not existing

This commit is contained in:
David Bomba 2024-07-30 16:19:07 +10:00
parent bce4fddcb1
commit 0923b1f7a1
6 changed files with 23 additions and 19 deletions

View File

@ -41,7 +41,7 @@ class ClientFilters extends QueryFilters
*/
public function balance(string $balance = ''): Builder
{
if (strlen($balance) == 0) {
if (strlen($balance) == 0 || count(explode(":", $balance)) < 2) {
return $this->builder;
}

View File

@ -35,7 +35,7 @@ class MailgunWebhookController extends BaseController
}
if(\hash_equals(\hash_hmac('sha256', $input['signature']['timestamp'] . $input['signature']['token'], config('services.mailgun.webhook_signing_key')), $input['signature']['signature'])) {
ProcessMailgunWebhook::dispatch($request->all())->delay(10);
ProcessMailgunWebhook::dispatch($request->all())->delay(rand(2,10));
}
return response()->json(['message' => 'Success.'], 200);

View File

@ -297,12 +297,13 @@ class NinjaMailerJob implements ShouldQueue
$t->replace(Ninja::transformTranslations($this->nmo->settings));
/** Force free/trials onto specific mail driver */
// if(Ninja::isHosted() && !$this->company->account->isPaid())
// {
// $this->mailer = 'mailgun';
// $this->setHostedMailgunMailer();
// return $this;
// }
if($this->mailer == 'default' && $this->company->account->isNewHostedAccount()) {
$this->mailer = 'mailgun';
$this->setHostedMailgunMailer();
return $this;
}
if (Ninja::isHosted() && $this->company->account->isPaid() && $this->nmo->settings->email_sending_method == 'default') {
//check if outlook.
@ -391,7 +392,7 @@ class NinjaMailerJob implements ShouldQueue
$smtp_username = $company->smtp_username ?? '';
$smtp_password = $company->smtp_password ?? '';
$smtp_encryption = $company->smtp_encryption ?? 'tls';
$smtp_local_domain = strlen($company->smtp_local_domain) > 2 ? $company->smtp_local_domain : null;
$smtp_local_domain = strlen($company->smtp_local_domain ?? '') > 2 ? $company->smtp_local_domain : null;
$smtp_verify_peer = $company->smtp_verify_peer ?? true;
if(strlen($smtp_host) <= 1 ||

View File

@ -181,7 +181,7 @@ class ProcessMailgunWebhook implements ShouldQueue
$sl = $this->getSystemLog($this->request['MessageID']);
/** Prevents Gmail tracking from firing inappropriately */
if($this->request['signature']['timestamp'] < $sl->log['signature']['timestamp'] + 3) {
if(!$sl || $this->request['signature']['timestamp'] < $sl->log['signature']['timestamp'] + 3) {
return;
}

View File

@ -364,16 +364,19 @@ class Account extends BaseModel
return $this->isProClient() && $this->isPaid();
}
public function isNewHostedAccount()
{
return Ninja::isHosted() && Carbon::createFromTimestamp($this->created_at)->diffInWeeks() <= 2;
}
public function isTrial(): bool
{
if (!Ninja::isNinja()) {
return false;
}
//@27-01-2024 - updates for logic around trials
return !$this->plan_paid && $this->trial_started && Carbon::parse($this->trial_started)->addDays(14)->gte(now()->subHours(12));
// $plan_details = $this->getPlanDetails();
// return $plan_details && $plan_details['trial'];
}
public function startTrial($plan): void

View File

@ -526,11 +526,11 @@ class Email implements ShouldQueue
{
/** Force free/trials onto specific mail driver */
// if(Ninja::isHosted() && !$this->company->account->isPaid()) {
// $this->mailer = 'mailgun';
// $this->setHostedMailgunMailer();
// return $this;
// }
if($this->mailer == 'default' && $this->company->account->isNewHostedAccount()) {
$this->mailer = 'mailgun';
$this->setHostedMailgunMailer();
return $this;
}
if (Ninja::isHosted() && $this->company->account->isPaid() && $this->email_object->settings->email_sending_method == 'default') {
@ -619,7 +619,7 @@ class Email implements ShouldQueue
$smtp_username = $company->smtp_username ?? '';
$smtp_password = $company->smtp_password ?? '';
$smtp_encryption = $company->smtp_encryption ?? 'tls';
$smtp_local_domain = strlen($company->smtp_local_domain) > 2 ? $company->smtp_local_domain : null;
$smtp_local_domain = strlen($company->smtp_local_domain ?? '') > 2 ? $company->smtp_local_domain : null;
$smtp_verify_peer = $company->smtp_verify_peer ?? true;
if(strlen($smtp_host) <= 1 ||