remove vendor email colums

This commit is contained in:
paulwer 2024-04-03 08:33:40 +02:00
parent f0ba86b699
commit f0d61a8261
4 changed files with 11 additions and 31 deletions

View File

@ -187,17 +187,17 @@ 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')) {
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')); // $company = MultiDB::findAndSetDbByCompanyId($request->has('company'));
$company_brevo_secret = $company?->settings?->email_sending_method === 'client_brevo' && $company?->settings?->brevo_secret ? $company->settings->brevo_secret : null; // $company_brevo_secret = $company?->settings?->email_sending_method === 'client_brevo' && $company?->settings?->brevo_secret ? $company->settings->brevo_secret : null;
if (!$company || !$company_brevo_secret || $request->get('token') !== $company_brevo_secret) // if (!$company || !$company_brevo_secret || $request->get('token') !== $company_brevo_secret)
return response()->json(['message' => 'Unauthorized'], 403); // 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.');

View File

@ -270,9 +270,6 @@ class PostMarkController extends BaseController
public function inboundWebhook(Request $request) public function inboundWebhook(Request $request)
{ {
Log::info($request->all());
Log::info($request->headers);
$input = $request->all(); $input = $request->all();
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)) {

View File

@ -224,8 +224,6 @@ class InboundMailEngine
return true; return true;
// from vendors // from vendors
if ($company->inbound_mailbox_allow_vendors && $company->vendors()->where("invoicing_email", $email->from)->orWhere("invoicing_domain", $domain)->exists())
return true;
if ($company->inbound_mailbox_allow_vendors && VendorContact::where("company_id", $company->id)->where("email", $email->from)->exists()) if ($company->inbound_mailbox_allow_vendors && VendorContact::where("company_id", $company->id)->where("email", $email->from)->exists())
return true; return true;
@ -238,9 +236,6 @@ class InboundMailEngine
} }
private function getClient(Company $company, InboundMail $email) private function getClient(Company $company, InboundMail $email)
{ {
// $parts = explode('@', $email->from);
// $domain = array_pop($parts);
$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(); $client = $clientContact->client();
@ -248,16 +243,8 @@ class InboundMailEngine
} }
private function getVendor(Company $company, InboundMail $email) private function getVendor(Company $company, InboundMail $email)
{ {
$parts = explode('@', $email->from);
$domain = array_pop($parts);
$vendor = Vendor::where("company_id", $company->id)->where('invoicing_email', $email->from)->first();
if ($vendor == null)
$vendor = Vendor::where("company_id", $company->id)->where("invoicing_domain", $domain)->first();
if ($vendor == null) {
$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(); $vendor = $vendorContact->vendor();
}
return $vendor; return $vendor;
} }

View File

@ -23,10 +23,6 @@ return new class extends Migration {
$table->text("inbound_mailbox_blacklist_domains")->nullable(); $table->text("inbound_mailbox_blacklist_domains")->nullable();
$table->text("inbound_mailbox_blacklist_senders")->nullable(); $table->text("inbound_mailbox_blacklist_senders")->nullable();
}); });
Schema::table('vendors', function (Blueprint $table) {
$table->string("invoicing_email")->nullable();
$table->string("invoicing_domain")->nullable();
});
} }
/** /**