1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 23:22:52 +01:00

changes related to allow_clients

This commit is contained in:
paulwer 2024-03-25 07:08:41 +01:00
parent 157037f56f
commit 1db0350273
2 changed files with 7 additions and 12 deletions

View File

@ -118,7 +118,7 @@ class ProcessBrevoInboundWebhook implements ShouldQueue
public function handle()
{
// brevo defines recipients as array to enable webhook processing as batches, we check all of them
// brevo defines recipients as array, we check all of them, to be sure
foreach ($this->input["Recipients"] as $recipient) {
// match company

View File

@ -229,15 +229,13 @@ class InboundMailEngine
if ($this->company->inbound_mailbox_allow_company_users && $this->company->users()->where("email", $this->email->from)->exists())
return true;
// from vendors (if active)
// from vendors
if ($this->company->inbound_mailbox_allow_vendors && $this->company->vendors()->where("invoicing_email", $this->email->from)->orWhere("invoicing_domain", $domain)->exists())
return true;
if ($this->company->inbound_mailbox_allow_vendors && $this->company->vendors()->contacts()->where("email", $this->email->from)->exists())
return true;
// from clients (if active)
if ($this->company->inbound_mailbox_allow_clients && $this->company->clients()->where("invoicing_email", $this->email->from)->orWhere("invoicing_domain", $domain)->exists())
return true;
// from clients
if ($this->company->inbound_mailbox_allow_clients && $this->company->clients()->contacts()->where("email", $this->email->from)->exists())
return true;
@ -246,14 +244,11 @@ class InboundMailEngine
}
private function getClient()
{
$parts = explode('@', $this->email->from);
$domain = array_pop($parts);
// $parts = explode('@', $this->email->from);
// $domain = array_pop($parts);
$client = Client::where("company_id", $this->company->id)->where("email", $domain)->first();
if ($client == null) {
$clientContact = ClientContact::where("company_id", $this->company->id)->where("email", $this->email->from)->first();
$client = $clientContact->client();
}
$clientContact = ClientContact::where("company_id", $this->company->id)->where("email", $this->email->from)->first();
$client = $clientContact->client();
return $client;
}