mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Add webhooks for restore
This commit is contained in:
parent
0e4dd61684
commit
d5cf303000
@ -96,6 +96,22 @@ class Webhook extends BaseModel
|
||||
|
||||
const EVENT_ARCHIVE_EXPENSE = 39;
|
||||
|
||||
const EVENT_RESTORE_PAYMENT = 40;
|
||||
|
||||
const EVENT_RESTORE_INVOICE = 41;
|
||||
|
||||
const EVENT_RESTORE_QUOTE = 42;
|
||||
|
||||
const EVENT_RESTORE_CREDIT = 43;
|
||||
|
||||
const EVENT_RESTORE_TASK = 44;
|
||||
|
||||
const EVENT_RESTORE_CLIENT = 45;
|
||||
|
||||
const EVENT_RESTORE_PROJECT = 46;
|
||||
|
||||
const EVENT_RESTORE_EXPENSE = 47;
|
||||
|
||||
|
||||
|
||||
|
||||
@ -139,7 +155,15 @@ class Webhook extends BaseModel
|
||||
self::EVENT_ARCHIVE_CREDIT,
|
||||
self::EVENT_ARCHIVE_QUOTE,
|
||||
self::EVENT_ARCHIVE_INVOICE,
|
||||
self::EVENT_ARCHIVE_PAYMENT
|
||||
self::EVENT_ARCHIVE_PAYMENT,
|
||||
self::EVENT_RESTORE_EXPENSE,
|
||||
self::EVENT_RESTORE_PROJECT,
|
||||
self::EVENT_RESTORE_CLIENT,
|
||||
self::EVENT_RESTORE_TASK,
|
||||
self::EVENT_RESTORE_CREDIT,
|
||||
self::EVENT_RESTORE_QUOTE,
|
||||
self::EVENT_RESTORE_INVOICE,
|
||||
self::EVENT_RESTORE_PAYMENT
|
||||
|
||||
];
|
||||
|
||||
|
@ -162,6 +162,76 @@ class BaseRepository
|
||||
|
||||
if (class_exists($className)) {
|
||||
event(new $className($entity, $fromDeleted, $entity->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
if ($entity instanceof Invoice){
|
||||
$subscriptions = Webhook::where('company_id', $entity->company_id)
|
||||
->where('event_id', Webhook::EVENT_RESTORE_INVOICE)
|
||||
->exists();
|
||||
|
||||
if ($subscriptions) {
|
||||
WebhookHandler::dispatch(Webhook::EVENT_RESTORE_INVOICE, $entity, $entity->company, 'client')->delay(now()->addSeconds(2));
|
||||
}}
|
||||
elseif ($entity instanceof Quote){
|
||||
$subscriptions = Webhook::where('company_id', $entity->company_id)
|
||||
->where('event_id', Webhook::EVENT_RESTORE_QUOTE)
|
||||
->exists();
|
||||
|
||||
if ($subscriptions) {
|
||||
WebhookHandler::dispatch(Webhook::EVENT_RESTORE_QUOTE, $entity, $entity->company, 'client')->delay(now()->addSeconds(2));
|
||||
}}
|
||||
elseif ($entity instanceof Credit){
|
||||
$subscriptions = Webhook::where('company_id', $entity->company_id)
|
||||
->where('event_id', Webhook::EVENT_RESTORE_CREDIT)
|
||||
->exists();
|
||||
|
||||
if ($subscriptions) {
|
||||
WebhookHandler::dispatch(Webhook::EVENT_RESTORE_CREDIT, $entity, $entity->company, 'client')->delay(now()->addSeconds(2));
|
||||
}
|
||||
}
|
||||
elseif ($entity instanceof Client){
|
||||
$subscriptions = Webhook::where('company_id', $entity->company_id)
|
||||
->where('event_id', Webhook::EVENT_RESTORE_CLIENT)
|
||||
->exists();
|
||||
|
||||
if ($subscriptions) {
|
||||
WebhookHandler::dispatch(Webhook::EVENT_RESTORE_CLIENT, $entity, $entity->company, 'client')->delay(now()->addSeconds(2));
|
||||
}
|
||||
}
|
||||
elseif ($entity instanceof Expense){
|
||||
$subscriptions = Webhook::where('company_id', $entity->company_id)
|
||||
->where('event_id', Webhook::EVENT_RESTORE_EXPENSE)
|
||||
->exists();
|
||||
|
||||
if ($subscriptions) {
|
||||
WebhookHandler::dispatch(Webhook::EVENT_RESTORE_EXPENSE, $entity, $entity->company, 'client')->delay(now()->addSeconds(2));
|
||||
}
|
||||
}
|
||||
elseif ($entity instanceof Project){
|
||||
$subscriptions = Webhook::where('company_id', $entity->company_id)
|
||||
->where('event_id', Webhook::EVENT_RESTORE_PROJECT)
|
||||
->exists();
|
||||
|
||||
if ($subscriptions) {
|
||||
WebhookHandler::dispatch(Webhook::EVENT_RESTORE_PROJECT, $entity, $entity->company, 'client')->delay(now()->addSeconds(2));
|
||||
}
|
||||
}
|
||||
elseif ($entity instanceof Task){
|
||||
$subscriptions = Webhook::where('company_id', $entity->company_id)
|
||||
->where('event_id', Webhook::EVENT_RESTORE_TASK)
|
||||
->exists();
|
||||
|
||||
if ($subscriptions) {
|
||||
WebhookHandler::dispatch(Webhook::EVENT_RESTORE_TASK, $entity, $entity->company, 'client')->delay(now()->addSeconds(2));
|
||||
}
|
||||
}
|
||||
elseif ($entity instanceof Payment){
|
||||
$subscriptions = Webhook::where('company_id', $entity->company_id)
|
||||
->where('event_id', Webhook::EVENT_RESTORE_PAYMENT)
|
||||
->exists();
|
||||
|
||||
if ($subscriptions) {
|
||||
WebhookHandler::dispatch(Webhook::EVENT_RESTORE_PAYMENT, $entity, $entity->company, 'client')->delay(now()->addSeconds(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user