From acba5282569003dc55b32a96cc2813049a9c6d00 Mon Sep 17 00:00:00 2001 From: Andrew Stern Date: Wed, 13 Jul 2016 09:29:49 -0400 Subject: [PATCH 1/2] Fix for nil on notification object. --- .../soap/responses/get_events_response_message.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/ews/soap/responses/get_events_response_message.rb b/lib/ews/soap/responses/get_events_response_message.rb index 4f75fbdd..971b5f29 100644 --- a/lib/ews/soap/responses/get_events_response_message.rb +++ b/lib/ews/soap/responses/get_events_response_message.rb @@ -32,10 +32,14 @@ def previous_watermark end def new_watermark - ev = notification.last - if ev - type = ev.keys.first - ev[type][:elems][0][:watermark][:text] + if notification + ev = notification.last + if ev + type = ev.keys.first + ev[type][:elems][0][:watermark][:text] + else + nil + end else nil end From c066444f9bdff4cd279623e9d29a02c2d0399258 Mon Sep 17 00:00:00 2001 From: Andrew Stern Date: Wed, 13 Jul 2016 13:15:20 -0400 Subject: [PATCH 2/2] More nil checks. --- lib/ews/soap/responses/get_events_response_message.rb | 4 +++- lib/ews/types/generic_folder.rb | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/ews/soap/responses/get_events_response_message.rb b/lib/ews/soap/responses/get_events_response_message.rb index 971b5f29..f05b2156 100644 --- a/lib/ews/soap/responses/get_events_response_message.rb +++ b/lib/ews/soap/responses/get_events_response_message.rb @@ -50,7 +50,9 @@ def more_events? end def events - notification[3..-1] + if notification + notification[3..-1] + end end end # GetEventsResponseMessage diff --git a/lib/ews/types/generic_folder.rb b/lib/ews/types/generic_folder.rb index b3a85aa9..d77d14b6 100644 --- a/lib/ews/types/generic_folder.rb +++ b/lib/ews/types/generic_folder.rb @@ -289,10 +289,12 @@ def get_events rmsg = resp.response_messages[0] @watermark = rmsg.new_watermark # @todo if parms[:more_events] # get more events - rmsg.events.collect{|ev| - type = ev.keys.first - class_by_name(type).new(ews, ev[type]) - } + if rmsg.events + rmsg.events.collect{|ev| + type = ev.keys.first + class_by_name(type).new(ews, ev[type]) + } + end else raise EwsSubscriptionError, "Folder <#{self.display_name}> not subscribed to. Issue a Folder#subscribe before checking events." end