Add support for embedded attachments#5
Conversation
mortymacs
left a comment
There was a problem hiding this comment.
Thanks for the PR!
I requested some changes. I also suggested some changes which you can apply if you agree ;)
Also, the important question I have is related to the endpoints, that I couldn't find .../attachments/item/ or .../attachments/item/... endpoints in the Microsoft Graph documents. Would you please share the Microsoft Graph page you've followed for these endpoints?
| item = get_item_by_folder(req, folder, itemid) | ||
| self._response_attachments(req, resp, item, attachmentid) | ||
|
|
||
| def on_get_embedded_item_in_folder_by_id(self, req, resp, folderid, itemid, attachmentid): |
There was a problem hiding this comment.
I can't find any suffix in the routes list with this name. Where does this method connect to?
| self.add_route(user + '/mailFolders/{folderid}/messages/{itemid}/attachments/{attachmentid}/item', | ||
| attachments, suffix="embedded_item_by_id") | ||
| self.add_route(user + '/mailFolders/{folderid}/messages/{itemid}/attachments/{attachmentid}/item/$value', | ||
| messages, suffix="embedded_folder_value") |
There was a problem hiding this comment.
Also, the same for here. Something like embedded_item_by_value. What's your idea?
| self.add_route(user + '/messages/{itemid}/attachments/{attachmentid}/item', | ||
| attachments, suffix="embedded_item_by_id") | ||
| self.add_route(user + '/messages/{itemid}/attachments/{attachmentid}/item/$value', | ||
| messages, suffix="embedded_value") |
There was a problem hiding this comment.
May I ask you to change the suffix to be more consistent? Something like embedded_item_by_value like the previous route. What's your idea?
| req (Request): Falcon request object. | ||
| resp (Response): Falcon response object. | ||
| item (Item): instance of an item. | ||
| attachmentid (str): attachment ID which is related to the item. Must be set. |
There was a problem hiding this comment.
| attachmentid (str): attachment ID which is related to the item. Must be set. | |
| attachmentid (str): attachment ID which is related to the item. |
As it doesn't have any default value, it's not needed to mention it. Because Python will raise an error anyway.
| item (Item): instance of an item. | ||
| attachmentid (str): attachment ID which is related to the item. Must be set. | ||
| """ | ||
|
|
| if not attachmentid: | ||
| raise falcon.HTTPNotFound() | ||
|
|
||
| response = partial(self.respond, req, resp) |
There was a problem hiding this comment.
Just a suggestion: you can call self.respond without using the partial function based on your function implementation.
| resp (Response): Falcon response object. | ||
| folderid (str): folder ID which the item exists in. | ||
| itemid (str): item ID (e.g. message ID or event ID). | ||
| attachmentid (str): attachment ID which is related to the item. Must be set. |
There was a problem hiding this comment.
| attachmentid (str): attachment ID which is related to the item. Must be set. | |
| attachmentid (str): attachment ID which is related to the item. |
The same for here.
|
|
||
| att_fields = [] | ||
| for att in attachments: | ||
| if att.embedded is True: |
There was a problem hiding this comment.
| if att.embedded is True: | |
| if att.embedded: |
Just a suggestion.
|
|
||
| relations = { | ||
| 'attachments': lambda message: (message.attachments, attachment.FileAttachmentResource), # TODO embedded | ||
| 'attachments': lambda message: (message.attachments(embedded=True), attachment.FileAttachmentResource), # TODO embedded |
There was a problem hiding this comment.
All attachments are embedded?
|
Thanks for your comments. Just wanted to leave a note that this is not forgotten. Nevertheless, I have this code already running in a productive environment. Therefore, for testing changes, I will have to ask the admin for setting up a test environment. |
Most of the bits were there already. Encapsulating field sets per attachments in a tuple was already there to be read. Just had to be implemented in the respective function. Support for referenceAttachments should be easy to implement.
I have based that still on master as the other pull request has not been merged yet.