mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
fix: getVendor / getClient
This commit is contained in:
parent
f0d61a8261
commit
b7a29bb2c7
@ -14,6 +14,7 @@ namespace App\Http\Controllers;
|
|||||||
use App\Jobs\Brevo\ProcessBrevoInboundWebhook;
|
use App\Jobs\Brevo\ProcessBrevoInboundWebhook;
|
||||||
use App\Jobs\Brevo\ProcessBrevoWebhook;
|
use App\Jobs\Brevo\ProcessBrevoWebhook;
|
||||||
use App\Libraries\MultiDB;
|
use App\Libraries\MultiDB;
|
||||||
|
use App\Models\Company;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
@ -77,6 +78,9 @@ class BrevoController extends BaseController
|
|||||||
/**
|
/**
|
||||||
* Process Brevo Inbound Webhook.
|
* Process Brevo Inbound Webhook.
|
||||||
*
|
*
|
||||||
|
* IMPORTANT NOTICE: brevo strips old sended emails, therefore only current attachements are present
|
||||||
|
*
|
||||||
|
* IMPORTANT NOTICE: brevo saves the message and attachemnts for later retrieval, therefore we can process it within a async job for performance reasons
|
||||||
*
|
*
|
||||||
* @OA\Post(
|
* @OA\Post(
|
||||||
* path="/api/v1/brevo_inbound_webhook",
|
* path="/api/v1/brevo_inbound_webhook",
|
||||||
@ -187,17 +191,18 @@ class BrevoController extends BaseController
|
|||||||
$input = $request->all();
|
$input = $request->all();
|
||||||
|
|
||||||
// validation for client mail credentials by recipient
|
// validation for client mail credentials by recipient
|
||||||
// if ($request->has('company')) {
|
if ($request->has('company_key')) {
|
||||||
// if (!($request->has('token')))
|
if (!($request->has('token')))
|
||||||
// return response()->json(['message' => 'Unauthorized'], 403);
|
return response()->json(['message' => 'Unauthorized'], 403);
|
||||||
|
|
||||||
// $company = MultiDB::findAndSetDbByCompanyId($request->has('company'));
|
MultiDB::findAndSetDbByCompanyKey($request->has('company_key'));
|
||||||
// $company_brevo_secret = $company?->settings?->email_sending_method === 'client_brevo' && $company?->settings?->brevo_secret ? $company->settings->brevo_secret : null;
|
$company = Company::where('company_key', $request->has('company_key'))->first();
|
||||||
// if (!$company || !$company_brevo_secret || $request->get('token') !== $company_brevo_secret)
|
$company_brevo_secret = $company?->settings?->email_sending_method === 'client_brevo' && $company?->settings?->brevo_secret ? $company->settings->brevo_secret : null;
|
||||||
// return response()->json(['message' => 'Unauthorized'], 403);
|
if (!$company || !$company_brevo_secret || $request->get('token') !== $company_brevo_secret)
|
||||||
|
return response()->json(['message' => 'Unauthorized'], 403);
|
||||||
|
|
||||||
// } else if (!($request->has('token') && $request->get('token') == config('services.brevo.secret')))
|
} else if (!($request->has('token') && $request->get('token') == config('services.brevo.secret')))
|
||||||
// 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.');
|
Log::info('Failed: Message could not be parsed, because required parameters are missing.');
|
||||||
|
@ -80,6 +80,10 @@ class MailgunController extends BaseController
|
|||||||
/**
|
/**
|
||||||
* Process Mailgun Inbound Webhook.
|
* Process Mailgun Inbound Webhook.
|
||||||
*
|
*
|
||||||
|
* IMPORTANT NOTICE: mailgun does NOT strip old sended emails, therefore all past attachements are present
|
||||||
|
*
|
||||||
|
* IMPORTANT NOTICE: mailgun saves the message and attachemnts for later retrieval, therefore we can process it within a async job for performance reasons
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* @OA\Post(
|
* @OA\Post(
|
||||||
* path="/api/v1/mailgun_inbound_webhook",
|
* path="/api/v1/mailgun_inbound_webhook",
|
||||||
|
@ -78,6 +78,9 @@ class PostMarkController extends BaseController
|
|||||||
/**
|
/**
|
||||||
* Process Postmark Webhook.
|
* Process Postmark Webhook.
|
||||||
*
|
*
|
||||||
|
* IMPORTANT NOTICE: postmark does NOT strip old sended emails, therefore also all past attachements are present
|
||||||
|
*
|
||||||
|
* IMPORTANT NOTICE: postmark does not saves attachements for later retrieval, therefore we cannot process it within a async job
|
||||||
*
|
*
|
||||||
* @OA\Post(
|
* @OA\Post(
|
||||||
* path="/api/v1/postmark_inbound_webhook",
|
* path="/api/v1/postmark_inbound_webhook",
|
||||||
|
@ -33,6 +33,9 @@ class ProcessBrevoInboundWebhook implements ShouldQueue
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* IMPORTANT NOTICE: brevo strips old sended emails, therefore only current attachements are present
|
||||||
|
*
|
||||||
* $input consists of json/serialized-array:
|
* $input consists of json/serialized-array:
|
||||||
*
|
*
|
||||||
* array (
|
* array (
|
||||||
@ -111,8 +114,6 @@ class ProcessBrevoInboundWebhook implements ShouldQueue
|
|||||||
/**
|
/**
|
||||||
* Execute the job.
|
* Execute the job.
|
||||||
*
|
*
|
||||||
* TODO: insert Mail from Storage
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
|
@ -40,6 +40,8 @@ class ProcessMailgunInboundWebhook implements ShouldQueue
|
|||||||
/**
|
/**
|
||||||
* Execute the job.
|
* Execute the job.
|
||||||
*
|
*
|
||||||
|
* IMPORTANT NOTICE: mailgun does NOT strip old sended emails, therefore all past attachements are present
|
||||||
|
*
|
||||||
* Mail from Storage
|
* Mail from Storage
|
||||||
* {
|
* {
|
||||||
* "Content-Type": "multipart/related; boundary=\"00000000000022bfbe0613e8b7f5\"",
|
* "Content-Type": "multipart/related; boundary=\"00000000000022bfbe0613e8b7f5\"",
|
||||||
|
@ -237,16 +237,18 @@ class InboundMailEngine
|
|||||||
private function getClient(Company $company, InboundMail $email)
|
private function getClient(Company $company, InboundMail $email)
|
||||||
{
|
{
|
||||||
$clientContact = ClientContact::where("company_id", $company->id)->where("email", $email->from)->first();
|
$clientContact = ClientContact::where("company_id", $company->id)->where("email", $email->from)->first();
|
||||||
$client = $clientContact->client();
|
if (!$clientContact)
|
||||||
|
return null;
|
||||||
|
|
||||||
return $client;
|
return $clientContact->client();
|
||||||
}
|
}
|
||||||
private function getVendor(Company $company, InboundMail $email)
|
private function getVendor(Company $company, InboundMail $email)
|
||||||
{
|
{
|
||||||
$vendorContact = VendorContact::where("company_id", $company->id)->where("email", $email->from)->first();
|
$vendorContact = VendorContact::where("company_id", $company->id)->where("email", $email->from)->first();
|
||||||
$vendor = $vendorContact->vendor();
|
if (!$vendorContact)
|
||||||
|
return null;
|
||||||
|
|
||||||
return $vendor;
|
return $vendorContact->vendor();
|
||||||
}
|
}
|
||||||
private function logBlocked(Company $company, string $data)
|
private function logBlocked(Company $company, string $data)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user