@@ -12,6 +12,7 @@ class Place::RoomBookingApprovalAltnerative < PlaceOS::Driver
1212 default_accept_message: " Request accepted" ,
1313 default_decline_message: " Request not accepted" ,
1414 events_requiring_approval_are_tentative: true ,
15+ always_poll_ms_graph: true ,
1516 })
1617
1718 accessor calendar : Calendar_1
@@ -24,6 +25,7 @@ class Place::RoomBookingApprovalAltnerative < PlaceOS::Driver
2425 @default_accept_message : String = " Request accepted"
2526 @default_decline_message : String = " Request not accepted"
2627 @events_requiring_approval_are_tentative : Bool = true
28+ @always_poll_ms_graph : Bool = true
2729
2830 def on_load
2931 on_update
@@ -45,6 +47,7 @@ class Place::RoomBookingApprovalAltnerative < PlaceOS::Driver
4547 @default_accept_message = setting?(String , :default_accept_message ) || " Request accepted"
4648 @default_decline_message = setting?(String , :default_decline_message ) || " Request not accepted"
4749 @events_requiring_approval_are_tentative = setting?(Bool , :events_requiring_approval_are_tentative ) || true
50+ @always_poll_ms_graph = setting?(Bool , :always_poll_ms_graph ) || true
4851 end
4952
5053 # Finds the building ID for the current location services object
@@ -71,7 +74,12 @@ class Place::RoomBookingApprovalAltnerative < PlaceOS::Driver
7174 system_ids.each do |system_id |
7275 sys = system(system_id)
7376 if sys.exists?(" Bookings" , 1 )
74- if bookings = sys.get(" Bookings" , 1 ).status?(Array (PlaceCalendar ::Event ), " bookings" )
77+ bookings_module = sys.get(" Bookings" , 1 )
78+ if @always_poll_ms_graph
79+ bookings_module.poll_events
80+ sleep 1 .seconds
81+ end
82+ if bookings = bookings_module.status?(Array (PlaceCalendar ::Event ), " bookings" )
7583 @events_requiring_approval_are_tentative ? bookings.select! { |event | event.status == " tentative" } : bookings.select! { |booking | room_attendee(booking).try(& .response_status).in?({" needsAction" , " tentative" }) }
7684 results[system_id] = bookings unless bookings.empty?
7785 end
@@ -84,10 +92,12 @@ class Place::RoomBookingApprovalAltnerative < PlaceOS::Driver
8492
8593 def accept_event (calendar_id : String , event_id : String , user_id : String ? = nil , notify : Bool ? = nil , comment : String ? = nil )
8694 calendar.accept_event(calendar_id: calendar_id, event_id: event_id, user_id: user_id, notify: notify || @notify_host_on_accept , comment: comment || @default_accept_message )
95+ find_bookings_for_approval
8796 end
8897
8998 def decline_event (calendar_id : String , event_id : String , user_id : String ? = nil , notify : Bool ? = nil , comment : String ? = nil )
9099 calendar.decline_event(calendar_id: calendar_id, event_id: event_id, user_id: user_id, notify: notify || @notify_host_on_decline , comment: comment || @default_decline_message )
100+ find_bookings_for_approval
91101 end
92102
93103 private def room_attendee (event : PlaceCalendar ::Event )
0 commit comments