Skip to content
Browse files

Fix EwSParser.resolution_set to work if <t:Contact> is missing

Sometimes ResolveNames will return <t:Resolution> entities with no <t:Contact>
- the example that bit me was if the auth'd EWS user has the user we are
resolving as a contact.

Workaround this by skipping <t:Resolution> entities with no <t:Contact>, this
should work okay until we want to start searching for users who *are* contacts.

The returned SOAP response for the case above looks something like:

<m:ResolutionSet TotalItemsInView="2" IncludesLastItemInRange="true">
  <t:Resolution>
    <t:Mailbox>
      <t:Name>me@mycompany.com</t:Name>
      <t:EmailAddress>me@mycompany.com</t:EmailAddress>
      <t:RoutingType>SMTP</t:RoutingType>
      <t:MailboxType>Mailbox</t:MailboxType>
    </t:Mailbox>
    <t:Contact>
      <!-- yada yada -->
    </t:Contact>
  </t:Resolution>
  <t:Resolution>
    <t:Mailbox>
      <t:Name>me@mycompany.com</t:Name>
      <t:EmailAddress>me@mycompany.com</t:EmailAddress>
      <t:RoutingType>SMTP</t:RoutingType>
      <t:MailboxType>Contact</t:MailboxType>
      <t:ItemId Id="really-long-string"
        ChangeKey="not-quite-as-long-string"/>
    </t:Mailbox>
  </t:Resolution>
</m:ResolutionSet>
  • Loading branch information...
1 parent de83505 commit b41121bf4595923cb3f8c91a2fd0a21813c1875d @geoffwa committed Jan 1, 2012
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/soap/handsoap/parsers/ews_parser.rb
View
5 lib/soap/handsoap/parsers/ews_parser.rb
@@ -225,8 +225,9 @@ def resolution_set
resolution_set = []
(@response/"//#{NS_EWS_MESSAGES}:ResolutionSet/*").each do |r|
mbox_hash = mailbox((r/"#{NS_EWS_TYPES}:Mailbox").first)
- contact_hash = contact((r/"#{NS_EWS_TYPES}:Contact").first)
- resolution_set << mbox_hash.merge(contact_hash)
+ contact_xml = (r/"#{NS_EWS_TYPES}:Contact").first
+ next if !contact_xml
+ resolution_set << mbox_hash.merge(contact(contact_xml))
end
resolution_set
end

0 comments on commit b41121b

Please sign in to comment.
Something went wrong with that request. Please try again.