mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Refactor for admin links
This commit is contained in:
parent
c3189183a5
commit
6e847888fc
@ -40,8 +40,6 @@ class CreditCreatedNotification implements ShouldQueue
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
// $first_notification_sent = true;
|
||||
|
||||
$credit = $event->credit;
|
||||
|
||||
/* We loop through each user and determine whether they need to be notified */
|
||||
@ -49,12 +47,6 @@ class CreditCreatedNotification implements ShouldQueue
|
||||
/* The User */
|
||||
$user = $company_user->user;
|
||||
|
||||
$use_react_link = false;
|
||||
|
||||
if($company_user->react_settings && property_exists($company_user->react_settings, 'react_notification_link') && $company_user->react_settings->react_notification_link) {
|
||||
$use_react_link = true;
|
||||
}
|
||||
|
||||
/* This is only here to handle the alternate message channels - ie Slack */
|
||||
// $notification = new EntitySentNotification($event->invitation, 'credit');
|
||||
|
||||
@ -66,7 +58,7 @@ class CreditCreatedNotification implements ShouldQueue
|
||||
unset($methods[$key]);
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new NinjaMailer((new EntityCreatedObject($credit, 'credit', $use_react_link))->build());
|
||||
$nmo->mailable = new NinjaMailer((new EntityCreatedObject($credit, 'credit', $company_user->portalType()))->build());
|
||||
$nmo->company = $credit->company;
|
||||
$nmo->settings = $credit->company->settings;
|
||||
$nmo->to_user = $user;
|
||||
|
@ -48,16 +48,11 @@ class InvoiceCreatedNotification implements ShouldQueue
|
||||
foreach ($event->company->company_users as $company_user) {
|
||||
/* The User */
|
||||
$user = $company_user->user;
|
||||
$use_react_link = false;
|
||||
|
||||
|
||||
if (! $user) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(isset($company_user->react_settings->react_notification_link) && $company_user->react_settings->react_notification_link) {
|
||||
$use_react_link = true;
|
||||
}
|
||||
|
||||
/* This is only here to handle the alternate message channels - ie Slack */
|
||||
// $notification = new EntitySentNotification($event->invitation, 'invoice');
|
||||
|
||||
@ -69,7 +64,7 @@ class InvoiceCreatedNotification implements ShouldQueue
|
||||
unset($methods[$key]);
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new NinjaMailer((new EntityCreatedObject($invoice, 'invoice', $use_react_link))->build());
|
||||
$nmo->mailable = new NinjaMailer((new EntityCreatedObject($invoice, 'invoice', $company_user->portalType()))->build());
|
||||
$nmo->company = $invoice->company;
|
||||
$nmo->settings = $invoice->company->settings;
|
||||
$nmo->to_user = $user;
|
||||
|
@ -45,7 +45,6 @@ class PurchaseOrderCreatedListener implements ShouldQueue
|
||||
|
||||
$purchase_order = $event->purchase_order;
|
||||
|
||||
|
||||
/* We loop through each user and determine whether they need to be notified */
|
||||
foreach ($event->company->company_users as $company_user) {
|
||||
/* The User */
|
||||
@ -55,13 +54,6 @@ class PurchaseOrderCreatedListener implements ShouldQueue
|
||||
continue;
|
||||
}
|
||||
|
||||
$use_react_link = false;
|
||||
|
||||
if($company_user->react_settings && property_exists($company_user->react_settings, 'react_notification_link') && $company_user->react_settings->react_notification_link) {
|
||||
$use_react_link = true;
|
||||
nlog("inside");
|
||||
}
|
||||
|
||||
/* This is only here to handle the alternate message channels - ie Slack */
|
||||
// $notification = new EntitySentNotification($event->invitation, 'purchase_order');
|
||||
|
||||
@ -73,7 +65,7 @@ class PurchaseOrderCreatedListener implements ShouldQueue
|
||||
unset($methods[$key]);
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new NinjaMailer((new EntityCreatedObject($purchase_order, 'purchase_order', $use_react_link))->build());
|
||||
$nmo->mailable = new NinjaMailer((new EntityCreatedObject($purchase_order, 'purchase_order', $company_user->portalType()))->build());
|
||||
$nmo->company = $purchase_order->company;
|
||||
$nmo->settings = $purchase_order->company->settings;
|
||||
|
||||
|
@ -56,7 +56,7 @@ class QuoteCreatedNotification implements ShouldQueue
|
||||
|
||||
$use_react_link = false;
|
||||
|
||||
if($company_user->react_settings && property_exists($company_user->react_settings, 'react_notification_link') && $company_user->react_settings->react_notification_link) {
|
||||
if(isset($company_user->react_settings->react_notification_link) && $company_user->react_settings->react_notification_link) {
|
||||
$use_react_link = true;
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ class QuoteCreatedNotification implements ShouldQueue
|
||||
unset($methods[$key]);
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new NinjaMailer((new EntityCreatedObject($quote, 'quote'))->build());
|
||||
$nmo->mailable = new NinjaMailer((new EntityCreatedObject($quote, 'quote', $company_user->portalType()))->build());
|
||||
$nmo->company = $quote->company;
|
||||
$nmo->settings = $quote->company->settings;
|
||||
|
||||
|
@ -196,8 +196,22 @@ class CompanyUser extends Pivot
|
||||
|
||||
public function scopeAuthCompany($query)
|
||||
{
|
||||
$query->where('company_id', auth()->user()->companyId());
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
$query->where('company_id', $user->companyId());
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the notifications should be React of Flutter links
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function portalType():bool
|
||||
{
|
||||
return isset($this->react_settings->react_notification_link) && $this->react_settings->react_notification_link;
|
||||
}
|
||||
|
||||
}
|
@ -118,7 +118,7 @@ class InvoiceInvitation extends BaseModel
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function entity()
|
||||
public function getEntity()
|
||||
{
|
||||
return $this->belongsTo(Invoice::class)->withTrashed();
|
||||
}
|
||||
|
@ -194,8 +194,16 @@ class PurchaseOrderInvitation extends BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
public function getAdminLink() :string
|
||||
public function getAdminLink($use_react_link = false) :string
|
||||
{
|
||||
return $this->getLink().'?silent=true';
|
||||
return $use_react_link ? $this->getReactLink() : $this->getLink().'?silent=true';
|
||||
}
|
||||
|
||||
private function getReactLink(): string
|
||||
{
|
||||
$entity_type = Str::snake(class_basename($this->entityType()));
|
||||
|
||||
return config('ninja.app_url')."/#/{$entity_type}/{$this->{$entity_type}->hashed_id}/edit";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -148,6 +148,6 @@ trait Inviteable
|
||||
{
|
||||
$entity_type = Str::snake(class_basename($this->entityType()));
|
||||
|
||||
return config('ninja.app_url')."/#/{$entity_type}/{$this->invoice->hashed_id}/edit";
|
||||
return config('ninja.react_url')."/{$entity_type}s/{$this->{$entity_type}->hashed_id}/edit";
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ return [
|
||||
'web_url' => 'https://www.invoiceninja.com',
|
||||
'admin_token' => env('NINJA_ADMIN_TOKEN', ''),
|
||||
'license_url' => 'https://app.invoiceninja.com',
|
||||
'react_url' => 'https://app.invoicing.co',
|
||||
'react_url' => env('REACT_URL', 'https://app.invoicing.co'),
|
||||
'production' => env('NINJA_PROD', false),
|
||||
'license' => env('NINJA_LICENSE', ''),
|
||||
'version_url' => 'https://pdf.invoicing.co/api/version',
|
||||
|
Loading…
x
Reference in New Issue
Block a user