MCPcopy Index your code
hub / github.com/O365/python-o365 / save_message

Method save_message

O365/message.py:942–976  ·  view source on GitHub ↗

Saves changes to a message. If the message is a new or saved draft it will call 'save_draft' otherwise this will save only properties of a message that are draft-independent such as: - is_read - category - flag :return: Success / Failure

(self)

Source from the content-addressed store, hash-verified

940 return self.__class__(parent=self, **{self._cloud_data_key: message})
941
942 def save_message(self):
943 """ Saves changes to a message.
944 If the message is a new or saved draft it will call 'save_draft' otherwise
945 this will save only properties of a message that are draft-independent such as:
946 - is_read
947 - category
948 - flag
949 :return: Success / Failure
950 :rtype: bool
951 """
952 if self.object_id and not self.__is_draft:
953 # we are only allowed to save some properties:
954 allowed_changes = {self._cc('isRead'), self._cc('categories'),
955 self._cc('flag'), self._cc('subject')} # allowed changes to be saved by this method
956 changes = {tc for tc in self._track_changes if tc in allowed_changes}
957
958 if not changes:
959 return True # there's nothing to update
960
961 url = self.build_url(self._endpoints.get('get_message').format(id=self.object_id))
962
963 data = self.to_api_data(restrict_keys=changes)
964
965 response = self.con.patch(url, data=data)
966
967 if not response:
968 return False
969
970 self._track_changes.clear() # reset the tracked changes as they are all saved
971 self.__modified = dt.datetime.now().replace(tzinfo=self.protocol.timezone)
972
973 return True
974 else:
975 # fallback to save_draft
976 return self.save_draft()
977
978 def save_draft(self, target_folder=OutlookWellKnowFolderNames.DRAFTS):
979 """ Save this message as a draft on the cloud

Callers 1

test_save_messageMethod · 0.80

Calls 7

to_api_dataMethod · 0.95
save_draftMethod · 0.95
_ccMethod · 0.80
build_urlMethod · 0.80
getMethod · 0.45
patchMethod · 0.45
clearMethod · 0.45

Tested by 1

test_save_messageMethod · 0.64