feat(notifications): add admin notification acknowledgement on booking state changes

- Add AcknowledgePendingBookingNotification helper for acknowledging notifications
- ConfirmBookingHandler: acknowledge pending notification when booking confirmed
- Cancel handlers: acknowledge pending notification and only create cancelled_booking notification if booking was not in pending status
- Add user_notification_preferences table with email, sms, push enabled flags
- Update cancellation logic to check original status before creating notifications
This commit is contained in:
2026-02-17 21:38:50 +00:00
parent 105831eeb3
commit bbb273c192
4 changed files with 194 additions and 18 deletions
+15
View File
@@ -351,6 +351,21 @@ CREATE TABLE admin_notifications (
created_at TIMESTAMPTZ DEFAULT NOW()
);
-- User notification preferences for future user notification system
CREATE TABLE user_notification_preferences (
id SERIAL PRIMARY KEY,
user_id CHAR(12) REFERENCES users(id) ON DELETE CASCADE,
notification_type VARCHAR(50) NOT NULL,
email_enabled BOOLEAN DEFAULT true,
sms_enabled BOOLEAN DEFAULT true,
push_enabled BOOLEAN DEFAULT true,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW(),
UNIQUE(user_id, notification_type)
);
CREATE INDEX idx_user_notification_preferences_user_id ON user_notification_preferences(user_id);
CREATE INDEX idx_payments_booking_id_status ON payments(booking_id, status);
CREATE INDEX idx_bookings_start_time_status ON bookings(start_time, status);
CREATE INDEX idx_users_created_at ON users(created_at);