feat: Add hotel and webhook endpoint management

- Introduced Hotel and WebhookEndpoint models to manage hotel configurations and webhook settings.
- Implemented sync_config_to_database function to synchronize hotel data from configuration to the database.
- Added HotelService for accessing hotel configurations and managing customer data.
- Created WebhookProcessor interface and specific processors for handling different webhook types (Wix form and generic).
- Enhanced webhook processing logic to handle incoming requests and create/update reservations and customers.
- Added logging for better traceability of operations related to hotels and webhooks.
This commit is contained in:
Jonas Linter
2025-11-25 12:05:48 +01:00
parent da85098d8d
commit 8d144a761c
8 changed files with 1706 additions and 262 deletions

View File

@@ -392923,3 +392923,74 @@ DETAIL: Key (hotel_id, guest_id)=(39054_001, 28275) is not present in table "co
[SQL: INSERT INTO conversions (reservation_id, customer_id, hashed_customer_id, hotel_id, guest_id, pms_reservation_id, reservation_number, reservation_date, creation_time, reservation_type, booking_channel, advertising_medium, advertising_partner, advertising_campagne, directly_attributable, guest_matched, created_at, updated_at) VALUES ($1::INTEGER, $2::INTEGER, $3::INTEGER, $4::VARCHAR, $5::VARCHAR, $6::VARCHAR, $7::VARCHAR, $8::DATE, $9::TIMESTAMP WITH TIME ZONE, $10::VARCHAR, $11::VARCHAR, $12::VARCHAR, $13::VARCHAR, $14::VARCHAR, $15::BOOLEAN, $16::BOOLEAN, $17::TIMESTAMP WITH TIME ZONE, $18::TIMESTAMP WITH TIME ZONE) RETURNING conversions.id]
[parameters: (None, None, None, '39054_001', '28275', '833', '532', datetime.date(2014, 5, 24), datetime.datetime(2014, 5, 24, 13, 16, 27), 'reservation', None, None, None, None, False, False, datetime.datetime(2025, 11, 19, 16, 23, 58, 58789), datetime.datetime(2025, 11, 19, 16, 23, 58, 58791))]
(Background on this error at: https://sqlalche.me/e/20/gkpj)
2025-11-25 12:02:21 - root - INFO - Logging to file: config/alpinebits.log
2025-11-25 12:02:21 - root - INFO - Logging configured at INFO level
2025-11-25 12:02:21 - alpine_bits_python.notification_service - INFO - Registered notification backend: pushover
2025-11-25 12:02:21 - alpine_bits_python.notification_manager - INFO - Registered pushover backend with priority 0
2025-11-25 12:02:21 - alpine_bits_python.notification_manager - INFO - Notification service configured with backends: ['pushover']
2025-11-25 12:02:21 - alpine_bits_python.api - INFO - Application startup initiated (primary_worker=True)
2025-11-25 12:02:21 - alpine_bits_python.db - INFO - Configured database schema: alpinebits
2025-11-25 12:02:21 - alpine_bits_python.db - INFO - Setting PostgreSQL search_path to: alpinebits,public
2025-11-25 12:02:21 - alpine_bits_python.alpinebits_server - INFO - Initializing action instance for AlpineBitsActionName.OTA_HOTEL_NOTIF_REPORT
2025-11-25 12:02:21 - alpine_bits_python.alpinebits_server - INFO - Initializing action instance for AlpineBitsActionName.OTA_PING
2025-11-25 12:02:21 - alpine_bits_python.alpinebits_server - INFO - Initializing action instance for AlpineBitsActionName.OTA_HOTEL_RES_NOTIF_GUEST_REQUESTS
2025-11-25 12:02:21 - alpine_bits_python.alpinebits_server - INFO - Initializing action instance for AlpineBitsActionName.OTA_READ
2025-11-25 12:02:21 - alpine_bits_python.webhook_processor - INFO - Registered webhook processor: wix_form
2025-11-25 12:02:21 - alpine_bits_python.webhook_processor - INFO - Registered webhook processor: generic
2025-11-25 12:02:21 - alpine_bits_python.webhook_processor - INFO - Webhook processors initialized
2025-11-25 12:02:21 - alpine_bits_python.api - INFO - Webhook processors initialized
2025-11-25 12:02:21 - alpine_bits_python.api - INFO - Hotel 39054_001 has no push_endpoint configured
2025-11-25 12:02:21 - alpine_bits_python.api - INFO - Hotel 135 has no push_endpoint configured
2025-11-25 12:02:21 - alpine_bits_python.api - INFO - Hotel 39052_001 has no push_endpoint configured
2025-11-25 12:02:21 - alpine_bits_python.api - INFO - Hotel 39040_001 has no push_endpoint configured
2025-11-25 12:02:21 - alpine_bits_python.api - INFO - Running startup tasks (primary worker)...
2025-11-25 12:03:13 - root - INFO - Logging to file: config/alpinebits.log
2025-11-25 12:03:13 - root - INFO - Logging configured at INFO level
2025-11-25 12:03:13 - alpine_bits_python.notification_service - INFO - Registered notification backend: pushover
2025-11-25 12:03:13 - alpine_bits_python.notification_manager - INFO - Registered pushover backend with priority 0
2025-11-25 12:03:13 - alpine_bits_python.notification_manager - INFO - Notification service configured with backends: ['pushover']
2025-11-25 12:03:13 - alpine_bits_python.api - INFO - Application startup initiated (primary_worker=True)
2025-11-25 12:03:13 - alpine_bits_python.db - INFO - Configured database schema: alpinebits
2025-11-25 12:03:13 - alpine_bits_python.db - INFO - Setting PostgreSQL search_path to: alpinebits,public
2025-11-25 12:03:13 - alpine_bits_python.alpinebits_server - INFO - Initializing action instance for AlpineBitsActionName.OTA_HOTEL_NOTIF_REPORT
2025-11-25 12:03:13 - alpine_bits_python.alpinebits_server - INFO - Initializing action instance for AlpineBitsActionName.OTA_PING
2025-11-25 12:03:13 - alpine_bits_python.alpinebits_server - INFO - Initializing action instance for AlpineBitsActionName.OTA_HOTEL_RES_NOTIF_GUEST_REQUESTS
2025-11-25 12:03:13 - alpine_bits_python.alpinebits_server - INFO - Initializing action instance for AlpineBitsActionName.OTA_READ
2025-11-25 12:03:13 - alpine_bits_python.webhook_processor - INFO - Registered webhook processor: wix_form
2025-11-25 12:03:13 - alpine_bits_python.webhook_processor - INFO - Registered webhook processor: generic
2025-11-25 12:03:13 - alpine_bits_python.webhook_processor - INFO - Webhook processors initialized
2025-11-25 12:03:13 - alpine_bits_python.api - INFO - Webhook processors initialized
2025-11-25 12:03:13 - alpine_bits_python.api - INFO - Hotel 39054_001 has no push_endpoint configured
2025-11-25 12:03:13 - alpine_bits_python.api - INFO - Hotel 135 has no push_endpoint configured
2025-11-25 12:03:13 - alpine_bits_python.api - INFO - Hotel 39052_001 has no push_endpoint configured
2025-11-25 12:03:13 - alpine_bits_python.api - INFO - Hotel 39040_001 has no push_endpoint configured
2025-11-25 12:03:13 - alpine_bits_python.api - INFO - Running startup tasks (primary worker)...
2025-11-25 12:03:14 - alpine_bits_python.hotel_service - INFO - Created hotel: 39054_001
2025-11-25 12:03:14 - alpine_bits_python.hotel_service - INFO - Created webhook endpoint for hotel 39054_001, type=wix_form, secret=E3wZiShNY47_KqwZUxBe7BJKluorJYj6qHfclrQg1UnyurYojyw_f0Z1KJBrXIuG
2025-11-25 12:03:14 - alpine_bits_python.hotel_service - INFO - Created webhook endpoint for hotel 39054_001, type=generic, secret=PmhN4o5MR4VYR9U04kwgp4nRnJ2FMfxm1V2TARIh46Qx49Iy0sndPzeIYXM31KTU
2025-11-25 12:03:14 - alpine_bits_python.hotel_service - INFO - Created hotel: 135
2025-11-25 12:03:14 - alpine_bits_python.hotel_service - INFO - Created webhook endpoint for hotel 135, type=wix_form, secret=Rb0Dp1mFHZH5vbF66ZsUXoSiIVJdVjskxjlz-PLYXglaJ_DXGo7B7dtw0xbO15_O
2025-11-25 12:03:14 - alpine_bits_python.hotel_service - INFO - Created webhook endpoint for hotel 135, type=generic, secret=KCblY6u535uAgQ-nk0DS24FsilkS73hsplVecXy8vFg0GqDFX1lsF2U4JGmPURtf
2025-11-25 12:03:14 - alpine_bits_python.hotel_service - INFO - Created hotel: 39052_001
2025-11-25 12:03:14 - alpine_bits_python.hotel_service - INFO - Created webhook endpoint for hotel 39052_001, type=wix_form, secret=d-oKOTZ4GqcNIdnR6cMcHtpEUWXNpFgwbc0qRXS_9m1J2vJRYHTjWs3pb8XvF3B_
2025-11-25 12:03:14 - alpine_bits_python.hotel_service - INFO - Created webhook endpoint for hotel 39052_001, type=generic, secret=bdO04CoGOHyl7P8zFOB8dNxaxkccNNyXgM_za9pPiFqm4LmUM4KQ0l2qfOTu7gyM
2025-11-25 12:03:14 - alpine_bits_python.hotel_service - INFO - Created hotel: 39040_001
2025-11-25 12:03:14 - alpine_bits_python.hotel_service - INFO - Created webhook endpoint for hotel 39040_001, type=wix_form, secret=Arj5jksgLxgJcad9OAGIZzWfF1x1g6g965EZKGp-njDsF2oK-jiODYlN4HiO46cz
2025-11-25 12:03:14 - alpine_bits_python.hotel_service - INFO - Created webhook endpoint for hotel 39040_001, type=generic, secret=A-_w63IXXmwsztd1pN6wDEtvr_oKO1GRROO5ff9lad0VTAh7WH5mzqUwdi9H8Be-
2025-11-25 12:03:14 - alpine_bits_python.hotel_service - INFO - Config sync complete: 4 hotels created, 0 updated, 8 endpoints created
2025-11-25 12:03:14 - alpine_bits_python.db_setup - INFO - Config sync: 4 hotels created, 0 updated, 8 endpoints created
2025-11-25 12:03:15 - alpine_bits_python.db_setup - INFO - Backfilling advertising account IDs for existing reservations...
2025-11-25 12:03:15 - alpine_bits_python.db_setup - INFO - Found 4 hotel(s) with account configurations
2025-11-25 12:03:15 - alpine_bits_python.db_setup - INFO - Backfilling usernames for existing acked_requests...
2025-11-25 12:03:15 - alpine_bits_python.db_setup - INFO - Found 4 hotel(s) with usernames in config
2025-11-25 12:03:15 - alpine_bits_python.api - INFO - Startup tasks completed
2025-11-25 12:03:15 - alpine_bits_python.api - INFO - Webhook periodic cleanup task started
2025-11-25 12:03:15 - alpine_bits_python.api - INFO - Application startup complete
2025-11-25 12:03:35 - alpine_bits_python.api - INFO - Application shutdown initiated
2025-11-25 12:03:35 - alpine_bits_python.api - INFO - Webhook cleanup task cancelled
2025-11-25 12:03:35 - alpine_bits_python.api - INFO - Webhook cleanup task stopped
2025-11-25 12:03:35 - alpine_bits_python.email_service - INFO - Shutting down email service thread pool
2025-11-25 12:03:35 - alpine_bits_python.email_service - INFO - Email service thread pool shut down complete
2025-11-25 12:03:35 - alpine_bits_python.api - INFO - Email service shut down
2025-11-25 12:03:35 - alpine_bits_python.api - INFO - Application shutdown complete
2025-11-25 12:03:35 - alpine_bits_python.worker_coordination - INFO - Released primary worker lock (pid=22943)