Add settings-gated appointment notifications and fix Bird key validation.
Deploy Ladill Care / deploy (push) Successful in 58s

Patients can be SMS/email notified on booking and video schedule when enabled in Settings. Bird validation now accepts only lsk_live_ keys, strips paste artifacts, and surfaces the platform error.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-13 13:31:28 +00:00
co-authored by Cursor
parent 7c33432dc9
commit d13d460e32
10 changed files with 625 additions and 15 deletions
@@ -5,8 +5,10 @@ namespace App\Http\Controllers\Care;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Care\Concerns\ScopesToAccount;
use App\Models\Branch;
use App\Services\Care\AppointmentPatientNotifier;
use App\Services\Care\AuditLogger;
use App\Services\Care\CarePermissions;
use App\Services\Messaging\MessagingCredentialsService;
use App\Services\Queue\QueueClient;
use App\Support\OrganizationBranding;
use Illuminate\Http\RedirectResponse;
@@ -17,11 +19,12 @@ class SettingsController extends Controller
{
use ScopesToAccount;
public function edit(Request $request): View
public function edit(Request $request, MessagingCredentialsService $credentials): View
{
$this->authorizeAbility($request, 'settings.view');
$organization = $this->organization($request);
$canManage = app(CarePermissions::class)->can($this->member($request), 'settings.manage');
$credential = $credentials->forOrganization($organization);
$branchCount = Branch::owned($this->ownerRef($request))
->where('organization_id', $organization->id)
@@ -31,6 +34,8 @@ class SettingsController extends Controller
'organization' => $organization,
'canManage' => $canManage,
'branchCount' => $branchCount,
'messagingSmsReady' => $credential->hasValidSms(),
'messagingEmailReady' => $credential->hasValidBird(),
'facilityTypes' => [
'clinic' => 'Clinic',
'hospital' => 'Hospital',
@@ -53,6 +58,10 @@ class SettingsController extends Controller
'logo' => ['nullable', 'image', 'mimes:jpeg,png,jpg,webp,svg', 'max:2048'],
'remove_logo' => ['nullable', 'boolean'],
'queue_integration_enabled' => ['nullable', 'boolean'],
'notify_appointment_booked_sms' => ['nullable', 'boolean'],
'notify_appointment_booked_email' => ['nullable', 'boolean'],
'notify_video_scheduled_sms' => ['nullable', 'boolean'],
'notify_video_scheduled_email' => ['nullable', 'boolean'],
]);
$settings = $organization->settings ?? [];
@@ -60,9 +69,13 @@ class SettingsController extends Controller
$settings['facility_type'] = $validated['facility_type'];
$wantsQueue = $request->boolean('queue_integration_enabled');
$hadQueue = (bool) data_get($settings, 'queue_integration_enabled', false);
$settings['queue_integration_enabled'] = $wantsQueue;
$settings[AppointmentPatientNotifier::SETTING_BOOKED_SMS] = $request->boolean('notify_appointment_booked_sms');
$settings[AppointmentPatientNotifier::SETTING_BOOKED_EMAIL] = $request->boolean('notify_appointment_booked_email');
$settings[AppointmentPatientNotifier::SETTING_VIDEO_SMS] = $request->boolean('notify_video_scheduled_sms');
$settings[AppointmentPatientNotifier::SETTING_VIDEO_EMAIL] = $request->boolean('notify_video_scheduled_email');
if ($wantsQueue && $queue->configured()) {
$branch = Branch::owned($owner)->where('organization_id', $organization->id)->orderBy('name')->first();
try {