mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-07 21:54:39 -04:00
replace Log::info with nlog
This commit is contained in:
parent
f530d95f59
commit
b2110de110
@ -194,14 +194,14 @@ class BrevoController extends BaseController
|
|||||||
return response()->json(['message' => 'Unauthorized'], 403);
|
return response()->json(['message' => 'Unauthorized'], 403);
|
||||||
|
|
||||||
if (!array_key_exists('items', $input)) {
|
if (!array_key_exists('items', $input)) {
|
||||||
Log::info('Failed: Message could not be parsed, because required parameters are missing.');
|
nlog('Failed: Message could not be parsed, because required parameters are missing.');
|
||||||
return response()->json(['message' => 'Failed. Invalid Parameters.'], 400);
|
return response()->json(['message' => 'Failed. Invalid Parameters.'], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($input["items"] as $item) {
|
foreach ($input["items"] as $item) {
|
||||||
|
|
||||||
if (!array_key_exists('Recipients', $item) || !array_key_exists('MessageId', $item)) {
|
if (!array_key_exists('Recipients', $item) || !array_key_exists('MessageId', $item)) {
|
||||||
Log::info('Failed: Message could not be parsed, because required parameters are missing. At least one item was invalid.');
|
nlog('Failed: Message could not be parsed, because required parameters are missing. At least one item was invalid.');
|
||||||
return response()->json(['message' => 'Failed. Invalid Parameters. At least one item was invalid.'], 400);
|
return response()->json(['message' => 'Failed. Invalid Parameters. At least one item was invalid.'], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ class MailgunController extends BaseController
|
|||||||
$input = $request->all();
|
$input = $request->all();
|
||||||
|
|
||||||
if (!array_key_exists('sender', $input) || !array_key_exists('recipient', $input) || !array_key_exists('message-url', $input)) {
|
if (!array_key_exists('sender', $input) || !array_key_exists('recipient', $input) || !array_key_exists('message-url', $input)) {
|
||||||
Log::info('Failed: Message could not be parsed, because required parameters are missing. Please ensure contacting this api-endpoint with a store & notify operation instead of a forward operation!');
|
nlog('Failed: Message could not be parsed, because required parameters are missing. Please ensure contacting this api-endpoint with a store & notify operation instead of a forward operation!');
|
||||||
return response()->json(['message' => 'Failed. Missing Parameters. Use store and notify!'], 400);
|
return response()->json(['message' => 'Failed. Missing Parameters. Use store and notify!'], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ class PostMarkController extends BaseController
|
|||||||
return response()->json(['message' => 'Unauthorized'], 403);
|
return response()->json(['message' => 'Unauthorized'], 403);
|
||||||
|
|
||||||
if (!(array_key_exists("MessageStream", $input) && $input["MessageStream"] == "inbound") || !array_key_exists("To", $input) || !array_key_exists("From", $input) || !array_key_exists("MessageID", $input)) {
|
if (!(array_key_exists("MessageStream", $input) && $input["MessageStream"] == "inbound") || !array_key_exists("To", $input) || !array_key_exists("From", $input) || !array_key_exists("MessageID", $input)) {
|
||||||
Log::info('Failed: Message could not be parsed, because required parameters are missing.');
|
nlog('Failed: Message could not be parsed, because required parameters are missing.');
|
||||||
return response()->json(['message' => 'Failed. Missing/Invalid Parameters.'], 400);
|
return response()->json(['message' => 'Failed. Missing/Invalid Parameters.'], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ class PostMarkController extends BaseController
|
|||||||
|
|
||||||
$company = MultiDB::findAndSetDbByExpenseMailbox($input["To"]);
|
$company = MultiDB::findAndSetDbByExpenseMailbox($input["To"]);
|
||||||
if (!$company) {
|
if (!$company) {
|
||||||
Log::info('[PostmarkInboundWebhook] unknown Expense Mailbox occured while handling an inbound email from mailgun: ' . $input["To"]);
|
nlog('[PostmarkInboundWebhook] unknown Expense Mailbox occured while handling an inbound email from mailgun: ' . $input["To"]);
|
||||||
$inboundEngine->saveMeta($input["From"], $input["To"], true); // important to save this, to protect from spam
|
$inboundEngine->saveMeta($input["From"], $input["To"], true); // important to save this, to protect from spam
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ class ProcessBrevoInboundWebhook implements ShouldQueue
|
|||||||
// match company
|
// match company
|
||||||
$company = MultiDB::findAndSetDbByExpenseMailbox($recipient);
|
$company = MultiDB::findAndSetDbByExpenseMailbox($recipient);
|
||||||
if (!$company) {
|
if (!$company) {
|
||||||
Log::info('[ProcessBrevoInboundWebhook] unknown Expense Mailbox occured while handling an inbound email from brevo: ' . $recipient);
|
nlog('[ProcessBrevoInboundWebhook] unknown Expense Mailbox occured while handling an inbound email from brevo: ' . $recipient);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ class ProcessBrevoInboundWebhook implements ShouldQueue
|
|||||||
|
|
||||||
} catch (\Error $e) {
|
} catch (\Error $e) {
|
||||||
if (config('services.brevo.secret')) {
|
if (config('services.brevo.secret')) {
|
||||||
Log::info("[ProcessBrevoInboundWebhook] Error while downloading with company credentials, we try to use default credentials now...");
|
nlog("[ProcessBrevoInboundWebhook] Error while downloading with company credentials, we try to use default credentials now...");
|
||||||
|
|
||||||
$brevo = new InboundParsingApi(null, Configuration::getDefaultConfiguration()->setApiKey("api-key", config('services.brevo.secret')));
|
$brevo = new InboundParsingApi(null, Configuration::getDefaultConfiguration()->setApiKey("api-key", config('services.brevo.secret')));
|
||||||
$attachment = $brevo->getInboundEmailAttachment($attachment["DownloadToken"]);
|
$attachment = $brevo->getInboundEmailAttachment($attachment["DownloadToken"]);
|
||||||
|
@ -180,7 +180,7 @@ class ProcessMailgunInboundWebhook implements ShouldQueue
|
|||||||
// match company
|
// match company
|
||||||
$company = MultiDB::findAndSetDbByExpenseMailbox($to);
|
$company = MultiDB::findAndSetDbByExpenseMailbox($to);
|
||||||
if (!$company) {
|
if (!$company) {
|
||||||
Log::info('[ProcessMailgunInboundWebhook] unknown Expense Mailbox occured while handling an inbound email from mailgun: ' . $to);
|
nlog('[ProcessMailgunInboundWebhook] unknown Expense Mailbox occured while handling an inbound email from mailgun: ' . $to);
|
||||||
$this->engine->saveMeta($from, $to, true); // important to save this, to protect from spam
|
$this->engine->saveMeta($from, $to, true); // important to save this, to protect from spam
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ class ProcessMailgunInboundWebhook implements ShouldQueue
|
|||||||
$mail = json_decode(file_get_contents($messageUrl));
|
$mail = json_decode(file_get_contents($messageUrl));
|
||||||
} catch (\Error $e) {
|
} catch (\Error $e) {
|
||||||
if (config('services.mailgun.secret')) {
|
if (config('services.mailgun.secret')) {
|
||||||
Log::info("[ProcessMailgunInboundWebhook] Error while downloading with company credentials, we try to use default credentials now...");
|
nlog("[ProcessMailgunInboundWebhook] Error while downloading with company credentials, we try to use default credentials now...");
|
||||||
|
|
||||||
$credentials = config('services.mailgun.domain') . ":" . config('services.mailgun.secret') . "@";
|
$credentials = config('services.mailgun.domain') . ":" . config('services.mailgun.secret') . "@";
|
||||||
$messageUrl = explode("|", $this->input)[2];
|
$messageUrl = explode("|", $this->input)[2];
|
||||||
@ -253,7 +253,7 @@ class ProcessMailgunInboundWebhook implements ShouldQueue
|
|||||||
|
|
||||||
} catch (\Error $e) {
|
} catch (\Error $e) {
|
||||||
if (config('services.mailgun.secret')) {
|
if (config('services.mailgun.secret')) {
|
||||||
Log::info("[ProcessMailgunInboundWebhook] Error while downloading with company credentials, we try to use default credentials now...");
|
nlog("[ProcessMailgunInboundWebhook] Error while downloading with company credentials, we try to use default credentials now...");
|
||||||
|
|
||||||
$credentials = config('services.mailgun.domain') . ":" . config('services.mailgun.secret') . "@";
|
$credentials = config('services.mailgun.domain') . ":" . config('services.mailgun.secret') . "@";
|
||||||
$url = $attachment->url;
|
$url = $attachment->url;
|
||||||
|
@ -69,11 +69,11 @@ class InboundMailEngine
|
|||||||
{
|
{
|
||||||
// invalid email
|
// invalid email
|
||||||
if (!filter_var($from, FILTER_VALIDATE_EMAIL)) {
|
if (!filter_var($from, FILTER_VALIDATE_EMAIL)) {
|
||||||
Log::info('E-Mail blocked, because from e-mail has the wrong format: ' . $from);
|
nlog('E-Mail blocked, because from e-mail has the wrong format: ' . $from);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!filter_var($to, FILTER_VALIDATE_EMAIL)) {
|
if (!filter_var($to, FILTER_VALIDATE_EMAIL)) {
|
||||||
Log::info('E-Mail blocked, because to e-mail has the wrong format: ' . $from);
|
nlog('E-Mail blocked, because to e-mail has the wrong format: ' . $from);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,14 +85,14 @@ class InboundMailEngine
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (in_array($domain, $this->globalBlacklistDomains)) {
|
if (in_array($domain, $this->globalBlacklistDomains)) {
|
||||||
Log::info('E-Mail blocked, because the domain was found on globalBlocklistDomains: ' . $from);
|
nlog('E-Mail blocked, because the domain was found on globalBlocklistDomains: ' . $from);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (in_array($domain, $this->globalWhitelistSenders)) {
|
if (in_array($domain, $this->globalWhitelistSenders)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (in_array($from, $this->globalBlacklistSenders)) {
|
if (in_array($from, $this->globalBlacklistSenders)) {
|
||||||
Log::info('E-Mail blocked, because the email was found on globalBlocklistEmails: ' . $from);
|
nlog('E-Mail blocked, because the email was found on globalBlocklistEmails: ' . $from);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,13 +103,13 @@ class InboundMailEngine
|
|||||||
// sender occured in more than 500 emails in the last 12 hours
|
// sender occured in more than 500 emails in the last 12 hours
|
||||||
$senderMailCountTotal = Cache::get('inboundMailCountSender:' . $from, 0);
|
$senderMailCountTotal = Cache::get('inboundMailCountSender:' . $from, 0);
|
||||||
if ($senderMailCountTotal >= 5000) {
|
if ($senderMailCountTotal >= 5000) {
|
||||||
Log::info('E-Mail blocked permanent, because the sender sended more than ' . $senderMailCountTotal . ' emails in the last 12 hours: ' . $from);
|
nlog('E-Mail blocked permanent, because the sender sended more than ' . $senderMailCountTotal . ' emails in the last 12 hours: ' . $from);
|
||||||
$this->blockSender($from);
|
$this->blockSender($from);
|
||||||
$this->saveMeta($from, $to);
|
$this->saveMeta($from, $to);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ($senderMailCountTotal >= 1000) {
|
if ($senderMailCountTotal >= 1000) {
|
||||||
Log::info('E-Mail blocked, because the sender sended more than ' . $senderMailCountTotal . ' emails in the last 12 hours: ' . $from);
|
nlog('E-Mail blocked, because the sender sended more than ' . $senderMailCountTotal . ' emails in the last 12 hours: ' . $from);
|
||||||
$this->saveMeta($from, $to);
|
$this->saveMeta($from, $to);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ class InboundMailEngine
|
|||||||
// sender sended more than 50 emails to the wrong mailbox in the last 6 hours
|
// sender sended more than 50 emails to the wrong mailbox in the last 6 hours
|
||||||
$senderMailCountUnknownRecipent = Cache::get('inboundMailCountSenderUnknownRecipent:' . $from, 0);
|
$senderMailCountUnknownRecipent = Cache::get('inboundMailCountSenderUnknownRecipent:' . $from, 0);
|
||||||
if ($senderMailCountUnknownRecipent >= 50) {
|
if ($senderMailCountUnknownRecipent >= 50) {
|
||||||
Log::info('E-Mail blocked, because the sender sended more than ' . $senderMailCountUnknownRecipent . ' emails to the wrong mailbox in the last 6 hours: ' . $from);
|
nlog('E-Mail blocked, because the sender sended more than ' . $senderMailCountUnknownRecipent . ' emails to the wrong mailbox in the last 6 hours: ' . $from);
|
||||||
$this->saveMeta($from, $to);
|
$this->saveMeta($from, $to);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ class InboundMailEngine
|
|||||||
// wrong recipent occurs in more than 100 emails in the last 12 hours, so the processing is blocked
|
// wrong recipent occurs in more than 100 emails in the last 12 hours, so the processing is blocked
|
||||||
$mailCountUnknownRecipent = Cache::get('inboundMailCountUnknownRecipent:' . $to, 0); // @turbo124 maybe use many to save resources in case of spam with multiple to addresses each time
|
$mailCountUnknownRecipent = Cache::get('inboundMailCountUnknownRecipent:' . $to, 0); // @turbo124 maybe use many to save resources in case of spam with multiple to addresses each time
|
||||||
if ($mailCountUnknownRecipent >= 200) {
|
if ($mailCountUnknownRecipent >= 200) {
|
||||||
Log::info('E-Mail blocked, because anyone sended more than ' . $mailCountUnknownRecipent . ' emails to the wrong mailbox in the last 12 hours. Current sender was blocked as well: ' . $from);
|
nlog('E-Mail blocked, because anyone sended more than ' . $mailCountUnknownRecipent . ' emails to the wrong mailbox in the last 12 hours. Current sender was blocked as well: ' . $from);
|
||||||
$this->blockSender($from);
|
$this->blockSender($from);
|
||||||
$this->saveMeta($from, $to);
|
$this->saveMeta($from, $to);
|
||||||
return true;
|
return true;
|
||||||
@ -263,7 +263,7 @@ class InboundMailEngine
|
|||||||
}
|
}
|
||||||
private function logBlocked(Company $company, string $data)
|
private function logBlocked(Company $company, string $data)
|
||||||
{
|
{
|
||||||
Log::info("[InboundMailEngine][company:" . $company->id . "] " . $data);
|
nlog("[InboundMailEngine][company:" . $company->id . "] " . $data);
|
||||||
|
|
||||||
(
|
(
|
||||||
new SystemLogger(
|
new SystemLogger(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user