Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ shards:

bindata:
git: https://github.com/spider-gazelle/bindata.git
version: 1.9.1
version: 1.10.0

clear:
git: https://github.com/place-labs/clear.git
Expand All @@ -47,7 +47,7 @@ shards:

email:
git: https://github.com/arcage/crystal-email.git
version: 0.6.3
version: 0.6.4

faker:
git: https://github.com/askn/faker.git
Expand Down Expand Up @@ -91,12 +91,20 @@ shards:

neuroplastic:
git: https://github.com/spider-gazelle/neuroplastic.git
version: 1.10.0
version: 1.11.0

office365:
git: https://github.com/placeos/office365.git
version: 1.14.0

open_api:
git: https://github.com/elbywan/open_api.cr.git
version: 1.3.0

openapi-generator:
git: https://github.com/place-labs/openapi-generator.git
version: 2.1.0+git.commit.a65ffc2f7dcc6a393e7d1f9229650b520d9525be

openssl_ext:
git: https://github.com/spider-gazelle/openssl_ext.git
version: 2.1.5
Expand All @@ -119,7 +127,7 @@ shards:

placeos-models:
git: https://github.com/placeos/models.git
version: 6.2.0
version: 6.3.0

promise:
git: https://github.com/spider-gazelle/promise.git
Expand Down
48 changes: 28 additions & 20 deletions src/controllers/bookings.cr
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,20 @@ class Bookings < Application
})

spawn do
get_placeos_client.root.signal("staff/guest/attending", {
action: :booking_created,
id: guest.id,
booking_id: booking.id,
resource_id: booking.asset_id,
title: booking.title,
booking_start: booking.booking_start,
attendee_name: attendee.name,
attendee_email: attendee.email,
})
begin
get_placeos_client.root.signal("staff/guest/attending", {
action: :booking_created,
id: guest.id,
booking_id: booking.id,
resource_id: booking.asset_id,
title: booking.title,
booking_start: booking.booking_start,
attendee_name: attendee.name,
attendee_email: attendee.email,
})
rescue error
Log.warn(exception: error) { "failed to signal guest attendance" }
end
end
end
end
Expand Down Expand Up @@ -302,16 +306,20 @@ class Bookings < Application

if !previously_visiting
spawn do
get_placeos_client.root.signal("staff/guest/attending", {
action: :booking_updated,
id: guest.id,
booking_id: existing_booking.id,
resource_id: existing_booking.asset_id,
title: existing_booking.title,
booking_start: existing_booking.booking_start,
attendee_name: attendee.name,
attendee_email: attendee.email,
})
begin
get_placeos_client.root.signal("staff/guest/attending", {
action: :booking_updated,
id: guest.id,
booking_id: existing_booking.id,
resource_id: existing_booking.asset_id,
title: existing_booking.title,
booking_start: existing_booking.booking_start,
attendee_name: attendee.name,
attendee_email: attendee.email,
})
rescue error
Log.warn(exception: error) { "failed to signal guest attendance" }
end
end
end
end
Expand Down
166 changes: 97 additions & 69 deletions src/controllers/events.cr
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,18 @@ class Events < Application
})

spawn do
placeos_client.root.signal("staff/event/changed", {
action: :create,
system_id: input_event.system_id,
event_id: created_event.id,
host: host,
resource: sys.email,
ext_data: input_event.extension_data,
})
begin
placeos_client.root.signal("staff/event/changed", {
action: :create,
system_id: input_event.system_id,
event_id: created_event.id,
host: host,
resource: sys.email,
ext_data: input_event.extension_data,
})
rescue error
Log.warn(exception: error) { "failed to signal event creation" }
end
end

# Save custom data
Expand Down Expand Up @@ -197,17 +201,21 @@ class Events < Application
})

spawn do
placeos_client.root.signal("staff/guest/attending", {
action: :meeting_created,
system_id: sys.id,
event_id: created_event.id,
host: host,
resource: sys.email,
event_summary: created_event.body,
event_starting: created_event.event_start.not_nil!.to_unix,
attendee_name: attendee.name,
attendee_email: attendee.email,
})
begin
placeos_client.root.signal("staff/guest/attending", {
action: :meeting_created,
system_id: sys.id,
event_id: created_event.id,
host: host,
resource: sys.email,
event_summary: created_event.body,
event_starting: created_event.event_start.not_nil!.to_unix,
attendee_name: attendee.name,
attendee_email: attendee.email,
})
rescue error
Log.warn(exception: error) { "failed to signal guest attendance" }
end
end
end
end
Expand Down Expand Up @@ -453,7 +461,33 @@ class Events < Application

if !previously_visiting || changing_room
spawn do
begin
sys = system.not_nil!

placeos_client.root.signal("staff/guest/attending", {
action: :meeting_update,
system_id: sys.id,
event_id: event_id,
host: host,
resource: sys.email,
event_summary: updated_event.not_nil!.body,
event_starting: updated_event.not_nil!.event_start.not_nil!.to_unix,
attendee_name: attendee.name,
attendee_email: attendee.email,
})
rescue error
Log.warn(exception: error) { "failed to signal guest attendance" }
end
end
end
end
elsif changing_room
existing.each do |attend|
next unless attend.visit_expected
spawn do
begin
sys = system.not_nil!
guest = attend.guest

placeos_client.root.signal("staff/guest/attending", {
action: :meeting_update,
Expand All @@ -463,32 +497,14 @@ class Events < Application
resource: sys.email,
event_summary: updated_event.not_nil!.body,
event_starting: updated_event.not_nil!.event_start.not_nil!.to_unix,
attendee_name: attendee.name,
attendee_email: attendee.email,
attendee_name: guest.name,
attendee_email: guest.email,
})
rescue error
Log.warn(exception: error) { "failed to signal guest attendance" }
end
end
end
elsif changing_room
existing.each do |attend|
next unless attend.visit_expected
spawn do
sys = system.not_nil!
guest = attend.guest

placeos_client.root.signal("staff/guest/attending", {
action: :meeting_update,
system_id: sys.id,
event_id: event_id,
host: host,
resource: sys.email,
event_summary: updated_event.not_nil!.body,
event_starting: updated_event.not_nil!.event_start.not_nil!.to_unix,
attendee_name: guest.name,
attendee_email: guest.email,
})
end
end
end
end

Expand All @@ -497,15 +513,19 @@ class Events < Application

# Update PlaceOS with an signal "staff/event/changed"
spawn do
sys = system.not_nil!
placeos_client.root.signal("staff/event/changed", {
action: :update,
system_id: sys.id,
event_id: event_id,
host: host,
resource: sys.email,
ext_data: eventmeta.try &.ext_data,
})
begin
sys = system.not_nil!
placeos_client.root.signal("staff/event/changed", {
action: :update,
system_id: sys.id,
event_id: event_id,
host: host,
resource: sys.email,
ext_data: eventmeta.try &.ext_data,
})
rescue error
Log.warn(exception: error) { "failed to signal event update" }
end
end

render json: StaffApi::Event.augment(updated_event.not_nil!, system.not_nil!.email, system, eventmeta)
Expand Down Expand Up @@ -636,12 +656,16 @@ class Events < Application
EventMetadata.query.by_tenant(tenant.id).where({event_id: event_id}).delete_all

spawn do
placeos_client.root.signal("staff/event/changed", {
action: :cancelled,
system_id: system.not_nil!.id,
event_id: event_id,
resource: system.not_nil!.email,
})
begin
placeos_client.root.signal("staff/event/changed", {
action: :cancelled,
system_id: system.not_nil!.id,
event_id: event_id,
resource: system.not_nil!.email,
})
rescue error
Log.warn(exception: error) { "failed to signal event deletion" }
end
end
end

Expand Down Expand Up @@ -797,19 +821,23 @@ class Events < Application

# Update PlaceOS with an signal "staff/guest/checkin"
spawn do
get_placeos_client.root.signal("staff/guest/checkin", {
action: :checkin,
checkin: checkin,
system_id: system_id,
event_id: event_id,
host: event.host,
resource: eventmeta.resource_calendar,
event_summary: event.not_nil!.body,
event_starting: eventmeta.event_start,
attendee_name: guest.name,
attendee_email: guest.email,
ext_data: eventmeta.ext_data,
})
begin
get_placeos_client.root.signal("staff/guest/checkin", {
action: :checkin,
checkin: checkin,
system_id: system_id,
event_id: event_id,
host: event.host,
resource: eventmeta.resource_calendar,
event_summary: event.not_nil!.body,
event_starting: eventmeta.event_start,
attendee_name: guest.name,
attendee_email: guest.email,
ext_data: eventmeta.ext_data,
})
rescue error
Log.warn(exception: error) { "failed to signal guest checkin" }
end
end

render json: attending_guest(attendee, attendee.guest)
Expand Down