1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Minor fixes and addition functionality

This commit is contained in:
Lars Kusch 2023-01-29 14:43:57 +01:00
parent 8fce15750b
commit 949722ff57
9 changed files with 118 additions and 13 deletions

View File

@ -79,25 +79,25 @@ class Webhook extends BaseModel
const EVENT_PROJECT_DELETE = 30;
const EVENT_UPDATE_PAYMENT = 31;
const EVENT_ARCHIVE_PAYMENT = 32;
const EVENT_ARCHIVE_INVOICE = 33;
const EVENT_ARCHIVE_QUOTE = 34;
const EVENT_ARCHIVE_CREDIT = 35;
const EVENT_ARCHIVE_TASK = 36;
const EVENT_ARCHIVE_CLIENT = 37;
const EVENT_ARCHIVE_PROJECT = 38;
const EVENT_ARCHIVE_EXPENSE = 39;
public static $valid_events = [
@ -138,9 +138,9 @@ class Webhook extends BaseModel
self::EVENT_ARCHIVE_TASK,
self::EVENT_ARCHIVE_CREDIT,
self::EVENT_ARCHIVE_QUOTE,
self::VENT_ARCHIVE_INVOICE,
self::EVENT_ARCHIVE_INVOICE,
self::EVENT_ARCHIVE_PAYMENT
];
protected $fillable = [

View File

@ -89,4 +89,15 @@ class ClientObserver
{
//
}
public function archived(Client $client)
{
$subscriptions = Webhook::where('company_id', $client->company->id)
->where('event_id', Webhook::EVENT_ARCHIVE_CLIENT)
->exists();
if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_ARCHIVE_CLIENT, $client, $client->company)->delay(now()->addSeconds(2));
}
}
}

View File

@ -91,4 +91,20 @@ class CreditObserver
{
//
}
/**
* Handle the client "archive" event.
*
* @param Credit $credit
* @return void
*/
public function archived(Credit $credit)
{
$subscriptions = Webhook::where('company_id', $credit->company->id)
->where('event_id', Webhook::EVENT_ARCHIVE_CREDIT)
->exists();
if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_ARCHIVE_CREDIT, $credit, $credit->company)->delay(now()->addSeconds(2));
}
}
}

View File

@ -89,4 +89,20 @@ class ExpenseObserver
{
//
}
/**
* Handle the expense "archive" event.
*
* @param Expense $expense
* @return void
*/
public function archived(Expense $expense)
{
$subscriptions = Webhook::where('company_id', $expense->company->id)
->where('event_id', Webhook::EVENT_ARCHIVE_EXPENSE)
->exists();
if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_ARCHIVE_EXPENSE, $expense, $expense->company)->delay(now()->addSeconds(2));
}
}
}

View File

@ -93,4 +93,18 @@ class InvoiceObserver
{
//
}
/**
* @param Invoice $invoice
* @return void
*/
public function archived(Invoice $invoice){
$subscriptions = Webhook::where('company_id', $invoice->company_id)
->where('event_id', Webhook::EVENT_ARCHIVE_INVOICE)
->exists();
if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_ARCHIVE_INVOICE, $invoice, $invoice->company, 'client')->delay(now()->addSeconds(2));
}
}
}

View File

@ -89,4 +89,14 @@ class PaymentObserver
{
//
}
public function archived(Payment $payment)
{
$subscriptions = Webhook::where('company_id', $payment->company->id)
->where('event_id', Webhook::EVENT_ARCHIVE_PAYMENT)
->exists();
if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_ARCHIVE_PAYMENT, $payment, $payment->company, 'invoices,client')->delay(now()->addSeconds(20));
}
}
}

View File

@ -92,4 +92,21 @@ class ProjectObserver
{
//
}
/**
* Handle the product "archived" event.
*
* @param Project $project
* @return void
*/
public function archived(Project $project)
{
$subscriptions = Webhook::where('company_id', $project->company_id)
->where('event_id', Webhook::EVENT_ARCHIVE_PROJECT)
->exists();
if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_ARCHIVE_PROJECT, $project, $project->company, 'client')->delay(now()->addSeconds(2));
}
}
}

View File

@ -93,4 +93,15 @@ class QuoteObserver
{
//
}
public function archived(Quote $quote)
{
$subscriptions = Webhook::where('company_id', $quote->company->id)
->where('event_id', Webhook::EVENT_ARCHIVE_QUOTE)
->exists();
if ($subscriptions) {
$quote->load('client');
WebhookHandler::dispatch(Webhook::EVENT_ARCHIVE_QUOTE, $quote, $quote->company, 'client')->delay(now()->addSeconds(2));
}
}
}

View File

@ -89,4 +89,14 @@ class TaskObserver
{
//
}
public function archived(Task $task)
{
$subscriptions = Webhook::where('company_id', $task->company->id)
->where('event_id', Webhook::EVENT_ARCHIVE_TASK)
->exists();
if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_ARCHIVE_TASK, $task, $task->company)->delay(now()->addSeconds(2));
}
}
}