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)
| 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 |