Skip to content

Commit

Permalink
Merge pull request #87 from ecederstrand/patch-1
Browse files Browse the repository at this point in the history
Loosen check on return value of CreateItem
  • Loading branch information
ajay-k authored Feb 23, 2023
2 parents 65ec3de + bf17d90 commit bd80fd4
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions exchangelib/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,9 @@ def _create(self, message_disposition, send_meeting_invitations):
res = self.account.bulk_create(
items=[self], folder=self.folder, message_disposition=message_disposition,
send_meeting_invitations=send_meeting_invitations)
if message_disposition in (SEND_ONLY, SEND_AND_SAVE_COPY):
if res:
raise ValueError('Got a response in non-save mode')
if not res:
return None
if len(res) != 1:
if len(res) > 1:
raise ValueError('Expected result length 1, but got %s' % res)
if isinstance(res[0], Exception):
raise res[0]
Expand Down Expand Up @@ -713,10 +711,7 @@ def send(self, save_copy=True, copy_to_folder=None, conflict_resolution=AUTO_RES
send_meeting_invitations=send_meeting_invitations)
return None

res = self._create(message_disposition=SEND_ONLY, send_meeting_invitations=send_meeting_invitations)
if res:
raise ValueError('Unexpected response in send-only mode')
return None
return self._create(message_disposition=SEND_ONLY, send_meeting_invitations=send_meeting_invitations)

def send_and_save(self, update_fields=None, conflict_resolution=AUTO_RESOLVE,
send_meeting_invitations=SEND_TO_NONE):
Expand All @@ -737,12 +732,10 @@ def send_and_save(self, update_fields=None, conflict_resolution=AUTO_RESOLVE,
self.send(save_copy=False, conflict_resolution=conflict_resolution,
send_meeting_invitations=send_meeting_invitations)
else:
res = self._create(
return self._create(
message_disposition=SEND_AND_SAVE_COPY,
send_meeting_invitations=send_meeting_invitations
)
if res:
raise ValueError('Unexpected response in send-only mode')

def reply(self, subject, body, to_recipients=None, cc_recipients=None, bcc_recipients=None):
if not self.account:
Expand Down

0 comments on commit bd80fd4

Please sign in to comment.