Skip to content

Commit

Permalink
feat(bookings): [PPT-1430] signal on induction accepted/declined
Browse files Browse the repository at this point in the history
  • Loading branch information
chillfox committed Dec 19, 2024
1 parent 949da77 commit b1aa0a0
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/controllers/bookings.cr
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,32 @@ class Bookings < Application
@[AC::Param::Info(description: "provided for use with analytics", example: "mobile")]
utm_source : String? = nil
) : Booking
if (induction.accepted? || induction.declined?) &&
(guest = booking.attendees.to_a[0]?.try &.guest)
action = if induction.accepted?
:induction_accepted
else
:induction_declined
end

spawn do
get_placeos_client.root.signal("staff/guest/#{action}", {
action: action,
id: guest.id,
induction: induction,
booking_id: booking.id,
resource_id: booking.asset_id,
resource_ids: booking.asset_ids,
event_summary: booking.description.presence || booking.title,
event_starting: booking.booking_start,
attendee_name: guest.name,
attendee_email: guest.email,
host: booking.user_email,
zones: booking.zones,
})
end
end

booking.induction = induction
booking.utm_source = utm_source
update_booking(booking, "induction")
Expand Down Expand Up @@ -1025,6 +1051,7 @@ class Bookings < Application
extension_data: booking.extension_data,
booked_by_email: booking.booked_by_email,
booked_by_name: booking.booked_by_name,
induction: booking.induction,
})
rescue error
Log.error(exception: error) { "while signaling booking #{signal}" }
Expand Down

0 comments on commit b1aa0a0

Please sign in to comment.