Skip to content

Commit

Permalink
test(events): [PPT-1473] return most detailed metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
chillfox committed Dec 16, 2024
1 parent f871759 commit 64a6f06
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/controllers/events.cr
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,20 @@ class Events < Application
# where there might be multiple resource calendars on the event we want to pick
# metadatas that most closely match the request
# and has the most information
#
# meta.ext_data is a JSON::Any | Nil type which can contain either nil or a hash.
# This means that nil checks can be unreliable and we should use the `==` or `!=` operator
# instead of `meta.ext_data.nil?` or `meta.ext_data`.
#
# meta.ext_data.nil? # => false
# meta.ext_data == nil # => true
# typeof(meta.ext_data) # => (JSON::Any | Nil)
# meta.ext_data.class # => JSON::Any
# meta.ext_data # => nil
#
#
next if (existing = metadatas[meta.ical_uid]?) && calendars[existing.resource_calendar]? &&
!(calendars[meta.resource_calendar]? && meta.ext_data)
!(calendars[meta.resource_calendar]? && meta.ext_data != nil)

metadatas[meta.ical_uid] = meta
if recurring_master_id = meta.recurring_master_id
Expand Down

0 comments on commit 64a6f06

Please sign in to comment.