$conflicts description => first night of the portal occupation * @return list the conflicts e-mailed now (new ones and due reminders) */ public function handle(Channel $channel, array $conflicts): array { $new = []; $reminders = []; foreach ($conflicts as $description => $startsOn) { $message = $this->inbox->post( InboxMessageKind::ChannelConflict, $channel->id.':'.sha1($description), 'Mögliche Doppelbuchung über '.$channel->name, $description, $channel, OccupancyCalendar::getUrl(['monat' => $startsOn->format('Y-m'), 'wohnung' => $channel->property_id]), ); if ($message?->wasRecentlyCreated) { $new[] = $description; } elseif ($message) { $reminders[] = $description; } } if ($new !== [] || $reminders !== []) { rescue(fn () => Mail::to(Settings::notificationRecipients())->send(new ChannelConflict($channel, $new, $reminders))); } return [...$new, ...$reminders]; } }