| @@ -46,20 +46,24 @@ | ||
| 46 | 46 | |
| 47 | 47 | add_action('fluent_booking/after_booking_scheduled', [$this, 'maybeHandleGlobalIntegration'], 10, 2); |
| 48 | 48 | add_action('fluent_booking/booking_schedule_cancelled', [$this, 'maybeHandleGlobalIntegration'], 10, 2); |
| 49 | 49 | add_action('fluent_booking/booking_schedule_completed', [$this, 'maybeHandleGlobalIntegration'], 10, 2); |
| 50 | - | |
| 50 | + add_action('fluent_booking/booking_schedule_rejected', [$this, 'maybeHandleGlobalIntegration'], 10, 2); | |
| 51 | + add_action('fluent_booking/booking_schedule_no_show', [$this, 'maybeHandleGlobalIntegration'], 10, 2); | |
| 52 | + add_action('fluent_booking/after_booking_rescheduled', [$this, 'checkGlobalIntegration'], 10, 3); | |
| 51 | 53 | } |
| 52 | 54 | |
| 53 | - public function maybeHandleGlobalIntegration($booking, $calendarSlot) | |
| 55 | + public function maybeHandleGlobalIntegration($booking, $calendarSlot, $status = null) | |
| 54 | 56 | { |
| 57 | + $status = $status ?: $booking->status; | |
| 55 | 58 | |
| 56 | - $status = $booking->status; | |
| 57 | - | |
| 58 | 59 | $maps = [ |
| 59 | - 'scheduled' => 'after_booking_scheduled', | |
| 60 | - 'cancelled' => 'booking_schedule_cancelled', | |
| 61 | - 'completed' => 'booking_schedule_completed' | |
| 60 | + 'scheduled' => 'after_booking_scheduled', | |
| 61 | + 'cancelled' => 'booking_schedule_cancelled', | |
| 62 | + 'completed' => 'booking_schedule_completed', | |
| 63 | + 'rescheduled' => 'after_booking_rescheduled', | |
| 64 | + 'rejected' => 'booking_schedule_rejected', | |
| 65 | + 'no_show' => 'booking_schedule_no_show', | |
| 62 | 66 | ]; |
| 63 | 67 | |
| 64 | 68 | if (!isset($maps[$status])) { |
| 65 | 69 | return false; |
| @@ -90,9 +94,8 @@ | ||
| 90 | 94 | } |
| 91 | 95 | |
| 92 | 96 | // Now we have to filter the feeds which are enabled |
| 93 | 97 | $enabledFeeds = $this->globalNotificationService->getEnabledFeeds($feeds, $booking); |
| 94 | - | |
| 95 | 98 | if (!$enabledFeeds) { |
| 96 | 99 | return false; |
| 97 | 100 | } |
| 98 | 101 | |
| @@ -99,9 +102,9 @@ | ||
| 99 | 102 | foreach ($enabledFeeds as $feed) { |
| 100 | 103 | |
| 101 | 104 | $enabledTriggers = Arr::get($feed, 'settings.event_trigger', []); |
| 102 | 105 | |
| 103 | - if (!$enabledTriggers && !in_array($targetHook, $enabledTriggers)) { | |
| 106 | + if (!$enabledTriggers || !in_array($targetHook, $enabledTriggers)) { | |
| 104 | 107 | continue; |
| 105 | 108 | } |
| 106 | 109 | |
| 107 | 110 | // We will decide if this feed will run on async or sync |
| @@ -122,6 +125,11 @@ | ||
| 122 | 125 | } |
| 123 | 126 | } |
| 124 | 127 | |
| 125 | 128 | return true; |
| 129 | + } | |
| 130 | + | |
| 131 | + public function checkGlobalIntegration($booking, $oldBooking, $calendarEvent) | |
| 132 | + { | |
| 133 | + return $this->maybeHandleGlobalIntegration($booking, $calendarEvent, 'rescheduled'); | |
| 126 | 134 | } |
| 127 | 135 | } |